当前位置:网站首页>reduce_sum()中的reduction_indices
reduce_sum()中的reduction_indices
2022-06-22 05:44:00 【惊瑟】
参考知乎这篇答案
https://www.zhihu.com/question/51325408/answer/125426642
reduction_indices,直译过来就是指“坍塌维度”,即按照哪个维度进行加法运算。
如:

由于square(y-x)=[1,4,9,16],是个一维向量(张量),所以reduction_indices只能设为0,设其他会报错。运算结果是30,也就是1维坍塌为0维。
将xy换成二维张量试试:

此时,square(y-x)=[[1,4,9,16],[1,4,9,16]],各位猜测一下结果是多少呢?没错,就是按照0维坍塌,即“行”,即原来的n行变1行,即按行进行sum,答案为[2,8,18,32]。
举一反三,如果reduction_indices=[1]呢?
答案是:[30,30],可以理解为[[30],[30]]。
over。
边栏推荐
- 不务正业系列7:老照片去除斑点手法
- Improve your game‘s performance
- 402 string (Title: Sword finger offer58 ii. left rotation string, 28. implementation of strstr(), 459 Repeated substrings)
- DOS bat syntax record I
- Xshell download and installation (solve the problem of expired evaluation)
- 格雷码与二进制的转换
- I2C interface
- Improve your game‘s performance
- tmux -- ssh terminal can be closed without impact the server process
- Introduction to golang Viper Library
猜你喜欢

TCP connection details

Unity development - scene asynchronous loading

Matlab system identification

Case analysis of terminal data leakage prevention

富设备平台突破:基于RK3568的DAYU200进入OpenHarmony 3.1 Release主干

Error: note: module requires go 1.17

Simple use of idea plug-in easy code

Ptrade trading program code - from zero to firm offer 19

Clion installation Download

记录在处理SIF数据中,遇到的一些问题及解决过程
随机推荐
n个整数的无序数组,找到每个元素后面比它大的第一个数,要求时间复杂度为O(N)
Server PHP related web page development environment construction
Test platform for combinational logic blocks
汇顶科技GR551x系列开发板已支持OpenHarmony
vcpkg:If you are sure you want to rebuild the above packages, run the command with the --recurse opt
[soft test] senior system architecture designer learning experience sharing
Creating GLSL Shaders at Runtime in Unity3D
非传递骰子(春季每日一题 51)
401 string (344. reverse string, 541. reverse string II, Title: Sword finger offer 05. replace spaces, 151. reverse words in string)
An unordered array of N integers. Find the first number after each element that is larger than it. The time complexity is O (n)
Bat common batch script record
What about computer jam?
Remove then add string from variable of Makefile
信号输出库
Development prospect forecast and investment strategy analysis report of global and Chinese manganese oxide nano powder industry 2022-2028
MFC TabCtrl 控件修改标签尺寸
Ethernet communication protocol
The first week of wechat applet development: page setup, page Jump and data binding
AUTOSAR从入门到精通100讲(150)-SOA架构及应用
Serial port (RS - 232)