Menu Big Learning

Stochastic optimization

Fitting a model means adjusting its parameters to reduce a loss. At scale, computing the exact direction for every step can cost more than taking a useful approximate step.

A slender metal wire takes an uneven path down a sloped block.
Following an objective downhill

One update at a time

For a linear predictor, the loss measures how far its prediction is from the desired answer. A gradient describes how the loss changes as each weight changes. Ordinary batch gradient descent uses the contributions of all examples before moving the weights.

Stochastic gradient descent, or SGD, estimates a direction from one example or a small sample. Each direction can wobble, yet a long sequence of inexpensive steps can make real progress. The learning rate controls how far each step moves. A large step can overshoot, while a very small one may waste the time saved by sampling.

An SGD update
  1. Read an example
  2. Evaluate its loss
  3. Adjust the weights

Batches, streams and fresh weights

A mini-batch averages the contributions of several examples. The examples in the batch can often be processed together. A larger batch can give a more stable estimate, but it also requires more work before the next update. Research on accelerated mini-batch methods asks when that trade brings an actual speedup.

Online learning describes the arrival and use of examples. A learner can update as each example arrives without storing a whole collection. SGD is one way to make those updates. The same SGD algorithm can also make repeated passes over a fixed dataset.

Several workers, one model

Synchronous workers compute from the same set of weights and combine their updates before the next step. A slow worker can hold up that round. An asynchronous worker may start from weights another worker has already changed.

The 2011 Hogwild! paper examined shared-memory updates without locks. Its analysis relied on sparsity, where one step touches only a small subset of the weights. That reduces the chance that simultaneous writes interfere. A dense problem that repeatedly updates the same coordinates poses a different risk.

A distributed alternative is to combine local quantities with an AllReduce operation. Communication then becomes part of the cost of an iteration, even if the local arithmetic is cheap.

Further reading