Executive Summary · First Principles · Mathematics
Deconstructing learning from first principles : function approximation, inductive bias, loss landscapes, backpropagation, and double descent.
Introduction: Reverse-Engineering Reality

At its most fundamental level, machine learning is not magic, nor is it the creation of sentient intelligence. It is a mathematical discipline focused on a singular objective: Function Approximation.
In classical programming, we explicitly write the function that maps an input to an output. We define the rules. In machine learning, we invert this process. We observe inputs () and targets (), and we construct a system that "learns" the function that connects them.
We are, in essence, reverse-engineering the hidden rules of the universe from empirical examples. Whether we are predicting stock prices, classifying images, or generating text, the goal remains the same: find a parameterization for a model such that:
1. The Mathematical Framework
We assume there exists a true ground-truth data distribution . We do not have access to this full distribution; we only have a finite observed dataset .
Our goal is to select a hypothesis from a specific hypothesis space (the set of all possible functions our model can represent) that minimizes predictive error.
The Four Pillars of Learning
Every machine learning architecture is built upon four fundamental pillars:
01 / The Data
Empirical observations sampled from the underlying distribution .
02 / The Model
The mathematical architecture defining hypothesis space parameterized by .
03 / The Loss Function
The scalar objective metric quantifying prediction error.
04 / The Optimizer
The gradient-based update mechanism driving parameters toward minimum loss.
2. Model Capacity and Inductive Bias
The Model determines the "shape" of functions we can learn. A linear regression model can only learn straight hyperplanes; it has a rigid inductive bias. A deep neural network has a much weaker inductive bias, allowing it to approximate complex non-linear manifolds.
This flexibility brings us to Model Capacity.
The Bias-Variance Tradeoff
Capacity measures a model's ability to fit diverse function spaces:
- Low Capacity (High Bias): The model is too simple to capture the underlying structure. This leads to Underfitting.
- High Capacity (High Variance): The model captures both signal and random noise. This leads to Overfitting.
3. The Loss Landscape
If the model is the vehicle, the Loss Function is the mountain terrain:
- Regression (MSE):
- Classification (Cross-Entropy):
Training seeks parameter updates minimizing total error:
4. The Training Loop: Engine of Learning
To descend the loss terrain, we compute local gradients pointing toward steepest error reduction.
Forward Pass
Pass input batch through the parameterized model to produce predictions .
Loss Computation
Evaluate discrepancy between predictions and ground truth via loss objective .
Backward Pass (Backpropagation)
Compute gradients with respect to every weight vector using the chain rule: .
Optimization Step
Update weights in the opposite gradient direction scaled by learning rate :

5. Implementation: PyTorch Engine
Here is a complete PyTorch implementation of linear regression with automated gradient computation:
import torchimport torch.nn as nnimport torch.optim as optim# 1. Data GenerationX = torch.randn(100, 1)y = 2.0 * X + 1.0 + 0.1 * torch.randn(100, 1)# 2. Model & Optimizermodel = nn.Linear(in_features=1, out_features=1)criterion = nn.MSELoss()optimizer = optim.SGD(model.parameters(), lr=0.1)# 3. Training Loopfor epoch in range(101):y_pred = model(X)loss = criterion(y_pred, y)optimizer.zero_grad()loss.backward()optimizer.step()
Execution Transcript
Optimizer Upgrade: SGD vs Adam
−optimizer = optim.SGD(model.parameters(), lr=0.1)+optimizer = optim.Adam(model.parameters(), lr=0.05, betas=(0.9, 0.999))+scheduler = optim.lr_scheduler.CosineAnnealingLR(optimizer, T_max=100)
6. Generalization & Holdout Split
The most critical concept in machine learning is Generalization. We care exclusively about performance on data the model has never seen (Test Error).