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]])

 

posted on 2019-01-24 10:11  那抹阳光1994  阅读(698)  评论(0编辑  收藏  举报

导航