liveBook · Manning

Gradient descent

As explained in Bayesian Optimization in Action

Gradient descent is an iterative optimization technique that updates parameters in the direction opposite the objective gradient.

Gradient descent iteratively improves model parameters by moving them toward lower loss. Imagine descending a mountain: each step follows a direction expected to reach a lower point. In Gaussian-process training, the method adjusts hyperparameters such as the mean constant, length scale, and output scale to reduce the negative log likelihood. section 12.1.2 section 12.1.3

A typical training loop proceeds as follows:

  • Define a likelihood-based loss, such as the negative exact marginal log likelihood. section 12.1.2
  • Create an optimizer such as Adam and give it the parameters to update. section 12.1.2 section 3.3.2
  • Run repeated iterations that clear gradients, compute the loss, backpropagate, and step the optimizer. section 12.1.2
  • Switch the model and likelihood from training mode to evaluation mode before prediction. section 12.1.2

Optimizing a GP mean

A constant-mean GP can begin with a mean of zero while the data favor a mean of two. Adam repeatedly updates model.mean_module.constant to improve the likelihood; tracking the loss and constant shows whether they converge. section 3.3.2

optimizer = torch.optim.Adam(model.parameters(), lr=0.01)          #1
mll = gpytorch.mlls.ExactMarginalLogLikelihood(likelihood, model)  #2
 
model.train()                                                      #3
likelihood.train()                                                 #3
 
for i in tqdm(range(500)):                                         #4
    optimizer.zero_grad()                                          #4
 
    output = model(train_x)                                        #4
    loss = -mll(output, train_y)                                   #4
 
    loss.backward()                                                #4
    optimizer.step()                                               #4
 
model.eval()                                                       #5
likelihood.eval()                                                  #5

The complete PyTorch and GPyTorch loop makes the update sequence directly reusable. section 12.1.2

Gradient descent depends on a reliable loss calculation. With large GP datasets, training can become slow and numerical instability can make the loss jagged, causing updates to produce a suboptimal model rather than a good minimum. section 12.1.3

How Bayesian Optimization in Action covers it

How deep it goes
Explains intuition, training-loop steps, parameter targeting, convergence, and numerical instability without deriving gradient mathematics.
Examples
Uses GP mean optimization, 500-iteration training loops, loss curves, and mountain-descent imagery.
What it assumes
Assumes Gaussian-process models and likelihoods while reinforcing optimization through a mountain analogy and executable loops.
What you can do after
Apply it via PyTorch and GPyTorch to optimize GP parameters and inspect convergence.
How it connects
Connects Gaussian processes, likelihood, hyperparameters, Adam, PyTorch, and numerical stability.

Also explained in

Compare how 17 books explain gradient descent →

Related concepts

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