捷徑

torch.hstack

torch.hstack(tensors, *, out=None) Tensor

將 tensors 依序水平堆疊 (column wise)。

對於 1-D tensors,這等同於沿著第一個軸 (axis) 串聯 (concatenation);對於所有其他 tensors,則等同於沿著第二個軸串聯。

參數 (Parameters)

tensors (Tensors 的序列) – 要串聯的 tensors 序列

關鍵字參數 (Keyword Arguments)

out (Tensor, optional) – 輸出 tensor (可選)。

範例 (Example)

>>> a = torch.tensor([1, 2, 3])
>>> b = torch.tensor([4, 5, 6])
>>> torch.hstack((a,b))
tensor([1, 2, 3, 4, 5, 6])
>>> a = torch.tensor([[1],[2],[3]])
>>> b = torch.tensor([[4],[5],[6]])
>>> torch.hstack((a,b))
tensor([[1, 4],
        [2, 5],
        [3, 6]])

文件

取得 PyTorch 的完整開發者文件

檢視文件 (View Docs)

教學 (Tutorials)

取得針對初學者和進階開發者的深入教學

檢視教學 (View Tutorials)

資源 (Resources)

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

檢視資源 (View Resources)