liveBook · Manning

Chapter 3: Classifiers and vector calculus

What you will learn in chapter 3 of Math and Architectures of Deep Learning

This chapter introduces error minimization for classifiers by using gradients to adjust model weights and biases toward desired outputs.

After this chapter you will be able to

What it builds on

Section by section

Introduction

This chapter introduces error minimization for classifiers by using gradients to adjust model weights and biases toward desired outputs.

Key terms: error minimization, training examples, weights, biases, gradients

3.1 Geometrical view of image classification

Introduces image classification through a car-versus-giraffe binary classifier and raises the need to represent the input image.

Key terms: image classification, classifier, binary classifier, classes, input, input representation

3.1.1 Input representation

This section represents a fixed-size image as a pixel-value matrix and rasterizes that matrix into a high-dimensional vector for geometric machine-learning analysis.

Key terms: pixel, image plane, two-dimensional array, matrix, pixel color value, rasterization, rasterized vector, vector, 50,176-dimensional space, pixel values

3.1.2 Classifiers as decision boundaries

This section presents image classification geometrically, with class examples forming clusters in high-dimensional input space and classifiers separating them with decision boundaries.

Key terms: rasterization, high-dimensional space, class, cluster, pixel values, classifier, hypersurface, decision boundary, point clusters, hyperplane

3.1.3 Modeling in a nutshell

This section explains how classifier modeling uses labeled training examples to choose a model family and iteratively fit its parameters so its decision boundary separates classes.

Key terms: training data, training inputs, ground truth, decision boundary, classifying surface, modeling the classifier, model architecture selection, parametric model function, model training, parameters

3.1.4 Sign of the surface function in binary classification

This subsection explains how the sign of a binary classifier's decision-surface function identifies which side of the boundary an input lies on and therefore predicts its class.

Key terms: binary classifiers, decision boundary, decision surface, φ(x; b), sign, input vector, line, half planes, separator, y + 2x + 1 = 0

3.2 Error, aka loss function

This section defines squared-error loss for individual labeled examples and the total training dataset, which training minimizes by adjusting model parameters.

Key terms: loss function, squared error, training data instance, input-target pair, model output, target output, total loss, total error, training data set, L(w,b)

3.3 Minimizing loss functions: Gradient vectors

This section introduces iterative supervised-model training as minimizing total loss by updating weights and bias using loss gradients and a learning rate.

Key terms: training, weights, bias, loss, total error, inferencing, gradient, loss gradient, ∇w,b L(w,b), gradient descent

3.3.1 Gradients: A machine learning-centric introduction

This section derives how small changes to model parameters change loss, culminating in the gradient as the vector tool for locating directions of loss change and stationary optima.

Key terms: loss function, parameters, weights, bias, ground truth, training inputs, δL, δw, derivative, dL/dw

3.3.2 Level surface representation and loss minimization

This section visualizes loss functions through level contours and surfaces to show why gradients point in the direction of fastest loss increase and how this guides loss minimization.

Key terms: level contour, level surface, level hypersurface, domain, loss function, gradient, tangent, normal, loss minimization, parameter space

3.4 Local approximation for the loss function

This section introduces Taylor series as practical local approximations of a loss function when finite parameter updates make the gradient-based linear change estimate inexact.

Key terms: loss function, parameter space, displacement, gradient vector, linear function, Taylor series, multidimensional function, local neighborhood, displacements, second term

3.4.1 1D Taylor series recap

This subsection recaps how a smooth one-dimensional loss curve can be approximated near a point by a Taylor series and usually truncated to its first-order gradient term.

Key terms: Taylor series, smooth function, derivatives, displacement δw, loss function L(w), first-order approximation, second-order term, δL, δw, dL/dw

3.4.2 Multidimensional Taylor series and the Hessian matrix

This subsection extends the local Taylor approximation of a loss from one parameter to many by using the gradient and Hessian matrix.

Key terms: multidimensional Taylor series, loss, parameter space, displacement vector, gradient, Hessian matrix, second derivatives, mixed partial derivatives, symmetric matrix, first-order approximation

3.5 PyTorch code for gradient descent, error minimization,and model training

This introduction previews practical PyTorch examples that train models by minimizing error with gradient descent and points readers to the complete code.

Key terms: PyTorch, gradient descent, error minimization, model training, complete code, http://mng.bz/4Zya

3.5.1 PyTorch code for linear models

This section implements a linear PyTorch model and frames its training as learning weights and a bias that minimize summed squared prediction error.

Key terms: true underlying function, input vector, output scalar, output vector, observations, parameterized function, error, squared error, batch error, loss

3.5.2 Autograd: PyTorch automatic gradient computation

This subsection introduces PyTorch Autograd as a scalable way to automatically compute model gradients by tracking computations involving selected variables.

Key terms: automatic differentiation, PyTorch Autograd, gradient, closed-form gradient, requires_grad = True, tracked variables, computation graph, Autograd

3.5.3 Nonlinear Models in PyTorch

This section contrasts fitting linear and nonlinear models to show that an architecture must match the underlying data relationship, because extra training cannot fix an inadequate linear model.

Key terms: linear model, nonlinear model, linear data distribution, nonlinear data distribution, model architecture, underlying output function, inadequate model architecture, further training, nonlinearity, real-life problems

3.5.4 A linear model for the cat brain in PyTorch

This subsection introduces training a PyTorch linear model on the cat-brain dataset and relates its learned parameters to the earlier pseudo-inverse solution.

Key terms: cat-brain problem, PyTorch model, pseudo-inverse, training dataset, model parameters, converge, pseudo-inverse technique, simple training dataset

3.6 Convex and nonconvex functions, and global and local minima

This section contrasts convex and nonconvex loss surfaces, explaining why gradient descent reaches a global minimum for convex surfaces but can stop at local minima on nonconvex ones.

Key terms: convex surface, global minimum, gradient, parameter space, nonconvex surface, local minimum, zero gradient, simulated annealing, random point, retrain

3.7 Convex sets and functions

This introduction frames the study of convex sets and functions, emphasizing tests for convexity, useful properties, and their extension from 2D to higher dimensions.

Key terms: convex functions, convexity, local minima, 2D space, higher dimensions, Jensen's inequality

3.7.1 Convex sets

This subsection defines convex and nonconvex sets geometrically by whether line segments between their points remain inside the set.

Key terms: convex set, straight line, pair of points, nonconvex set, joining line, points C and D, boundary, convex curve

3.7.2 Convex curves and surfaces

This section gives equivalent geometric and differential characterizations of convex curves and surfaces, and distinguishes concavity from nonconvexity.

Key terms: convex function, weighted average, secant line, convex curve, convex surface, second derivative, curvature, Hessian matrix, positive semidefinite, negative semidefinite

3.7.3 Convexity and the Taylor series

This subsection connects Taylor approximations to the two equivalent local characterizations of convexity: positive curvature and lying above tangents.

Key terms: Taylor expansion, linear approximation, tangent, quadratic approximation, first derivative, second derivative, convex function, tangent definition of convexity, second derivative definition of convexity

3.7.4 Examples of convex functions

This section identifies common convex and concave functions using second derivatives and states operations that preserve convexity.

Key terms: convex, second derivative, even power, positive second derivative, concave, log x, −log x, positive scalar, convexity, sum of convex functions

3.8 Summary

This summary connects geometric classification with loss-based gradient training and the local and global behavior of loss surfaces.

Where this is used later

Concepts explained in this chapter

← Chapter 2: Vectors, matrices, and tensors in machine learning Chapter 4: Linear algebraic tools in 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.