Skip to content

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