栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

Pytorch-scatter方法

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Pytorch-scatter方法

标题Pytorch_scatter中的scatter包

例子:

解释:
将src按index的指示,在维度dim上进行修改。
1、关于元素位置
index=[0,0,1]中第一个0表示将第dim=1维度中的下标为0的元素[1.0226,-0.3013]放在输出的下标为0的位置;第二个0表示将下标为1的元素[-0.1796,-0.4600]放在输出下标为0的位置;同理第三个1表示将下标为3的放在输出1的位置,具体如下图:
由于第一行和第二行都换到了输出的相同维度,因此我们对这两行执行reduce函数操作(默认为sum)
2、关于输出维度
dim=1表示修改原维度[1,3,2]为[1,max[0,0,1]+1,2],即[1,2,2]。(注:输出维度也可利用out及dim_size参数指定)

3、源注释
以下是官方文档对于scatter函数的解释,供大家学习时参考。

   Parameters :
    src – The source tensor.
    index – The indices of elements to scatter.
    dim – The axis along which to index. (default: -1)
    out – The destination tensor.
    dim_size – If out is not given, automatically create output with size dim_size at dimension dim. If dim_size is not given, a minimal sized output tensor according to index.max() + 1 is returned.
    reduce – The reduce operation ("sum", "mul", "mean", "min" or "max"). (default: "sum")
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/822645.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号