1. The Optimization Problem¶
The goal of training a neural network is to minimize the empirical loss over a training set of samples:
Finite-Sum Structure: The objective is a sum of individual sample losses .
Non-convexity: Due to non-linear activation functions, the loss surface is generally non-convex, requiring gradient-based optimization.
Gradients: Training requires computing the gradient of the total loss: .
2. The Backpropagation Algorithm¶
Backpropagation is an efficient method for computing the gradient using the chain rule. It consists of two primary phases:
Phase 1: Forward Pass¶
Input is fed through the network to compute and store intermediate activations:
Linear Combination:
Hidden Activation:
Output Logits:
Prediction:
Loss Computation: (for regression)
Phase 2: Backward Pass¶
Gradients are computed layer-by-layer starting from the output:
Output Error (): Compute the error signal at the output layer:
Output Weights Gradient:
Hidden Error (): Backpropagate the error to the hidden layer:
Input Weights Gradient:
3. Computational Efficiency¶
The total cost of a single training step is the sum of the forward and backward passes:
Forward Pass: where are the dimensions of the input, hidden, and output layers respectively.
Backward Pass: .
Key Insight: The backward pass has the same order of complexity as the forward pass, making backpropagation highly efficient for large-scale models.
4. Stochastic Gradient Descent (SGD)¶
To scale to massive datasets, optimizers use subsets of data rather than the full batch.
Mini-batch SGD¶
Instead of computing the full gradient , we sample a mini-batch of size :
Learning Rate (): Determines the step size of the update.
Batch Size (): Common values include 64, 128, or 256.
Epoch: One complete pass through the entire dataset.
Iterations per Epoch: , where is the total number of training samples.
5. Model Summary: NN vs. Ensemble Methods¶
Lecture 13 also concludes the discussion on tree-based ensembles:
Bagging: Reduces variance by training multiple trees on bootstrapped samples and averaging results.
Random Forest: Improves Bagging by selecting a random subset of features at each split to de-correlate the trees.
Classification: .
Regression: .