torch.broadcast_tensors¶
- torch.broadcast_tensors(*tensors) List of Tensors [原始碼][原始碼]¶
根據廣播語意廣播給定的張量。
- 參數
*tensors – 任意數量的相同類型的張量
警告
廣播張量的多個元素可能指向單個記憶體位置。 因此,原地運算(尤其是向量化的運算)可能會導致不正確的行為。 如果需要寫入張量,請先複製它們。
範例
>>> x = torch.arange(3).view(1, 3) >>> y = torch.arange(2).view(2, 1) >>> a, b = torch.broadcast_tensors(x, y) >>> a.size() torch.Size([2, 3]) >>> a tensor([[0, 1, 2], [0, 1, 2]])