I convert the tensor to Double() after complaint (below) during loss calc but when I print tensor.type() it shows TensorDouble but when I print the content, at the end of list, it still shows dtype=float32.
What are the difference, why is it showing to different? Thanks.,
targets: <class 'torch.Tensor'> 64 torch.DoubleTensor
tensor([1.6250, 3.2660, 1.2980, 2.1920, 0.9170, 1.0800, 1.2320, 2.3020, 1.9490,
1.7990, 3.1560, 1.6250, 1.0340, 2.4040, 1.4870, 0.9850, 1.6060, 3.2130,
1.4580, 3.2660, 0.9850, 3.6350, 2.2090, 2.7360, 2.6490, 1.6340, 0.9060,
0.9910, 1.1500, 2.8080, 2.2500, 0.6720, 5.0000, 2.6900, 1.4320, 0.7190,
2.7820, 0.9790, 1.1320, 1.6310, 3.4060, 1.7070, 1.4060, 3.3280, 2.3270,
0.9890, 2.6280, 2.3740, 2.6700, 1.1440, 1.1790, 1.4100, 2.4890, 2.3730,
1.1880, 3.8380, 1.1360, 2.5190, 1.4910, 2.2220, 3.0420, 0.7370, 2.2430,
1.3810], dtype=torch.float64)
inputs: <class 'torch.Tensor'> torch.Size([64, 8])
targets: <class 'torch.Tensor'> torch.Size([64])
Traceback (most recent call last):
File "p308.py", line 224, in <module>
train_model(train_dl, model)
File "p308.py", line 164, in train_model
yhat = model(inputs[1])
File "/usr/local/lib/python3.6/dist-packages/torch/nn/modules/module.py", line 1051, in _call_impl
return forward_call(*input, **kwargs)
File "p308.py", line 104, in forward
X = self.hidden1(X.double()).double()
File "/usr/local/lib/python3.6/dist-packages/torch/nn/modules/module.py", line 1051, in _call_impl
return forward_call(*input, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/torch/nn/modules/linear.py", line 96, in forward
return F.linear(input, self.weight, self.bias)
File "/usr/local/lib/python3.6/dist-packages/torch/nn/functional.py", line 1847, in linear
return torch._C._nn.linear(input, weight, bias)
RuntimeError: expected scalar type Double but found Float