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