QuiddityML

ML Foundations

How models learn, neural networks, optimization, generalization, and evaluation. Posts are listed in the order the ideas build on each other.

How a model learns

How a model learns What is machine learning? The 5 types of learning explained Machine learning is a way to build software that learns its rules from examples instead of having them written by hand. This post explains how that works and why it can work on data the model has never seen, then walks through the five types of learning (supervised, unsupervised, semi-supervised, self-supervised, and reinforcement learning) with an example of each and how to pick between them. 24 September 2026 · 8 min read How a model learns What is a perceptron? From the original perceptron to the modern neuron A perceptron is the simplest artificial neuron: it weighs its inputs, adds them up, and outputs 0 or 1. This post explains how it works, how it learns, why modern neurons output a real number instead, and why one neuron can never solve XOR. 25 September 2026 · 7 min read How a model learns Linear regression from scratch in PyTorch Linear regression predicts a number, like a house price, as a weighted sum of the inputs plus a bias. This post builds it in PyTorch two ways: with gradients computed by hand, and with nn.Linear and an optimizer. 25 September 2026 · 6 min read How a model learns What is a loss function? MSE, cross-entropy, and when to use which A loss function turns a model's predictions into one number that says how wrong they are, and training is the process of pushing that number down. This post explains why models need one, which loss to use for regression, binary, multi-class, and multi-label problems (and for a few other tasks), and how to use the loss on a proper validation split to evaluate a model. 23 September 2026 · 13 min read How a model learns Entropy, cross-entropy, and KL divergence explained Cross-entropy is the usual loss for training a classifier. This post explains where it comes from, starting with entropy and ending with KL divergence, works each one out on the same small example, and shows how to compute them in PyTorch. 26 September 2026 · 8 min read How a model learns Maximum likelihood estimation explained: where MSE and cross-entropy come from Maximum likelihood estimation picks the model parameters that make the observed data most probable. This post explains it with a coin-flip example, then shows how the same idea produces mean squared error for regression and cross-entropy for classification. 26 September 2026 · 8 min read How a model learns What is gradient descent? Explained step by step Gradient descent is the procedure that trains almost every machine learning model. This post explains what it does, why the update has a minus sign, how the learning rate changes everything, and what the three lines of PyTorch that implement it are doing. 16 September 2026 · 6 min read How a model learns What is backpropagation? Explained with a tiny network Backpropagation is how a neural network works out which way to change each of its weights to reduce its error. This post computes it by hand on a network with two weights, shows why it runs backward, and checks the numbers against PyTorch. 21 September 2026 · 5 min read How a model learns The PyTorch training loop explained, with Dataset and DataLoader The training loop is the five lines of PyTorch code that make a model learn from data. This post explains what each line does, why their order can't be swapped, and how a Dataset and DataLoader feed the loop one batch at a time. 26 September 2026 · 8 min read How a model learns Logistic regression explained: sigmoid, binary cross-entropy, and why it is a one-layer neural network Logistic regression predicts the probability that an input belongs to one of two classes. This post explains the sigmoid function, the binary cross-entropy loss it trains with, why the two are paired, and how to train it in PyTorch. 27 September 2026 · 9 min read How a model learns Softmax explained: probabilities, model confidence, and the stable softmax trick Softmax turns a classifier's raw scores into probabilities that add up to 1. This post explains the formula with a worked example, how to read its output as the model's confidence and when not to trust it, and why softmax code subtracts the largest score first. 27 September 2026 · 7 min read How a model learns Multi-class vs multi-label classification: softmax vs sigmoid outputs Multi-class classification picks exactly one label per input, and multi-label classification can pick several or none. This post explains the difference, why the first uses softmax and the second uses one sigmoid per label, and how to write both in PyTorch. 27 September 2026 · 5 min read

Neural networks

Neural networks What is a neural network? The multilayer perceptron explained A neural network passes its input through layers of simple units, each layer reshaping the numbers for the next one. This post explains the multilayer perceptron layer by layer, why stacking layers helps, and how to count its parameters by hand and in PyTorch. 28 September 2026 · 8 min read Neural networks The universal approximation theorem explained (and what it does not promise) The universal approximation theorem says a neural network with one wide enough hidden layer can match any continuous curve as closely as you like. This post explains what that means, why it works, and the four things the theorem does not promise about training and real data. 28 September 2026 · 6 min read Neural networks Parameters vs hyperparameters in machine learning Parameters are the numbers a model learns from data, and hyperparameters are the settings you choose before training starts. This post explains the difference with a small PyTorch network, shows where each one lives in code, and how to pick hyperparameters with a validation set. 28 September 2026 · 6 min read Neural networks Activation functions roadmap: step, sigmoid, tanh, ReLU, Leaky ReLU, GELU An activation function is the small non-linear function each neuron applies to its output. This post goes through the common ones in the order they were invented, what each fixed, what each broke, and how to write every one in PyTorch. 22 September 2026 · 6 min read Neural networks Weight initialization explained: Xavier vs He (Kaiming) vs orthogonal Weight initialization is how a neural network's weights are set before training starts, and a bad choice can stop a deep network from learning at all. This post shows what goes wrong with zero, too large, and too small weights, and when to use Xavier, He (Kaiming), or orthogonal initialization in PyTorch. 29 September 2026 · 8 min read Neural networks Vanishing and exploding gradients, and how gradient clipping helps Vanishing and exploding gradients happen when the training signal shrinks to almost nothing or grows out of control as it passes back through a deep network. This post shows why both happen, how to measure them in PyTorch, and how ReLU, good initialization, and gradient clipping help. 29 September 2026 · 7 min read Neural networks Dying ReLU: what dead neurons are and how to fix them A dead ReLU neuron outputs zero for every input and stops learning, and a network can lose a large share of its neurons this way during training. This post explains why ReLU neurons die, how to measure the dead fraction in PyTorch, and how to prevent it with initialization, the learning rate, and Leaky ReLU. 29 September 2026 · 8 min read

Optimization

Optimization Machine learning optimizers explained: SGD, momentum, RMSProp, Adam, AdamW An optimizer is the rule that turns gradients into parameter updates. This post explains the five optimizers most models train with, in the order each one was invented to fix the last, and which one to pick. 17 September 2026 · 7 min read Optimization What is the Adam optimizer? Explained step by step Adam is the optimizer most deep learning models train with. This post explains what it does, why it works better than plain gradient descent, and when to use AdamW instead. 15 September 2026 · 5 min read Optimization Batch vs stochastic vs mini-batch gradient descent, and how to choose a batch size Batch, stochastic, and mini-batch gradient descent differ only in how many training examples each update looks at. This post explains what that changes, why mini-batch is the usual choice, and how to pick a batch size and adjust the learning rate with it. 30 September 2026 · 7 min read Optimization What is a learning rate, and how do you pick one? The learning rate is the number that most often decides whether a model trains well. This post explains what it does inside the update rule, how to read the three shapes of a loss curve, why good values differ between SGD and Adam, and a five-line test that finds a usable value. 16 September 2026 · 6 min read Optimization Learning rate schedules explained: warmup, cosine annealing, step decay, and ReduceLROnPlateau A learning rate schedule changes the step size of training as the run goes on, usually large at the start and small at the end. This post explains why a fixed learning rate falls short, how linear warmup, cosine annealing, step decay, and ReduceLROnPlateau work, and how to set each one up in PyTorch. 30 September 2026 · 12 min read Optimization Train, validation, and test sets: what each is for and how to split A dataset is usually split into three parts: a training set the model learns from, a validation set for making choices, and a test set for the final score. This post explains what each split is for, why the test set is kept out of model choices, and how to split data in PyTorch. 30 September 2026 · 7 min read Optimization How to save and resume training in PyTorch (checkpoints) A checkpoint is a file that stores a training run so it can be continued later. This post explains what to put in one, how to save and load it in PyTorch, why saving only the model weights is not enough to resume, and why most runs keep a latest and a best checkpoint. 1 October 2026 · 9 min read Optimization How to make PyTorch training reproducible: seeds, determinism, and what still varies Reproducible training means running the same code on the same data and getting the same result. This post explains where the randomness in a PyTorch run comes from, how to seed each source, how to seed a DataLoader, and which differences remain after seeding. 1 October 2026 · 8 min read

Generalization and regularization

Generalization and regularization Overfitting vs underfitting: how to tell which one you have, and how to fix it Overfitting is when a model memorizes its training data and fails on new data. Underfitting is when it cannot even fit the training data. This post shows how to read which one you have from the loss curves and what to change for each. 17 September 2026 · 6 min read Generalization and regularization How to read a loss curve: training vs validation loss A loss curve is a plot of a model's loss over the course of training. This post explains how to plot training and validation loss together, what a healthy curve looks like, and what it means when validation loss goes up while training loss keeps going down. 1 October 2026 · 10 min read Generalization and regularization Bias-variance tradeoff explained with pictures A model can be wrong on new data in two different ways, and the fixes for each pull in opposite directions. This post shows both with plots, how to tell them apart from your training and validation loss, and what to change for each. 22 September 2026 · 7 min read Generalization and regularization How much data do you need to train a model? The amount of training data a model needs depends on how large the model is, how accurate it has to be, and how noisy the data is. This post explains that relationship, the formal version from learning theory, and a test that tells you whether more data would help your model. 2 October 2026 · 8 min read Generalization and regularization The curse of dimensionality explained The curse of dimensionality is what happens to a dataset when you add input features without adding examples. This post shows why the same data covers less of the input space with each new feature, why distances between examples stop being useful, and what to do about it. 2 October 2026 · 7 min read Generalization and regularization Double descent explained Double descent is what happens when a model keeps growing after it can fit its training data exactly. Its error on new data rises to a peak and then falls a second time. This post explains where the peak sits, why very large models can do better than mid-sized ones, and how to reproduce the curve in a few lines of PyTorch. 2 October 2026 · 7 min read Generalization and regularization Regularization explained: L1, L2, dropout, and early stopping Regularization is a set of techniques that stop a model from memorizing its training data so it does better on new data. This post explains four common ones (L2 weight decay, L1, dropout, and early stopping), how each one works, and how to set them in PyTorch. 21 September 2026 · 6 min read Generalization and regularization Weight decay vs L2 regularization: why they differ under Adam Weight decay and L2 regularization both pull a model's weights toward zero, and with plain gradient descent they are the same thing. This post explains what each one does, why they stop being the same under Adam, and why AdamW is the usual fix. 3 October 2026 · 6 min read Generalization and regularization What is dropout and why does it work? Dropout is a regularization technique that randomly switches off part of a neural network during training so the model does better on new data. This post explains what dropout does on each step, why it reduces overfitting, how it behaves at test time, and how to use it in PyTorch. 3 October 2026 · 5 min read Generalization and regularization Label smoothing explained Label smoothing is a small change to classification training that stops a model from becoming 100% sure of its answers. This post explains what it changes in the targets, why that helps, how to set it in PyTorch, and when to leave it off. 3 October 2026 · 5 min read Generalization and regularization Hyperparameter tuning: grid search vs random search Picking the learning rate and layer sizes by trial and error wastes training runs. This post compares grid search, random search, and successive halving, with runnable PyTorch code and advice on which to use. 4 October 2026 · 7 min read

Evaluation

Evaluation Data leakage in machine learning: examples and how to prevent it A model that scores well during development can still fail on new data when its evaluation was contaminated. This post shows common examples of data leakage, how to spot it on a loss curve, and how to prevent it in PyTorch. 4 October 2026 · 7 min read Evaluation Cross-validation explained: k-fold, stratified, and when not to use it A score from one train/validation split can swing a lot depending on which examples landed where. This post explains k-fold and stratified k-fold cross-validation, builds both in plain PyTorch, and says when a single split or a time-ordered split is the better choice. 4 October 2026 · 5 min read Evaluation Precision, recall, and F1 score explained, with the confusion matrix Precision, recall, and F1 score measure how well a classifier finds the cases you care about, which accuracy can hide. This post explains the confusion matrix they come from, what each metric tells you, how the decision threshold trades one for the other, and how to compute them in PyTorch. 4 October 2026 · 11 min read Evaluation ROC curve and AUC explained, and when to use PR AUC instead The ROC curve and its AUC score tell you how well a classifier ranks positive examples above negative ones, without picking a threshold. This post explains how the curve is built, what an AUC of 0.5 or 0.9 means, why it can look good on rare-class data, and when to report PR AUC instead. 4 October 2026 · 7 min read Evaluation Regression metrics: MAE, RMSE, R², and MAPE MAE, RMSE, R² and MAPE are the usual numbers for saying how good a model that predicts prices, sales or other quantities is. This post explains what each one measures, how to compute them in PyTorch, and which one to report for your problem. 5 October 2026 · 8 min read Evaluation How to choose an evaluation metric for your model Accuracy, precision, recall, ROC AUC and R² each miss a different kind of failure. This post shows what each one misses, how to pick one primary metric from the cost of your model's mistakes, and which two or three metrics to track next to it. 5 October 2026 · 7 min read Evaluation Loss is NaN: the common causes and fixes A loss that turns into NaN usually comes from a log of zero, an exponential that overflows, or a division by zero. This post shows how to catch the NaN on the step it appears, find the layer that produced it, and fix each common cause in PyTorch. 5 October 2026 · 8 min read Evaluation How to measure model size and speed: parameters, FLOPs, latency, throughput, memory Accuracy says how good a model's predictions are, not whether it is small and fast enough to run. This post shows how to measure parameter count, FLOPs, latency, throughput, and memory in PyTorch, and which one to look at for which job. 6 October 2026 · 8 min read Evaluation ML model monitoring after deployment: data drift and when to retrain A model that tested well can get worse after launch because the data it sees keeps changing while the model stays the same. This post explains how that happens, how to notice it, and how to retrain and replace a live model safely in PyTorch. 6 October 2026 · 6 min read Evaluation A step-by-step workflow for improving a machine learning model When a model trains but its results are not good enough, a five-step loop tells you what to change next: pick a metric tied to the goal, build a small baseline, read the gap between training and test error, make one targeted change, and measure again. 6 October 2026 · 7 min read Evaluation My loss is not decreasing: a checklist A training loss that stays flat usually has one of a short list of causes. This checklist goes through them in a practical order: the data, the training loop, the learning rate, the loss function, initialization, and a one-batch test that separates a bug from a hard problem. 16 September 2026 · 7 min read