torch.Tensor.index_put_

Tensor.index_put_(indices, values, accumulate=False) Tensor

使用indices中指定的索引(这是一个张量元组),将来自values张量的值放入self张量。表达式tensor.index_put_(indices, values)等同于tensor[indices] = values。返回self

accumulateTrue 时,values 中的元素会被添加到 self。如果 accumulateFalse,且 indices 包含重复元素,则行为未定义。

参数
  • indices (元组 of LongTensor) – 用于对 self 进行索引的张量。

  • values (Tensor) – 具有与self相同数据类型的张量。

  • accumulate (bool) – 是否将结果累积到 self 中

本页目录