pytorch踩坑记
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)
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)
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)