快捷方式

torch.broadcast_to

torch.broadcast_to(input, shape) Tensor

input 廣播到指定的 shape 形狀。等同於呼叫 input.expand(shape)。詳情請參閱 expand()

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

  • shape (list, tuple, or torch.Size) – 新的形狀。

示例

>>> x = torch.tensor([1, 2, 3])
>>> torch.broadcast_to(x, (3, 3))
tensor([[1, 2, 3],
        [1, 2, 3],
        [1, 2, 3]])

文件

查閱 PyTorch 的完整開發者文件

檢視文件

教程

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

檢視教程

資源

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

檢視資源