import torch
A = torch.ones(2,3)
B = torch.ones(2,3)*2
print('A:',A)
print('A:',A.shape)
print('----------------------')
print('B:',B)
print('B:',B.shape)
print('-----------------------')
C = torch.cat((A, B)) #默认dim=0
print('C:',C)
print('C:',C.shape)
print('_______________________')
D = torch.cat((A, B), dim=1)
print('D:',D)
print('D:',D.shape)

torch.cat() python

清晰可见:dim=0按行拼接, dim=1按列拼接。

相关文章:

  • 2022-01-07
  • 2021-09-26
  • 2023-03-12
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-10-25
  • 2022-12-23
  • 2021-08-03
  • 2022-01-11
  • 2021-06-10
  • 2023-03-12
相关资源
相似解决方案