liveBook · Manning

Stochastic gradient descent

As explained in Transformers in Action

Stochastic gradient descent is an iterative optimization method that updates parameters using gradients estimated from individual examples or randomly selected small batches.

Stochastic gradient descent (SGD) iteratively adjusts model weights and biases to reduce loss. Each update uses a gradient estimated from an individual example or a small batch, with the learning rate scaling the step. section 8.1.1

Training behavior depends on settings chosen before training:

  • Learning rate sets the update size: a rate that is too high can overshoot the minimum, while one that is too low can slow training or get stuck in a local minimum. section 8.1.1
  • Batch size sets how many data points contribute to each gradient, affecting convergence stability and speed. section 8.1.1
  • More epochs can improve learning, but training too long can cause overfitting; early stopping can interrupt training when validation improvement stalls. section 8.1.1
Figure 8.1 Gradient descent with lr = 0.1, demonstrating faster convergence
figure

Shows gradient descent with a learning rate of 0.1 and faster convergence. section 8.1.1

Figure 8.2 Gradient descent with lr = 0.01, illustrating stability in convergence
figure

Shows gradient descent with a learning rate of 0.01 and stable convergence. section 8.1.1

How Transformers in Action covers it

How deep it goes
Explains parameter updates and learning-rate, batch-size, and epoch effects on training.
Examples
Compares gradient-descent figures using learning rates of 0.1 and 0.01.
What you can do after
Evaluate how learning rate, batch size, and epochs affect updates, convergence, and overfitting.
How it connects
Connects gradient updates to loss functions, learning rate, batch size, epochs, and early stopping.

Also explained in

Compare how 12 books explain stochastic gradient descent →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Transformers in Action. The section links point to the parts of the book it draws on.