pytorch scatter_add_用法

pytorch torch.scatter_add_()函数用法

self_tensor.scatter_add_(dim, index_tensor, other_tensor) 

函数的作用

将other_tensor中的数据,按照index_tensor中的索引位置,添加至self_tensor中
这里给出官网的说明,非常清晰
在这里插入图片描述
解释起来就是,dim决定了哪个维度的索引是由index tensor提供的,其他所有位置是self_tensor和other_tensor一一对应的!

例子

在这里插入图片描述

发布了131 篇原创文章 · 获赞 6 · 访问量 6919

猜你喜欢

转载自blog.csdn.net/Orientliu96/article/details/104830383