【PyTorch】Pytorch踩坑记

pytorch踩坑记


错误1:UserWarning: To copy construct from a tensor, it is recommended to use sourceTensor.clone().detach() or sourceTensor.clone().detach().requires_grad_(True), rather than torch.tensor(sourceTensor).

copy
# bug : feature = torch.tensor(torch.from_numpy(feature), dtype=torch.float32) # debug : # 改为: feature = torch.as_tensor(torch.from_numpy(feature), dtype=torch.float32)

错误2:RuntimeError: Expected object of scalar type Float but got scalar type Double for argument #2 ‘mat1’ in call to _th_addmm

copy
# debug : feature = torch.as_tensor(torch.from_numpy(feature), dtype=torch.float32)

错误3:UserWarning: Using a target size (torch.Size([64])) that is different to the input size (torch.Size([64,1]))

copy
# debug : # 在forward(self, x)函数体中,在return x之前,加一句 x = x.squeeze(-1)
posted @   梁君牧  阅读(4658)  评论(0编辑  收藏  举报
点击右上角即可分享
微信分享提示
🚀