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

Array has inhomogeneous shape when trying to run the pettingzoo example #274

Open
Sisyphus192 opened this issue Jan 10, 2023 · 7 comments
Open

Comments

@Sisyphus192
Copy link

Trying to run run_rl.py pettingzoo example and I get the following error:

poetry run python examples/run_rl.py --cuda 0
--> Running on the GPU

----------------------------------------
  timestep     |  0
  reward       |  3.8675
----------------------------------------

Logs saved in experiments/leduc_holdem_dqn_result/
Traceback (most recent call last):
  File "rlcard/examples/run_rl.py", line 162, in <module>
    train(args)
  File "rlcard/examples/run_rl.py", line 85, in train
    agent.feed(ts)
  File "rlcard/.venv/lib/python3.9/site-packages/rlcard/agents/pettingzoo_agents.py", line 34, in feed
    return super().feed(ts)
  File "rlcard/.venv/lib/python3.9/site-packages/rlcard/agents/dqn_agent.py", line 131, in feed
    self.train()
  File "rlcard/.venv/lib/python3.9/site-packages/rlcard/agents/dqn_agent.py", line 194, in train
    state_batch, action_batch, reward_batch, next_state_batch, legal_actions_batch, done_batch = self.memory.sample()
ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape was (32,) + inhomogeneous part.
@Sisyphus192
Copy link
Author

Ok, after some more testing this appears to be an issue with python 3.9+
The run_rl.py works fine on python 3.8, with latest versions of rl_card + pettingzoo

I had originally tested several combinations of versions of rl_card + pettingzoo in python 3.9, 3.10, and 3.11.

I don't know if this is a rl_card + pettingzoo compatibility issue with python 3.9+ or is coming from some changed behavior in torch in python 3.9+.

@daochenzha
Copy link
Member

@Sisyphus192 Thanks for posting this. The update of Numpy causes this. I have just fixed the issue in the master branch. The PyPi version will also be updated soon.

@Walhalla-Summary
Copy link

Hello, how to solve this problem when running code?

question:
File "D:\lq_rlcard\rlcards\agents\dqn_agent.py", line 422, in sample
return tuple(map(np.array, samples[:-1])) + (samples[-1],)
ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape was (32,) + inhomogeneous part.

@daochenzha
Copy link
Member

@Walhalla-Summary Could you provide more details about how to reproduce the results?

@Sisyphus192
Copy link
Author

@Walhalla-Summary What version of rlcard and numpy are you using?

@Walhalla-Summary
Copy link

@Sisyphus192 I use the latest version of rlcard, numpy=1.24, and Python version is 3.10

@Sisyphus192
Copy link
Author

I can't replicate this with rlcard's dqn_agent on python 3.10 and numpy 1.24. I suspect the issue lies with your changes to the dqn_agent, can you provide more details about how to reproduce this error?

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

3 participants