我有一个这样的Tensor
tensor([[4.],[1.]], device='cuda:0')
我想更改为以下内容:
tensor([4.,1.], device='cuda:0')
如何做到这一点?我不确定这是否是错误的原因:
loss = nn.MSELoss(y_tilde,y) RuntimeError: Boolean value of Tensor with more than one value is ambiguous
ycl3bljg1#
使用
torch.flatten()
示例:
t = torch.tensor([[[1, 2], [3, 4]], [[5, 6], [7, 8]]]) out: tensor([[[1, 2], [3, 4]], [[5, 6], [7, 8]]]) torch.flatten(t) out: tensor([1, 2, 3, 4, 5, 6, 7, 8])
1条答案
按热度按时间ycl3bljg1#
使用
示例: