当前位置:网站首页>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 .
边栏推荐
- Niuke White Moon race 52
- End-to-end 3D Point Cloud Instance Segmentation without Detection
- 云服务器上部署仿牛客网项目
- Unity 基础光照模型
- Experiment 4 QT
- Redis design and Implementation (III) | interaction between server and client (event IO model)
- 示波器探头对测量电容负荷有影响吗?
- VIM from dislike to dependence (21) -- cross file search
- 【NVMe2.0b 14-8】Set Features(下篇)
- 电流探头的干扰源电流谱测试
猜你喜欢

Swagger use

Build a docker image of Henkel database from 0

自制GIF动态图-gifcam

vim 从嫌弃到依赖(21)——跨文件搜索

【NVMe2.0b 14-8】Set Features(下篇)

What are the Amazon evaluation terms?

我们如何拿到自己满意的薪资呢?这些套路还是需要掌握的

【NVMe2.0b 14-1】Abort、Asynchronous Event Request、Capacity Management command

Redis设计与实现(三)| 服务器与客户端的交互(事件IO模型)

swagger使用
随机推荐
Viteproject require Syntax Compatibility Problem Solving require is not defined
C # about Net cognition
Redis设计与实现(四)| 主从复制
Game 280 problem2: minimum operands to turn an array into an alternating array
Sword finger offer II 076 The kth largest number in the array (use heap to solve TOPK problem)
【NVMe2.0b 14-4】Directive Send/Receive command
Redis设计与实现(二)| 数据库(删除策略&过期淘汰策略)
Niuke Xiaobai month race 52
1163 Dijkstra Sequence
Leetcode47. full arrangement II
php api获取二维码、组合生成图片
Circuit analysis of current probe
MIME type Encyclopedia
电流探头电路分析
C preliminary chapter learning route
Oracle expansion table space installed in docker
小心transmittable-thread-local的这个坑
[nvme2.0b 14-8] set features (Part 2)
我们如何拿到自己满意的薪资呢?这些套路还是需要掌握的
增强for循环的增删操作 & 迭代器删除集合元素