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

Wrong target value in DDQN implementation #21

Open
xuziye0327 opened this issue Dec 17, 2024 · 0 comments
Open

Wrong target value in DDQN implementation #21

xuziye0327 opened this issue Dec 17, 2024 · 0 comments

Comments

@xuziye0327
Copy link

Hi!

Current implementation of target value in DDQN should be wrong. It is the target value of DQN actually.

https://github.com/MaximeVandegar/Papers-in-100-Lines-of-Code/blob/a518f16cfcba84b774fcbfe136a9f439ce94c231/Deep_Reinforcement_Learning_with_Double_Q_learning/ddqn.py#L88C21-L88C94

DQN:
截屏2024-12-17 21 13 44

In DDQN, we should use argmax(u) of online network:
截屏2024-12-17 21 17 06

    # DDQN
    with torch.no_grad():
        next_q_values = target_q_net(next_state)
        double_q = q_net(next_state).argmax(dim=1)
        next_q_values = next_q_values.gather(1, double_q.unsqueeze(1)).squeeze(1)
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

1 participant