scatter_(dim, index, src) → Tensor
Writes all values from the tensor src
into self at the indices specified in the index
tensor. For each value in src, its output index is specified by its index in src for dimension != dim and by the corresponding value in index for dimension = dim.
- 官网的例子就可以看出来,dim=0的时候,src中的元素对应到index的元素,放在某行,这个由index确定;dim=1的时候src中的值代表对应某列。
For a 3-D tensor, self is updated as:
self[index[i][j][k]][j][k] = src[i][j][k] # if dim == 0
self[i][index[i][j][k]][k] = src[i][j][k] # if dim == 1
self[i][j][index[i][j][k]] = src[i][j][k] # if dim == 2