liveBook · Manning

Chapter 5: Fundamentals of machine learning

What you will learn in chapter 5 of Deep Learning with Python, Third Edition

This chapter introduction previews a framework for understanding overfitting, model evaluation, and the balance between training and generalization.

After this chapter you will be able to

What it builds on

Section by section

Introduction

This chapter introduction previews a framework for understanding overfitting, model evaluation, and the balance between training and generalization.

5.1 Generalization: The goal of machine learning

This section explains why improving performance on training data is not the same as achieving good performance on unseen data.

Key terms: optimization, generalization, training data, overfitting, training set, validation set, test set, never-before-seen data

5.1.1 Underfitting and overfitting

This section explains how training can move from underfitting to overfitting, why noisy or misleading features make overfitting more likely, and how feature selection can help.

Key terms: underfit, overfit, optimization, generalization, validation metrics, noisy training data, outliers, ambiguous features, robust fit, rare features

5.1.2 The nature of generalization in deep learning

This section explains why deep learning can generalize despite being able to memorize arbitrary data: natural data has structure that models can learn to interpolate across.

Key terms: representational power, training loss, validation loss, memorizing, manifold hypothesis, manifold, low-dimensional, input space, interpolation, latent manifold

5.2 Evaluating machine-learning models

This introduction explains why reliable evaluation is necessary when developing models that generalize to new data.

Key terms: generalization power, evaluate machine learning models

5.2.1 Training, validation, and test sets

This section explains why model evaluation needs separate training, validation, and test data, then compares three ways to split and reuse data when evaluation is unstable.

Key terms: training data, validation data, test data, hyperparameters, information leaks, overfitting to the validation set, generalization, simple hold-out validation, validation set, test set

5.2.2 Beating a common-sense baseline

This section explains how a common-sense baseline makes validation performance meaningful and helps determine whether a model is worth pursuing.

Key terms: common-sense baseline, trivial baseline, validation metrics, random classifier, class imbalance, validation accuracy

5.2.3 Things to keep in mind about model evaluation

This section explains three ways data splits can make model evaluation misleading and why reliable evaluation matters for judging generalization.

Key terms: Data representativeness, training set, test set, randomly shuffle, The arrow of time, temporal leak, posterior, Redundancy in your data, validation set, disjoint

5.3 Improving model fit

This section sets the initial model-fitting milestone—beating a simple baseline while becoming capable of overfitting—and identifies three signs that the model has not reached it.

Key terms: generalization power, overfit, common-sense baseline, training loss, validation loss, underfitting

5.3.1 Tuning key gradient descent parameters

This section explains how to get stalled model training moving by tuning the learning rate and batch size.

Key terms: loss, gradient descent process, optimizer, initial values, learning rate, batch size, gradients, lower variance

5.3.2 Using better architecture priors

This section explains why a model can fit its training data yet perform no better than chance on validation data, emphasizing the need for suitable architecture priors.

Key terms: input data, targets, generalize, shuffled labels, architecture priors, densely connected architecture, recurrent architecture, generalization

5.3.3 Increasing model capacity

This section shows how loss curves can reveal insufficient model capacity and why increasing capacity can make a model overfit, while too much capacity can make it overfit immediately.

Key terms: model capacity, representational power, architecture priors, validation loss, overparameterized, memorization capacity, overfitting

5.4 Improving generalization

5.4.1 Dataset curation

This section explains why improving generalization starts with choosing and curating suitable data, often before improving the model.

Key terms: generalization, latent structure, smoothly interpolate, curve fitting, dataset curation, dense sampling, labeling errors, missing values, feature selection

5.4.2 Feature engineering

The section explains how hand-designed input features can simplify a learning problem and why they remain useful even when deep learning can extract features automatically.

Key terms: feature engineering, hardcoded (non-learned) transformations, input features, raw pixels, (x, y) coordinates, polar coordinates, angle theta, classical shallow algorithms, deep learning, useful features

5.4.3 Using early stopping

This section explains why deep learning training should stop before a complete fit and how validation metrics can identify and preserve the best model state.

Key terms: overparameterization, minimum possible training loss, most generalizable fit, underfit curve, overfit curve, validation metrics, epochs, EarlyStopping callback, best known model state

5.4.4 Regularizing your model

This section explains how reducing model capacity, penalizing large weights, and using dropout can limit overfitting, with validation results guiding the choice.

Key terms: regularization, generalization, validation, capacity, learnable parameters, validation loss, underfit, overfit, weight regularization, L1 regularization

5.5 Summary

Where this is used later

Concepts explained in this chapter

← Chapter 4: Classification and regression Chapter 6: The universal workflow of machine learning →

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.