Optimizer.

An algorithm that uses gradients to update neural network weights during training, with techniques like momentum and adaptive learning rates.

An optimizer is a fundamental algorithm in machine learning that determines how a neural network's weights are updated during training based on computed gradients. The optimizer takes the gradients calculated through backpropagation and applies them to adjust the model parameters in a way that minimizes the loss function. Modern optimizers like Adam, AdamW, and RMSprop have largely replaced simple gradient descent because they incorporate sophisticated techniques like momentum and adaptive per-parameter learning rates that dramatically improve training efficiency and convergence.

Different optimizers employ various strategies to overcome the limitations of basic gradient descent. Momentum-based optimizers like SGD with momentum accumulate gradients over time to smooth out noisy updates and accelerate convergence in consistent directions. Adaptive optimizers like Adam maintain separate learning rates for each parameter, automatically adjusting based on the historical gradients to handle sparse gradients and different parameter scales effectively. AdamW adds weight decay directly to the update rule rather than to the loss function, providing better regularization for transformer models.

The choice of optimizer significantly impacts training dynamics, convergence speed, and final model performance. While Adam variants are popular for their robustness and fast initial convergence, SGD with momentum often achieves better generalization on certain tasks, leading to the common practice of switching optimizers during training. Learning rate scheduling works in conjunction with the optimizer, and hyperparameter tuning often focuses heavily on optimizer settings. A common misconception is that more sophisticated optimizers always perform better—in practice, the optimal choice depends on the specific model architecture, dataset characteristics, and computational constraints.