torch.stack
stack方法可以沿新维度连接张量序列
out = [tensor([0.7008]), tensor([0.1135]), tensor([0.4927])] torch.stack(out, 0) >> tensor([[0.7008], [0.1135], [0.4927]]) torch.stack(out, 1) >> tensor([[0.7008, 0.1135, 0.4927]])
快去成为你想要的样子!
stack方法可以沿新维度连接张量序列
out = [tensor([0.7008]), tensor([0.1135]), tensor([0.4927])] torch.stack(out, 0) >> tensor([[0.7008], [0.1135], [0.4927]]) torch.stack(out, 1) >> tensor([[0.7008, 0.1135, 0.4927]])