lambders / drl-experiments

Training a DRL agent to play Flappy Bird. An exercise to reimplement DQN, A2C, and PPO DRL methods.
4 stars 4 forks source link

RuntimeError: Input type (torch.FloatTensor) and weight type (torch.cuda.FloatTensor) should be the same #1

Open bowlderstudio opened 4 years ago

bowlderstudio commented 4 years ago

Could you tell me the version of your pytorch. I got runtime error: python main.py --algo=ppo --mode=train pygame 1.9.6 Hello from the pygame community. https://www.pygame.org/contribute.html /workdata/git/drl-experiments/ppo.py:54: UserWarning: nn.init.uniform is now deprecated in favor of nn.init.uniform_. torch.nn.init.uniform(m.weight, -0.01, 0.01) libpng warning: iCCP: known incorrect sRGB profile libpng warning: iCCP: known incorrect sRGB profile libpng warning: iCCP: known incorrect sRGB profile libpng warning: iCCP: known incorrect sRGB profile libpng warning: iCCP: known incorrect sRGB profile libpng warning: iCCP: known incorrect sRGB profile libpng warning: iCCP: cHRM chunk does not match sRGB libpng warning: iCCP: known incorrect sRGB profile libpng warning: iCCP: known incorrect sRGB profile libpng warning: iCCP: known incorrect sRGB profile libpng warning: iCCP: known incorrect sRGB profile libpng warning: iCCP: known incorrect sRGB profile libpng warning: iCCP: known incorrect sRGB profile libpng warning: iCCP: known incorrect sRGB profile libpng warning: iCCP: known incorrect sRGB profile libpng warning: iCCP: known incorrect sRGB profile Traceback (most recent call last): File "main.py", line 133, in agent.train() File "/workdata/git/drl-experiments/ppo.py", line 241, in train values, actions, action_log_probs = self.net.act(states) File "/workdata/git/drl-experiments/ppo.py", line 87, in act values, action_logits = self.forward(x) File "/workdata/git/drl-experiments/ppo.py", line 72, in forward x = self.relu1(self.conv1(x)) File "/home/minshi/.virtualenvs/drl-experiments-0ZyJdSJ6/lib/python3.6/site-packages/torch/nn/modules/module.py", line 532, in call result = self.forward(*input, **kwargs) File "/home/minshi/.virtualenvs/drl-experiments-0ZyJdSJ6/lib/python3.6/site-packages/torch/nn/modules/conv.py", line 345, in forward return self.conv2d_forward(input, self.weight) File "/home/minshi/.virtualenvs/drl-experiments-0ZyJdSJ6/lib/python3.6/site-packages/torch/nn/modules/conv.py", line 342, in conv2d_forward self.padding, self.dilation, self.groups) RuntimeError: Input type (torch.FloatTensor) and weight type (torch.cuda.FloatTensor) should be the same

bowlderstudio commented 4 years ago

I debug the problem. It seems the input of your network is a status which the dimension is only (4, 16, 8, 4) which only presents status, however the status return by the game and suppose to input into your model is (8, 4, 84, 84), which looks like image. So I guess maybe the game package I installed in different from yours.