torch.Tensor.index_put_¶ Tensor.index_put_(indices, values, accumulate=False) → Tensor¶ 將張量 values 中的值放入張量 self 中,使用的索引在 indices 中指定(indices 是一個由張量組成的元組)。表示式 tensor.index_put_(indices, values) 等同於 tensor[indices] = values。返回 self。 如果 accumulate 為 True,則將 values 中的元素新增到 self 中。如果 accumulate 為 False,並且 indices 包含重複元素,則行為是未定義的。 引數 indices (tuple of LongTensor) – 用於對 self 進行索引的張量。 values (Tensor) – 與 self 具有相同 dtype 的張量。 accumulate (bool) – 是否累加到 self 中