Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error Running Train.py #6

Open
mitchross opened this issue Jun 25, 2019 · 4 comments
Open

Error Running Train.py #6

mitchross opened this issue Jun 25, 2019 · 4 comments

Comments

@mitchross
Copy link

Flappy-bird-deep-Q-learning-pytorch/src/deep_q_network.py:21: UserWarning: nn.init.uniform is now deprecated in favor of nn.init.uniform_.
nn.init.uniform(m.weight, -0.01, 0.01)
Perform a random action
Iteration: 2/2000000, Action: 1, Loss: 0.010123813524842262, Epsilon 0.1, Reward: 0.1, Q-value: 0.0005683371564373374
Traceback (most recent call last):
File "train.py", line 133, in
train(opt)
File "train.py", line 74, in train
action = torch.argmax(prediction)[0]
IndexError: invalid index of a 0-dim tensor. Use tensor.item() to convert a 0-dim tensor to a Python number
(python36) bash-3.2$

@2448845600
Copy link

I meet the question so. It cause bytorch version. In latest torch, 0-dim tensor is invaild,
我也遇到这问题,是torch版本引起的,稍作修改即可。

Change code line77

action = torch.argmax(prediction)[0]

To

action = torch.argmax(prediction)

@mitchross
Copy link
Author

I tried that. Still errors

(python36) C:\Flappy-bird-deep-Q-learning-pytorch>python train.py
Traceback (most recent call last):
File "train.py", line 15, in
from src.flappy_bird import FlappyBird
File "C:***\Flappy-bird-deep-Q-learning-pytorch\src\flappy_bird.py", line 6, in
from pygame import Rect, init, time, display
File "C:\Users****\lib\site-packages\pygame_init_.py", line 120, in
from pygame.base import *
ModuleNotFoundError: No module named 'pygame.base'

@Jarvis-Cai
Copy link

@2448845600 thanks, guy! fix my problem.

@xueliu8617112
Copy link

@2448845600 谢谢~搞定啦

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants