快捷方式

torch.select_scatter

torch.select_scatter(input, src, dim, index) Tensor

src 張量的值嵌入到 input 張量中給定索引處。此函式返回一個具有新儲存的張量;它不建立檢視。

引數
  • input (Tensor) – 輸入張量。

  • src (Tensor) – 要嵌入到 input 中的張量。

  • dim (int) – 要插入切片的維度。

  • index (int) – 要選擇的索引。

注意

src 必須具有適當的大小才能嵌入到 input 中。具體而言,它應具有與 torch.select(input, dim, index) 相同的形狀。

示例

>>> a = torch.zeros(2, 2)
>>> b = torch.ones(2)
>>> a.select_scatter(b, 0, 0)
tensor([[1., 1.],
        [0., 0.]])

文件

查閱 PyTorch 的全面開發者文件

檢視文件

教程

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

檢視教程

資源

查詢開發資源並解答疑問

檢視資源