philtabor / Youtube-Code-Repository

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

Error when I changed dueling_ddqn_torch.py to get multiple dicrete actions #50

Closed Nazanin-87 closed 2 years ago

Nazanin-87 commented 2 years ago

I want to implement a dueling double DQN algorithm for selecting multiple discrete actions. Since the existing dueling_ddqn_torch.py code is for choosing a single action, I should modify it. But when I changed the choose_action function of Agent to get multiple actions, I got the following error: IndexError: tensors used as indices must be long, byte or bool tensors The complement explanation of the error is Traceback (most recent call last): File "C:/Users/Desktop/D3QN.py", line 339, in <module> agent.learn() File "C:/Users/Desktop/D3QN.py", line 157, in learn q_pred = T.add(Vs, (As - As.mean(dim=1, keepdim=True)))[indices, actions] IndexError: tensors used as indices must be long, byte or bool tensors The whole code is attached. dueling_ddqn_torch.zip I would be grateful if anyone helps me to solve this error.

philtabor commented 2 years ago

Please provide a link to a github, I'm not going to open a random zip file.

Nazanin-87 commented 2 years ago

Please provide a link to a github, I'm not going to open a random zip file. Thanks. https://github.com/Nazanin-87/D3QN/blob/main/D3QN.py

Nazanin-87 commented 2 years ago

The issue is solved.