Skip to content

Conversation

@Solventerritory
Copy link

This PR adds a new example script, examples/lookahead_usage.py, demonstrating the correct and intuitive usage of the Optax lookahead optimizer. The example clarifies the required parameter wrapping and update pattern, addressing confusion raised in issue #1429.

  • Shows how to initialize and use LookaheadParams
  • Demonstrates gradient calculation and update steps
  • Provides a minimal, reproducible usage pattern

This should help users adopt the lookahead optimizer as a drop-in replacement, following the Optax API conventions.

@rdyro
Copy link
Collaborator

rdyro commented Dec 28, 2025

Thanks for the contribution, as is this is not a very helpful example, are you interested reviewing / expanding lookahead_mnist.ipynb instead?

@Solventerritory
Copy link
Author

@rdyro

@rdyro
Copy link
Collaborator

rdyro commented Jan 2, 2026

I'm unclear on the direction of thi

@rdyro rdyro closed this Jan 2, 2026
@rdyro rdyro reopened this Jan 2, 2026
@rdyro
Copy link
Collaborator

rdyro commented Jan 2, 2026

Sorry, closed by mistake.

I'm unsure about the direction of this PR. As is, this PR does not meaningfully expand on the existing lookahead optimizer example and the contributed .py file is not in keeping with optax's style of jupyter notebook examples.

We already have a lookahead optimizer example notebook: lookahead_mnist.ipynb that could perhaps benefit from an more in-depth demonstration, but I don't see this PR taking that direction so far.

Would you like to take a look at meaningfully expanding lookahead_mnist.ipynb?

- Add comprehensive explanation section about lookahead optimizer
- Include step-by-step initialization guide with comments
- Enhance training loop with detailed docstrings and annotations
- Add usage summary section with common mistakes and best practices
- Clarify when to use params.fast vs params.slow

This addresses reviewer feedback to expand the existing lookahead
example notebook rather than adding a new .py file.
@Solventerritory Solventerritory force-pushed the lookahead-usage-example branch from 7cd25b8 to 8ecd70e Compare January 6, 2026 21:53
@Solventerritory Solventerritory force-pushed the lookahead-usage-example branch from 941810f to 1bbdad7 Compare January 6, 2026 22:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants