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

fix qvalue mask_action error for obs_next #310

Merged
merged 4 commits into from
Mar 15, 2021

Conversation

Trinkle23897
Copy link
Collaborator

@Trinkle23897 Trinkle23897 commented Mar 14, 2021

No description provided.

@Trinkle23897 Trinkle23897 requested a review from danagi March 14, 2021 09:58
@codecov-io
Copy link

codecov-io commented Mar 14, 2021

Codecov Report

Merging #310 (dc3833f) into master (243ab43) will decrease coverage by 0.03%.
The diff coverage is 91.66%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #310      +/-   ##
==========================================
- Coverage   93.94%   93.91%   -0.04%     
==========================================
  Files          51       51              
  Lines        3270     3270              
==========================================
- Hits         3072     3071       -1     
- Misses        198      199       +1     
Flag Coverage Δ
unittests 93.91% <91.66%> (-0.04%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
tianshou/env/venvs.py 90.71% <0.00%> (-0.72%) ⬇️
tianshou/policy/modelfree/dqn.py 98.78% <93.75%> (ø)
tianshou/policy/modelfree/c51.py 93.61% <100.00%> (ø)
tianshou/policy/modelfree/qrdqn.py 93.18% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 243ab43...dc3833f. Read the comment docs.

Copy link
Collaborator

@danagi danagi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the problem in #309 is caused by the function _target_q which uses unmasked logits to get target max q values in dqn.py. Since self(...).act is the legal max q value action, my personal suggestion is as follow:

model = 'model_old' if self._target else 'model'
result = self(batch, model=model, input='obs_next')
a = result.act
target_q = result.logits[np.arange(len(a)), a]

@Trinkle23897 Trinkle23897 merged commit ec23c7e into thu-ml:master Mar 15, 2021
@Trinkle23897 Trinkle23897 deleted the qvalue-mask-obsnext branch March 15, 2021 00:06
BFAnas pushed a commit to BFAnas/tianshou that referenced this pull request May 5, 2024
* fix thu-ml#309
* remove for-loop in dqn expl_noise
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

Successfully merging this pull request may close these issues.

3 participants