print(link_od)
print(link_od.shape)
print(etaODAVG)
print(etaODAVG.shape)
x_lstm = torch.cat([x_link_od,
etaODAVG],
-1)
print(x_lstm)
tensor([[187975, 55639],
[ 82492, 25441],
[ 82492, 25441]])
torch.Size([3, 2])
tensor([[-0.4727],
[-0.2943],
[-0.2943]])
torch.Size([3, 1])
RuntimeError: Tensors must have same number of dimensions: got 3 and 2
请问怎样才能让torch.cat成功运行,将第二个tensor按行拼接到第一个tensor后面。
你这只能按列拼接,按行拼接link_od两列数据,etaODAVG一列数据肯定不行啊
x_lstm = torch.cat((link_od,etaODAVG),1),#按列拼接
tensor([[ 1.8798e+05, 5.5639e+04, -4.7270e-01],
[ 8.2492e+04, 2.5441e+04, -2.9430e-01],
[ 8.2492e+04, 2.5441e+04, -2.9430e-01]])