总结,发现了两种解决方法。
大佬1
解释的很详细了,
tensor.to(torch.float32) 但其实这里面的tensor指的是tensor类型的数据
在你自己的代码上他可能是x可能是data 这个要你自己多尝试
我的代码例子:
bow=[[1,0,1,1,1,0,0],[1,1,1,0,0,0,1],[0,1,1,0,0,1,0]]
enc_1=torch.nn.Linear(7, 10)
en1=torch.relu(enc_1(bow))
#原本我的转变方式:(float32->64)
Bow=torch.Tensor(bow,dtype=float64)
#我猜)实际上应该写成
Bow2=torch.Tensor(bow)
Bow2.data=Bow2.data.to(torch.float64)
看到很多次了,在最前面 加这一行代码
torch.set_default_tensor_type(torch.DoubleTensor)
如果是
Bow=torch.Tensor(bow,dtype=float64)这种形式
+
torch.set_default_tensor_type(torch.DoubleTensor)
,反正我的代码是能跑的…