liveBook · Manning

Adam

As explained in Deep Learning with Python, Third Edition

An adaptive gradient-based optimization algorithm that updates model parameters using running estimates of first and second moments of gradients.

Adam is an optimizer: it defines how a neural network changes its weight tensors after calculating loss gradients. It is commonly used as a reliable default, so choosing an optimizer need not become an early design obstacle. section 2.5 section 4.1.3

A practical compilation choice

A Keras model can be compiled with Adam alongside a task-appropriate loss. For binary classification, pair Adam with binary_crossentropy when the final layer produces a sigmoid probability. Training then applies the optimizer's update rules across mini-batches. section 4.1.3 section 2.5

model.compile(
    optimizer="adam",
    loss="sparse_categorical_crossentropy",
    metrics=["accuracy"],
)

Inspect the compact Keras configuration that selects Adam, the loss function, and the accuracy metric together. section 2.5

Use Adam with these practical rules:

  • Start with Adam when you need a broadly suitable optimizer for a new problem. section 4.1.3
  • Choose the loss from the task and output representation; Adam does not replace that decision. section 4.1.3
  • Remember that training still computes gradients through backpropagation and applies updates batch by batch. section 2.5
  • Monitor performance on data outside the training set, because optimization can coincide with overfitting. section 4.1.7

How Deep Learning with Python, Third Edition covers it

How deep it goes
Explains Adam's role in gradient descent and default selection, but stops short of its adaptive moment estimates or update equations.
Examples
Uses Adam for MNIST digit classification and binary classification with sigmoid output and binary crossentropy.
What it assumes
Assumes familiarity with model weights, loss functions, gradients, and training loops while explaining their roles in context.
What you can do after
Configure Adam through Keras model compilation and use it to train models with mini-batch gradient updates.
How it connects
Ties Adam to loss functions, backpropagation, mini-batch stochastic gradient descent, model compilation, and overfitting.

Related concepts

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