快捷方式

torch.Tensor.put_

Tensor.put_(index, source, accumulate=False) Tensor

將源張量 (source) 中的元素複製到由索引 (index) 指定的位置。為了索引方便,self 張量被視為一維張量處理。

indexsource 需要包含相同數量的元素,但不一定具有相同的形狀。

如果 accumulateTrue,源張量 (source) 中的元素將累加到 self 中。如果 accumulate 為 False,並且 index 包含重複元素,則行為未定義。

引數
  • index (LongTensor) – self 中的索引

  • source (Tensor) – 包含要複製的值的張量

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

示例

>>> src = torch.tensor([[4, 3, 5],
...                     [6, 7, 8]])
>>> src.put_(torch.tensor([1, 3]), torch.tensor([9, 10]))
tensor([[  4,   9,   5],
        [ 10,   7,   8]])

文件

查閱 PyTorch 的全面開發者文件

檢視文件

教程

獲取面向初學者和高階開發者的深度教程

檢視教程

資源

查詢開發資源並獲得問題解答

檢視資源