捷徑

torch.broadcast_to

torch.broadcast_to(input, shape) Tensor

input 廣播 (broadcast) 到 shape 的形狀。等同於呼叫 input.expand(shape)。詳細資訊請參閱 expand()

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

  • shape (list, tuple, 或 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 的完整開發者文件

檢視文件

教學課程

取得適合初學者和進階開發者的深入教學課程

檢視教學課程

資源

尋找開發資源並獲得問題解答

檢視資源