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")
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值