Explore Optax Gradient Transformations
mainOptax provides a wide variety of gradient transformations that can be composed to create complex optimizers. These transformations modify gradients before they are applied to parameters.
Common categories of transformations include:
- Scaling: Adjusting gradient magnitude using methods like
scale_by_adam,scale_by_lion,scale_by_rms, orscale_by_learning_rate. - Clipping: Preventing exploding gradients using
clip,clip_by_global_norm, oradaptive_grad_clip. - Noise/Regularization: Adding stochasticity via
add_noiseor managing weight decay withadd_decayed_weights. - State Management: Using
ema(Exponential Moving Average) orsnapshotto track statistics. - Masking/Conditional: Using
conditionally_maskorselective_transformto apply updates only to specific parameters.
Each transformation typically returns an OptState (or a specific state like ScaleByAdamState) which must be maintained and passed back into the optimizer during training loops.