torch.Tensor.index_put_¶
- Tensor.index_put_(indices, values, accumulate=False) → Tensor
将张量
values
中的值根据索引indices
(索引为张量元组)放入张量self
中。表达式tensor.index_put_(indices, values)
与tensor[indices] = values
等价。返回self
。如果
accumulate
是True
,则将values
中的元素添加到self
中。如果累加是False
,则如果索引包含重复元素,行为未定义。- 参数:
索引(LongTensor 的元组)- 用于索引 self 的张量。
values(Tensor)- 与 self 相同数据类型的张量。
accumulate(布尔值)- 是否累加到 self