pytorch 的 reshape((-1, 1)) 是什么意思?

pytorch 的 reshape((-1, 1)) 是什么意思

代码

import torch

print(torch.tensor([1,2,3,4,5,6,7,8]).reshape(-1,1)) 
tensor([[1],
        [2],
        [3],
        [4],
        [5],
        [6],
        [7],
        [8]])

示意图

image

posted @ 2025-12-30 10:31  fanbal  阅读(5)  评论(0)    收藏  举报