这是indexloc提供的服务,不要输入任何密码
Skip to content

Add discrete Critic Regularized Regression #367

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

Merged
merged 8 commits into from
May 19, 2021

Conversation

nuance1979
Copy link
Collaborator

  • Add discrete Critic Regularized Regression
  • Reference: paper and code
  • Note that CRR itself does not seem to work well on Atari tasks but adding CQL loss/regularizer helps.

@codecov-commenter
Copy link

codecov-commenter commented May 14, 2021

Codecov Report

Merging #367 (29e7cae) into master (b5c3dda) will decrease coverage by 0.01%.
The diff coverage is 93.54%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #367      +/-   ##
==========================================
- Coverage   94.55%   94.53%   -0.02%     
==========================================
  Files          54       55       +1     
  Lines        3505     3567      +62     
==========================================
+ Hits         3314     3372      +58     
- Misses        191      195       +4     
Flag Coverage Δ
unittests 94.53% <93.54%> (-0.02%) ⬇️

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

Impacted Files Coverage Δ
tianshou/policy/imitation/discrete_crr.py 93.44% <93.44%> (ø)
tianshou/policy/__init__.py 100.00% <100.00%> (ø)
tianshou/data/collector.py 94.93% <0.00%> (-0.43%) ⬇️
tianshou/policy/modelfree/pg.py 98.21% <0.00%> (+1.78%) ⬆️

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 b5c3dda...29e7cae. Read the comment docs.

Yi Su and others added 2 commits May 15, 2021 06:53
@nuance1979
Copy link
Collaborator Author

FYI, I tried a variant of CRR where I replaced the DQN critic with a QRDQN (num_quantiles=200). It was slightly better but not much: For Breakout, after 40 iterations, I got 161.4 for QRCRR vs 137.2 for CRR; for Pong, after 40 iterations, I got 18.5 for QRCRR vs 16.8 for CRR.

Copy link
Collaborator

@Trinkle23897 Trinkle23897 left a comment

Choose a reason for hiding this comment

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

Have you ever considered inheriting from QRDQN or DiscreteCQL instead of PG? Because the only reused part is forward and it is really simple (just a few line, just discrete, no other cases in PGPolicy) -- and maybe that would be more concise?

@nuance1979
Copy link
Collaborator Author

Have you ever considered inheriting from QRDQN or DiscreteCQL instead of PG? Because the only reused part is forward and it is really simple (just a few line, just discrete, no other cases in PGPolicy) -- and maybe that would be more concise?

Yes, I have. But after some thought, I chose to inherit from PGPolicy to emphasize the fact that CRR is a policy gradient model, i.e., the critic, be it DQN, QRDQN or else, is only a by-product of the training process and does NOT contribute to the evaluation of the policy. I also thought about multiple inheritance, i.e., let CRR inherits from both PGPolicy and DQN or QRDQN or DiscreteCQL but I realized that it would not make the implementation simpler. For example, because none of them has a self.actor_old model, I still need to override the def sync_weight() method in order to synchronize the target actor model.

The only place I can think of improving is to refactor the def learn() method of the parent class in order to share some code. But even if I do that, that's only going to save me <10 lines of code at the expense of fragmenting the logic of def learn() function.

Anyway that's just my opinion. I can certainly change it if you insist.

@Trinkle23897 Trinkle23897 merged commit 8f7bc65 into thu-ml:master May 19, 2021
@Trinkle23897 Trinkle23897 linked an issue May 19, 2021 that may be closed by this pull request
8 tasks
@nuance1979 nuance1979 deleted the crr branch October 6, 2021 17:28
BFAnas pushed a commit to BFAnas/tianshou that referenced this pull request May 5, 2024
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.

Critic Regularized Regression (CRR) for offline/batch reinforcement learning
3 participants