liveBook · Manning

Compile()

As explained in Grokking Machine Learning

A Keras model method that configures a model's loss function, optimizer, and evaluation metrics before training.

Before training a Keras model, compile() sets the loss function, optimizer, and metrics used during training. The loss measures model error, the optimizer guides training, and the metrics report how the model is doing. For categorical classification, one example uses categorical cross-entropy, Adam, and accuracy. section 10.3

model.compile(loss = 'categorical_crossentropy', optimizer='adam', metrics=['accuracy'])

This call configures categorical cross-entropy loss, the Adam optimizer, and accuracy reporting. section 10.3

How Grokking Machine Learning covers it

How deep it goes
Defines loss, optimizer, and metric settings, then gives a classification example without detailing their internals.
Examples
Uses categorical cross-entropy, Adam, and accuracy for a neural-network classifier.
What you can do after
Configure a Keras model with a loss function, optimizer, and metrics before training.
How it connects
Connects loss functions, optimizers, evaluation metrics, and model training.

Related concepts

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