CHH3213 / Note-Ubuntu_CHH3213

ubuntu系统CHH3213上做的笔记
0 stars 0 forks source link

71. torch.stack #71

Open CHH3213 opened 2 years ago

CHH3213 commented 2 years ago

函数作用: 函数stack()对序列数据内部的张量进行扩维拼接,指定维度由程序员选择、大小是生成后数据的维度区间。

print(torch.stack((T1,T2),dim=0).shape) print(torch.stack((T1,T2),dim=1).shape) print(torch.stack((T1,T2),dim=2).shape)

输出为:

torch.Size([2, 3, 3]) torch.Size([3, 2, 3]) torch.Size([3, 3, 2])