Youtube-Code-Repository icon indicating copy to clipboard operation
Youtube-Code-Repository copied to clipboard

Error in Store_transition in pytorch dqns

Open Vis03al opened this issue 3 years ago • 4 comments

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

Vis03al avatar Jan 11 '23 07:01 Vis03al

Traceback (most recent call last): File "/home/alvynabranches/aichess/lunar_lander.py", line 32, in agent.store_transition(observation, action, reward, observation_, int(done)) File "/home/../aichess/engines/dddqn.py", line 111, in store_transition self.memory.store_transition(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 avatar Feb 22 '23 18:02 alvynabranches

Same error for DQN as well as DDQN

alvynabranches avatar Feb 22 '23 19:02 alvynabranches

which version of gym are you using?

philtabor avatar Feb 22 '23 19:02 philtabor

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.

dawmro avatar May 25 '24 23:05 dawmro