linnaeushuang / pensieve-pytorch

MIT License
27 stars 10 forks source link

RuntimeError: Found dtype Double but expected Float #10

Open balasubramanian1612s opened 2 years ago

balasubramanian1612s commented 2 years ago

### I run the Command: python3 pensieve_torch.py --model_type=1

File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/multiprocessing/process.py", line 315, in _bootstrap self.run() File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/multiprocessing/process.py", line 108, in run self._target(*self._args, **self._kwargs)

File "/Users/Balasubramanian/Downloads/pensieve-pytorch-master/pensieve_torch.py", line 137, in central_agent net.getNetworkGradient(s_batch,a_batch,r_batch,terminal=terminal)

File "/Users/Balasubramanian/Downloads/pensieve-pytorch-master/A3C.py", line 80, in getNetworkGradient critic_loss.backward() File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/torch/_tensor.py", line 255, in backward torch.autograd.backward(self, gradient, retain_graph, create_graph, inputs=inputs) File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/torch/autograd/init.py", line 147, in backward Variable._execution_engine.run_backward( RuntimeError: Found dtype Double but expected Float

### This is my error, Couldn't figure out what is the problem. Please help me out.

linnaeushuang commented 2 years ago

Sorry for the late reply. If you use my dependencies, you won't get any error. I guess your error is caused by version of torch (or numpy). Probably in your version, torch uses "Double" as its default dtype. One of the solutions is follows:

self.actorNetwork=ActorNetwork(self.s_dim,self.a_dim).double().to(self.device)

Fix model precision as double precision in A3C.py