import numpy as np
import torch
x = torch.Tensor(2, 2, 2)
y = x.view(1, 8) #输出维度:1*8
z = x.view(-1, 4) # -1表示维数自动判断,此输出的维度为:2*4
t = x.view(8) #输出维度 : 8*1
t = x.view(-1) #输出维度: 1*8
torch中tensor的view函数
最新推荐文章于 2024-07-01 15:18:45 发布