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.]])