-
Notifications
You must be signed in to change notification settings - Fork 306
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
[Refactor] Refactor losses (value function, doc, input batch size) #987
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
Mar 23, 2023
vmoens
force-pushed
the
add_adv_module_lossesd
branch
from
March 27, 2023 10:48
2efc4d4
to
dd6ac56
Compare
vmoens
added
enhancement
New feature or request
bc breaking
backward compatibility breaking change
labels
Mar 28, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
bc breaking
backward compatibility breaking change
CLA Signed
This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
enhancement
New feature or request
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This is a major refactoring of the loss modules.
From now on, loss and value estimation are decoupled as much as can be. This leaves the possibility to the user to pick the value function that she feels appropriate.
In a nutshell, the previous API left little choice of value estimator:
From now on, one can pick up the value function after creating the loss:
Each loss is equipped with a default value function that can be accessed via
If
make_value_function
is not called, then this default value estimator will be used.The reason why we don't simply pass a ValueFunction module is that some losses (eg SAC) have an intricated value:
Q(s,a) - log_prob(a|s)
for instance. Hence we can't just have the users makevf = ValueFunction(network, ...)
and passvf
to the loss. With thisEnum
trick, we get the best of both worlds: total flexibility in user-facing constructors and full compatibility in the backend.BC-breaking changes
TD0Estimate
,TD1Estimate
,TDLambdaEstimate
gamma
orlmbda
to the module raises a warning. However for bc-compatibility the value passed will still be used *unless another is passed viamake_value_function
.Unaddressed
We did not take care of making all losses compatible with GAE. The only reason is that GAE requires the value (not only the next value), which we currently don't support. This can be addressed separately.