-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
[RLlib] Add functionality to define kernel and bias initializers for RLModule
s.
#42137
[RLlib] Add functionality to define kernel and bias initializers for RLModule
s.
#42137
Conversation
…etworks. This commit implements it for framework 'tf2'. Signed-off-by: Simon Zehnder <simon.zehnder@gmail.com>
Signed-off-by: Simon Zehnder <simon.zehnder@gmail.com>
Signed-off-by: Simon Zehnder <simon.zehnder@gmail.com>
… the initial dense layer of 'TransposeCNNHead'. Signed-off-by: Simon Zehnder <simon.zehnder@gmail.com>
RLModule
s.RLModule
s.
|
||
# Initialize, if necessary. | ||
if cnn_transpose_initializer: | ||
if cnn_transpose_initializer_config: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Simplify to:
if cnn_transpose_initializer_config is not None:
cnn_transpose_initializer(
layer.weight, **(cnn_transpose_initializer_config or {})
)
Gets rid of one entire if-else-block.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great catch! Thanks @sven1977 !
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we do not need the or {}
there
bias=cnn_transpose_use_bias or is_final_layer, | ||
), | ||
|
||
layer = nn.ConvTranspose2d( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
) | ||
if cnn_initializer: | ||
if cnn_initializer_config: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same simplification as described below (see Conv Transpose).
output_initializer(layer.weight) | ||
else: | ||
if hidden_initializer: | ||
if hidden_layer_initializer_config: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same simplification as described below (see Conv Transpose).
rllib/core/models/torch/heads.py
Outdated
|
||
if initial_dense_initializer: | ||
if config.initial_dense_initializer_config: | ||
initial_dense_initializer( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same simplification as described below (see Conv Transpose).
…review from @sven1977. Signed-off-by: Simon Zehnder <simon.zehnder@gmail.com>
Signed-off-by: Simon Zehnder <simon.zehnder@gmail.com>
Signed-off-by: Simon Zehnder <simon.zehnder@gmail.com>
Signed-off-by: Simon Zehnder <simon.zehnder@gmail.com>
Signed-off-by: Simon Zehnder <simon.zehnder@gmail.com>
Signed-off-by: Simon Zehnder <simon.zehnder@gmail.com>
Signed-off-by: Simon Zehnder <simon.zehnder@gmail.com>
…does not allow like the others None for the initializer. Signed-off-by: Simon Zehnder <simon.zehnder@gmail.com>
Signed-off-by: Sven Mika <sven@anyscale.io>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Pending test cases for merge ... Thanks @simonsays1980 !
Hey @simonsays1980 , could you check the tests? I think 2 are failing due to the new changes. |
… were not yet named right. Also added docs for these. Signed-off-by: Simon Zehnder <simon.zehnder@gmail.com>
Signed-off-by: Simon Zehnder <simon.zehnder@gmail.com>
@sven1977 There were a couple of minor bugs yesterday - the ones you saw after my last push. Hopefully with my commit today tests should all pass. |
RLModule
s.RLModule
s.
Signed-off-by: Simon Zehnder <simon.zehnder@gmail.com>
Why are these changes needed?
The new stack does not offer users to define the initializers for network weights. Following literature (e.g. https://arxiv.org/abs/2006.05990) initialization of network weights can have signficant influence on policy performance.
This PR adds the funcitonality of network initialization to the new stack and enables thereby users to
Related issue number
Closes #40259
Checks
git commit -s
) in this PR.scripts/format.sh
to lint the changes in this PR.method in Tune, I've added it in
doc/source/tune/api/
under thecorresponding
.rst
file.