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

bugfix: TypeError when adding a batch dimension #15

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

rieuky
Copy link

@rieuky rieuky commented Nov 2, 2022

Error Message

File "dqn.py", line 69, in get_action
state = state[np.newaxis, :]
TypeError: tuple indices must be integers or slices, not tuple

Solution

According to the OpenAI Gym source codes, env.reset() seems to return two data (in tuple).
So I added an underscore to successfully unpack the tuple.
I have applied the similar modification to env.step().

Environments

  • Ubuntu 20.04
  • Python 3.8.10
  • OpenAI Gym 0.26.2

@rieuky rieuky marked this pull request as ready for review November 2, 2022 23:22
@Aprilistic
Copy link

Or you can fix this problem by changing
state = env.reset() -> state = env.reset()[0]

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

Successfully merging this pull request may close these issues.

2 participants