Here's a proposal for a new improvement to the Adam optimizer, which we'll call "AdamFlex" (Adaptive Moment Estimation with Flexible Learning Rate Adjustment):
AdamFlex builds upon the original Adam optimizer by introducing a dynamic learning rate adjustment mechanism that adapts to the training progress without significantly increasing storage or computational requirements. The key idea is to introduce a flexible learning rate schedule that responds to changes in the loss landscape and gradient statistics.
Key features of AdamFlex:
-
Minimal additional storage: AdamFlex only requires one additional scalar value per parameter group, which stores the cumulative gradient norm.
-
Low computational overhead: The additional computations are minimal and mostly involve simple operations on scalar values.
-
Maintains Adam's core functionality: AdamFlex preserves the carefully tuned Adam hyperparameters and its adaptive moment estimation.
-
Transformer-friendly: The proposed modification is designed to work well with transformer architectures.
Here's how AdamFlex modifies the original Adam algorithm:
-
Initialize an additional variable cumulative_grad_norm for each parameter group, set to 0.
-
During each update step, after computing the gradients but before applying the Adam update:
a. Calculate the L2 norm of the gradients for the current parameter group.
b. Update the cumulative_grad_norm:
cumulative_grad_norm = β * cumulative_grad_norm + (1 - β) * current_grad_norm
where β is a smoothing factor (e.g., 0.99).
-
Modify the effective learning rate based on the cumulative_grad_norm:
effective_lr = base_lr * (1 + γ * tanh(cumulative_grad_norm / α))
where:
- base_lr is the original Adam learning rate
- γ is a small scaling factor (e.g., 0.1)
- α is a normalization factor (e.g., the initial gradient norm)
-
Use this effective_lr in place of the original learning rate when applying the Adam update.
The benefits of AdamFlex:
-
Adaptive to training dynamics: The effective learning rate adjusts based on the recent history of gradient norms, allowing for more aggressive updates when gradients are consistently large and more conservative updates when they are small.
-
Smooth transitions: The use of tanh ensures smooth transitions in the learning rate adjustment, preventing abrupt changes that could destabilize training.
-
Minimal hyperparameter tuning: The additional hyperparameters (β, γ, and α) can be set to reasonable default values and don't require extensive tuning.
-
Transformer-friendly: The adaptive nature of this modification is particularly suitable for transformer architectures, which often have varying gradient magnitudes across different layers and attention heads.
-
Easy to implement: AdamFlex can be implemented with minimal changes to existing Adam optimizer code.
This proposed improvement aims to enhance Adam's performance on transformer architectures without significantly increasing computational or storage requirements, while preserving the carefully tuned original Adam hyperparameters.