当前位置:网站首页>Detailed explanation of pytoch's scatter function
Detailed explanation of pytoch's scatter function
2022-06-30 08:31:00 【Wu lele~】
List of articles
Preface
Looking at FCOS Algorithm source code , It is found that... Is used to obtain positive sample points scatter This function , So record it .
1、 Interpretation of official documents
Post the link first :scatter Official interpretation
Tensor.scatter_(dim, index, src, reduce=None) → Tensor
Receive three parameters : dim, index and src. This function is used to stay dim Dimensionally , according to index Index provided , from src Extract the corresponding element from the to assign to Tensor. The following is an official example of a three-dimensional tensor .
Two points need to be noted :index and src Of dim The dimensions must be the same ! In the official 3-D tensor For example , namely self、src and index The dimensions of are 3; if 2D-tensor be self、src and index The dimensions of are 2. Because I need to use index As an index , so index The size of the element in must be <self.size(d) And src.size(d).
2、 for instance

Attach code :
src = torch.Tensor([[0,1,2,3,4],[5,6,7,8,9]])
self = torch.zeros((3,5))
index = torch.tensor([[0,1,2,0,0],[2,0,0,1,2]])
self.scatter_(dim=0,index=index,src=src)
print(self)
Output :
summary
In actual programming ,src It is often scalar , Is a constant . According to the definition , On the right side of the equation src[i][j] Identical to scalar . Is this time scatter The function is based on index take self The corresponding position in becomes a constant .
边栏推荐
- How can we get a satisfactory salary? These routines still need to be mastered
- Tidb 6.0: making Tso more efficient tidb Book rush
- [flower carving experience] 14 line blank board pingpong library test external sensor module (one)
- End-to-end 3D Point Cloud Instance Segmentation without Detection
- Codeworks 5 questions per day (1700 for each) - the third day
- 【NVMe2.0b 14-2】Create/Delete Queue
- Dlib library blink
- 自制GIF动态图-gifcam
- Experiment 2 LED button PWM 2021/11/22
- [untitled]
猜你喜欢

Circuit analysis of current probe

【NVMe2.0b 14-5】Firmware Download/Commit command

Swagger use

微信公众号第三方平台开发,零基础入门。想学我教你啊

Graffiti Wi Fi & ble SoC development slide strip

Do you know the IP protocol?

El input limit can only input numbers

Redis design and Implementation (III) | interaction between server and client (event IO model)

【NVMe2.0b 14-2】Create/Delete Queue

【NVMe2.0b 14】NVMe Admin Command Set
随机推荐
Graffiti Wi Fi & ble SoC development slide strip
Implementation of remote monitoring by camera in Experiment 5
vim 从嫌弃到依赖(21)——跨文件搜索
Experiment 3 remote control
Applet uses QR code plug-in
我们如何拿到自己满意的薪资呢?这些套路还是需要掌握的
JS中的this指向
Sword finger offer II 075 Array relative sort (custom sort, count sort)
【NVMe2.0b 14-2】Create/Delete Queue
酒精测试仪方案:酒精测试仪是根据什么原理测酒精溶度?
Redis design and Implementation (I) | data structure & object
Tidb v6.0.0 (DMR): initial test of cache table - tidb Book rush
Flink Sql -- toAppendStream doesn‘t support consuming update and delete changes which
[untitled]
示波器探头对测量电容负荷有影响吗?
文件上传 upload 组件 on-success 事件,添加自定义参数
File upload component on success event, add custom parameters
【NVMe2.0b 14-4】Directive Send/Receive command
C# ListBox如何获取选中的内容(搜了很多无效的文章)
[untitled]