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
Add learning rate logging #135
Conversation
The API would be like this: model = Model(
module=MyModule(),
optimizer=elegy.Optimizer(
optax.adam(1e-3),
lr_schedule=lambda step, epoch: my_schedule(step, epoch),
steps_per_epoch=100,
)
) Just to clarify, the tp.Union[elegy.Optimizer, optax.GradientTransformation, None] so you can still pass optax object directly, but to enable this additional functionality the idea is to pass the An alternative strategy could be to have |
@cgarciae My main issue with this approach is that only the learning rate multiplier is logged not the actual learning rate (here
I vote for automatically logging if a schedule is given, not logging if it stays constant. That's how Keras does it. |
In my previous example I actually meant: model = Model(
module=MyModule(),
optimizer=elegy.Optimizer(
optax.adam(1.0), # set this to 1 so lr_schedule has more meaning.
lr_schedule=lambda step, epoch: my_schedule(step, epoch),
steps_per_epoch=100,
)
) I think we can get away with documenting this behaviour in the Its a shame that the |
Should we move |
Both is fine.
|
We could definitely accept Just to clarify, are we interpreting the use of optax.scale(-learning_rate) by most Optax optimizers, this makes the definition of a learning rate a bit fuzzy since optax.chain(
optax.sdg(0.5),
optax.scale(0.5),
) is the same as optax.sdg(0.25) |
I would simply use the |
Codecov Report
@@ Coverage Diff @@
## master #135 +/- ##
==========================================
+ Coverage 79.25% 79.44% +0.18%
==========================================
Files 110 110
Lines 5143 5195 +52
==========================================
+ Hits 4076 4127 +51
- Misses 1067 1068 +1
Continue to review full report at Codecov.
|
b12c27b
to
27618b6
Compare
@cgarciae just to answer you I think it would be nice if there is a lr schedule, the learning rate should be logged by default, since you want to monitor that |
Implements the same functionality from #131 using only minor modifications to
elegy.Optimizer
.lr_schedule
andsteps_per_epoch
to Optimizer.Optimizer.get_effective_learning_rate
@alexander-g Here is a proposal that is a bit simpler, closer to what I mentioned in #124. What do you think?
@charlielito should we log the learning rate automatically if available or should we create a Callback?