liveBook · Manning

Learning rate

As explained in Deep Learning with R, Third Edition

A learning rate is the step-size hyperparameter controlling how far model parameters move during an optimization update.

A learning rate is the step size used when changing model weights during optimization. After computing the loss gradient, training moves each parameter in the opposite direction by an amount scaled by the learning rate. section 2.4.3 section 2.6

Choose the value with the training behavior in mind:

  • Too small: updates are tiny, so descent can require many iterations and appear to stall. section 2.4.3 section 5.3.1
  • Too large: updates can overshoot a useful fit and send optimization to poor or seemingly random locations. section 2.4.3 section 5.3.1
  • Tune it together with batch size when training stalls; larger batches can make gradients more informative and less noisy. section 5.3.1

Training MNIST with RMSprop

A dense MNIST model using RMSprop with a learning rate of 1 reaches only about 20%–40% accuracy. Keeping the model and batch size unchanged while reducing the learning rate to 1e-2 allows training to proceed. section 5.3.1

Listing 2.9 A single step of training
one_training_step <- function(model, images_batch, labels_batch) {
  predictions <- model$call(images_batch)  #1
  loss <-

 op_sparse_categorical_crossentropy(labels_batch, predictions) #2
  average_loss <- op_mean(loss)
  gradients <- get_gradients_of_loss_wrt_weights(loss, model$weights) 
  update_weights(gradients, model$weights)  #3
  loss
}

Follow one training step from predictions and loss through automatic differentiation to weight updates. section 2.5.2

How Deep Learning with R, Third Edition covers it

How deep it goes
Defines the update role, gives the weight-update equation, and demonstrates tuning, but defers systematic schedules and advanced optimization details.
Examples
Uses manual weight updates, Keras optimizers, and MNIST runs comparing learning rates of 1 and 1e-2.
What it assumes
Assumes basic model training while introducing gradients, loss, backpropagation, and optimizer-based weight updates.
What you can do after
Operate/configure training by setting the learning rate and adjusting it when updates overshoot or optimization appears stalled.
How it connects
Connects learning rate to gradients, loss, backpropagation, optimizers, mini-batch stochastic gradient descent, and batch size.

Also explained in

Compare how 16 books explain learning rate →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Deep Learning with R, Third Edition. The section links point to the parts of the book it draws on.