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

[Algorithm] Td3 #684

Merged
merged 37 commits into from
Jan 17, 2023
Merged

[Algorithm] Td3 #684

merged 37 commits into from
Jan 17, 2023

Conversation

BY571
Copy link
Contributor

@BY571 BY571 commented Nov 17, 2022

Description

Adding Twin Delayed Deep Deterministic Policy Gradient (TD3) algorithm.
Creating:

  • Example script
  • Adding TD3Loss objective class
  • Adding make_td3_loss helper function
  • Adding make_td3_actor helper function
  • Creating TD3Model data class
  • Adapting the AdditiveGaussianWrapper to accept mean and std for the normal distribution
  • Adding TD3MlpQNet Model
  • Tested algorithm for convergence

Performance looks good at the beginning of the training but becomes very unstable at the end. Did try some other parameter settings but could not resolve the instabilities until now.
image

Motivation and Context

This PR closes an open issue: close #18.

  • I have raised an issue to propose this change (required for new features and bug fixes)

Types of changes

What types of changes does your code introduce? Remove all that do not apply:

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds core functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation (update in the documentation)
  • Example (update in the folder of examples)

Checklist

Go over all the following points, and put an x in all the boxes that apply.
If you are unsure about any of these, don't hesitate to ask. We are here to help!

  • I have read the CONTRIBUTION guide (required)
  • My change requires a change to the documentation.
  • I have updated the tests accordingly (required for a bug fix or a new feature).
  • I have updated the documentation accordingly.

@facebook-github-bot
Copy link

Hi @BY571!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at [email protected]. Thanks!

@vmoens vmoens added the new algo New algorithm request or PR label Nov 18, 2022
@vmoens vmoens changed the title Td3 [Algorithm] Td3 Nov 18, 2022
@facebook-github-bot
Copy link

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Nov 18, 2022
@vmoens
Copy link
Contributor

vmoens commented Nov 22, 2022

For the formatting, refer to instructions :)

Copy link
Contributor

@vmoens vmoens 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 you have committed a log file :)
Let me know if there's anything i can do to help -- I can do a review even if the code is still a draft if you'd like

@BY571
Copy link
Contributor Author

BY571 commented Nov 24, 2022

I think you have committed a log file :) Let me know if there's anything i can do to help -- I can do a review even if the code is still a draft if you'd like

Sure, you can review it already! Just trying to fix the last formatting issue.

@codecov
Copy link

codecov bot commented Nov 24, 2022

Codecov Report

Merging #684 (5d1b995) into main (37da520) will increase coverage by 3.68%.
The diff coverage is 96.51%.

@@            Coverage Diff             @@
##             main     #684      +/-   ##
==========================================
+ Coverage   85.15%   88.83%   +3.68%     
==========================================
  Files         123      124       +1     
  Lines       21167    21364     +197     
==========================================
+ Hits        18024    18978     +954     
+ Misses       3143     2386     -757     
Flag Coverage Δ
habitat-gpu 24.74% <20.83%> (-0.02%) ⬇️
linux-brax 29.31% <20.83%> (-0.05%) ⬇️
linux-cpu 85.32% <95.02%> (?)
linux-gpu 86.30% <96.51%> (+61.43%) ⬆️
linux-jumanji 30.08% <20.83%> (-0.06%) ⬇️
linux-outdeps-gpu 72.47% <95.02%> (+0.21%) ⬆️
linux-stable-cpu 85.18% <95.02%> (?)
linux-stable-gpu 85.95% <95.02%> (?)
linux_examples-gpu 42.59% <25.00%> (-0.11%) ⬇️
macos-cpu 85.08% <95.02%> (?)
olddeps-gpu 75.49% <20.39%> (-0.54%) ⬇️

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

Impacted Files Coverage Δ
torchrl/objectives/utils.py 83.44% <ø> (ø)
torchrl/modules/tensordict_module/exploration.py 77.77% <83.33%> (+0.31%) ⬆️
test/test_cost.py 96.32% <96.89%> (+0.11%) ⬆️
torchrl/objectives/td3.py 96.92% <96.92%> (ø)
torchrl/objectives/__init__.py 100.00% <100.00%> (ø)
torchrl/envs/common.py 83.12% <0.00%> (+0.25%) ⬆️
torchrl/modules/distributions/continuous.py 85.65% <0.00%> (+0.39%) ⬆️
torchrl/data/tensor_specs.py 84.25% <0.00%> (+1.10%) ⬆️
examples/dreamer/dreamer_utils.py 78.53% <0.00%> (+1.69%) ⬆️
... and 17 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@BY571 BY571 marked this pull request as ready for review January 5, 2023 07:24
Copy link
Contributor

@vmoens vmoens left a comment

Choose a reason for hiding this comment

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

LGTM thanks for this!

@vmoens vmoens merged commit a9cbd44 into pytorch:main Jan 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. new algo New algorithm request or PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants