在某个索引处连接火炬张量

时间:2021-04-13 18:16:35

标签: python-3.x concatenation torch

我希望在某个索引处连接 2 个火炬张量。例如,我想在 a[1] 之后添加 b。

a = torch.Tensor([1, 2, 3, 4, 5])
b = torch.Tensor([6, 7, 8, 9, 10])

所需的输出是

torch.Tensor([1, 2, 6, 7, 8, 9, 10, 3, 4, 5])

我试过torch.cat,但我只能有

tensor([ 6.,  7.,  8.,  9., 10.,  1.,  2.,  3.,  4.,  5.])
tensor([ 1.,  2.,  3.,  4.,  5.,  6.,  7.,  8.,  9., 10.])

0 个答案:

没有答案