评价此页

torch.Tensor.index_put_#

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

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

如果 accumulateTrue,则将 values 中的元素加到 self 中。如果 accumulate 为 False,则当索引包含重复元素时,行为未定义。

参数
  • indices (tuple of LongTensor) – 用于索引 self 的张量。

  • values (Tensor) – 与 self 具有相同 dtype 的张量。

  • accumulate (bool) – 是否累加到 self