liveBook · Manning

Momentum

As explained in Natural Language Processing in Action, Second Edition

Momentum is an optimization hyperparameter that incorporates prior update direction to accelerate or damp parameter movement during gradient-based optimization.

Momentum is an optimizer hyperparameter that carries forward update direction. It accelerates movement when optimization heads toward the target and slows movement when it veers away. Like learning rate, it must be tuned for the problem rather than treated as universally optimal. section 5.2.5

Configure momentum in PyTorch

A logistic-regression neuron uses stochastic gradient descent with momentum 0.001 and learning rate 0.02: `optimizer = SGD(model.parameters(), momentum=0.001, lr=0.02)`. Training repeatedly zeros gradients, computes loss, backpropagates, and calls `optimizer.step()` across 200 epochs.

How Natural Language Processing in Action, Second Edition covers it

How deep it goes
Defines acceleration and damping behavior, then demonstrates configuration; stops short of deriving the update equation or systematic tuning procedure.
Examples
Demonstrates momentum in a PyTorch single-neuron classifier trained for 200 epochs on vectorized name data.
What it assumes
Assumes gradient-based optimization, stochastic gradient descent, loss functions, and learning rate; introduces momentum as an optimizer attribute.
What you can do after
Apply momentum via PyTorch's SGD optimizer and inspect training loss and test accuracy across epochs.
How it connects
Connects momentum with stochastic gradient descent, learning rate, loss functions, backpropagation, and hyperparameter tuning.

Also explained in

Compare how 6 books explain momentum →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Natural Language Processing in Action, Second Edition. The section links point to the parts of the book it draws on.