错误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).

# 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

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

# debug :
# 在forward(self, x)函数体中,在return x之前,加一句
x = x.squeeze(-1)

相关文章:

  • 2021-03-31
  • 2021-12-22
  • 2021-12-28
  • 2021-08-22
  • 2021-12-25
  • 2021-09-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-05-31
  • 2022-12-23
  • 2021-12-12
  • 2022-12-23
  • 2021-07-27
  • 2021-04-20
相关资源
相似解决方案