fix(contrib): improve adopt docstring example to show meaningful convergence and add doctest coverage - #1747
Draft
wahid18-maqs wants to merge 2 commits into
Conversation
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
This PR improves the
adopt()docstring example to show meaningful optimizer convergence and adds doctest coverage to keep the example executable.Changes
adopt()docstring example to:learning_rate=0.1instead of0.003so the optimizer makes visible progressjax.value_and_gradinstead ofjax.gradto follow the idiomatic optax patternoptax/contrib/_adopt_test.pywith adoctest.DocTestSuitewrapper to execute the example as part of the test suiteWhy
The previous example used
learning_rate=0.003which produced no visible decrease in the objective function across 5 steps — the loss stayed at14.0throughout. This misled users into thinking ADOPT was not working or that stagnation was expected behavior.The updated example uses a more appropriate learning rate that shows the optimizer actually making progress, giving users a realistic expectation of what ADOPT does.
Adding doctest coverage also ensures the example remains valid and synchronized with the implementation going forward.