評價此頁

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