philtabor / Youtube-Code-Repository

Repository for most of the code from my YouTube channel
859 stars 479 forks source link

Error in Store_transition in pytorch dqns #54

Open Vis03al opened 1 year ago

Vis03al commented 1 year ago

In "main_torch_dqn_lunar_lander_2020.py" file

--> self.state_memory[index] = state It says "ValueError: setting an array element with a sequence. The requested array would exceed the maximum number of dimension of 1"

When i alter few things to get rid off this error i am getting into another error ,could you help me out

alvynabranches commented 1 year ago

Traceback (most recent call last): File "/home/alvynabranches/aichess/lunar_lander.py", line 32, in agent.storetransition(observation, action, reward, observation, int(done)) File "/home/../aichess/engines/dddqn.py", line 111, in store_transition self.memory.storetransition(state, action, reward, state, done) File "/home/../aichess/engines/dddqn.py", line 22, in store_transition self.state_memory[index] = state ValueError: setting an array element with a sequence. The requested array would exceed the maximum number of dimension of 1.

alvynabranches commented 1 year ago

Same error for DQN as well as DDQN

philtabor commented 1 year ago

which version of gym are you using?

dawmro commented 3 months ago

Find your env.reset() and change it to: env.reset()[0]

Why? Look here:

(method) def reset(
    *,
    seed: int | None = None,
    options: dict[str, Any] | None = None
) -> tuple[Any, dict[str, Any]]

Another thing: If you are using gymnasium instead of gym, remember that done has been replaced with terminated, truncated. Addjust your functions accordingly.