A.scatter_(dim, index, B) # 基本用法, tensor A 被就地scatter到 tensor B
如果dim = 0,意思就是在保持行索引不变的情况下,针对每一行,把每个原色的列索引转换为index里面的数值。
可以用于生成one - hot embedding
参考:
https://zhuanlan.zhihu.com/p/339043454