NeuralNetworks101
60-minute intensive/ Beginner to intermediate/ Framework-agnostic

How a network
learns to be less wrong

A neural network is not magic and not a brain. It is a stack of multiplications, a way of measuring error, and a rule for nudging numbers downhill. This course walks the full loop — signal forward, error backward — until every piece has a job you can name.

forward pass — signal, weights, prediction backward pass — error, gradients, updates this colour logic holds for the whole course
~60 minRead and practice time
9 modules+ 5 interactive labs
10 questionsKnowledge check with answers

What you'll cover

  1. What a neural network actually is
  2. The neuron: weights, bias, activation
  3. Layers, depth, width and parameters
  4. Forward propagation: making a prediction
  5. Loss: putting a number on wrong
  6. Backpropagation and gradient descent
  7. Training in practice
  8. Beyond the basic net: CNNs, RNNs, transformers
  9. Best practices and common pitfalls
  10. Knowledge check (10 questions)
  11. Glossary
  12. Sources and further reading
Module 16 min read

What a neural network actually is

A neural network is a function. You hand it numbers, it hands numbers back. What makes it interesting is that the function contains thousands or billions of adjustable dials — called parameters — and there is a mechanical procedure for turning those dials so the outputs get closer to the answers you wanted.

That is the entire idea. Everything else in this course is detail about the shape of the function (modules 2–4), how you measure "closer" (module 5), and how you turn the dials (modules 6–7).

The one-sentence version

prediction = f(input, parameters)  →  error = how far off  →  adjust parameters  →  repeat

Traditional software is written rule by rule: a human decides that if the email contains "wire transfer urgently" it goes to spam. A neural network is not written that way. You supply examples — thousands of emails already labelled spam or not — and the training procedure discovers the weighting of features that separates them. You specify the architecture and the objective; the data specifies the rules.

DimensionClassic programmingNeural network
You writeThe rules, explicitlyThe architecture and the objective
You supplyInput dataInput data and labelled examples of the right answer
OutputDeterministic resultA learned approximation, usually with a confidence
Fails byThrowing an errorBeing confidently wrong on data unlike its training set
Best whenRules are known and stableRules are fuzzy, visual, linguistic, or too numerous to write

Why "neural"

The vocabulary is borrowed from biology and the borrowing is loose. A biological neuron fires a spike when incoming signals cross a threshold; an artificial neuron computes a weighted sum and passes it through a smooth function. The resemblance is a historical metaphor, not a claim about the brain. It is more useful to think of a network as a very large, very flexible curve-fitter than as a digital mind.

The claim that makes it all work. The universal approximation theorem says a network with even one sufficiently wide hidden layer can approximate essentially any continuous function to arbitrary precision. It guarantees a good set of parameters exists. It says nothing about whether training will find it — which is why the rest of this course is mostly about training.

"But what is a neural network? | Chapter 1, Deep learning" — 3Blue1Brown. Open on YouTube ↗

Module 27 min read

The neuron: weights, bias, activation

One artificial neuron does three things in order. It weights each incoming number, adds a bias, and passes the total through an activation function. That is the whole unit, and a network is nothing but many copies of it wired together.

z = (x₁·w₁) + (x₂·w₂) + … + b     output = g(z)
  • Inputs (x) — the numbers arriving, either raw features or activations from the previous layer.
  • Weights (w) — one per input, learned. A weight is importance: large positive means "this input pushes my output up", negative means it pushes down, near zero means "ignore it". Weights are where the knowledge lives.
  • Bias (b) — a learned offset added regardless of input. It shifts the threshold at which the neuron becomes active, so a neuron isn't forced to output zero when its inputs are zero.
  • Activation g(z) — a fixed, non-linear function applied to the sum.

Why the activation function is non-negotiable

Without it, every neuron is a linear function, and stacking linear functions produces… another linear function. A hundred layers of pure multiplication collapse algebraically into a single equivalent layer, capable only of drawing straight lines. Non-linearity is what buys you depth. It is the ingredient that lets layers compose into curves, corners and concepts.

ActivationOutput rangeBehaviour and typical use
ReLU
max(0, z)
0 → ∞Cheap, fast, the default for hidden layers. Negative inputs output exactly zero, which can leave neurons permanently "dead".
Leaky ReLU−∞ → ∞Lets a small slope through for negatives, curing dead neurons at almost no cost.
Sigmoid0 → 1Squashes to a probability. Fine for a binary output layer; poor in deep hidden layers because its gradient vanishes at the extremes.
Tanh−1 → 1Zero-centred sigmoid; better behaved than sigmoid in hidden layers but shares the saturation problem.
Softmax0 → 1, sums to 1Output layer for multi-class problems: turns raw scores into a probability distribution over classes.
Lab 01 · single neuron

Turn the dials on one neuron

Move the weights and bias and watch the weighted sum and the activation respond. Try setting a weight to zero — the neuron stops listening to that input entirely.

Weights are not knowledge you can read. A single weight rarely means anything on its own. Meaning lives in patterns across thousands of them, which is why interpreting a trained network is a research field rather than a lookup.
Module 37 min read

Layers, depth, width and parameters

Neurons are organised into layers, and layers into three roles:

  • Input layer — not really neurons, just the entry point. Its size is fixed by your data: 784 for a 28×28 greyscale image, one per column for a spreadsheet.
  • Hidden layers — everything in between, where representation happens. Their number and size are yours to choose.
  • Output layer — sized by the task: one neuron for a price or a yes/no, ten for ten digit classes.

In a fully connected (dense) network, every neuron in a layer receives every output from the layer before. Depth is how many layers you stack; width is how many neurons sit in each.

What depth actually buys

Each layer transforms the representation handed to it. In a vision network, early layers respond to edges and gradients, middle layers to textures and parts, later layers to whole objects. Nobody assigns those jobs — the hierarchy emerges because a deep network is rewarded for reusing simple features to build complicated ones. Depth is compositional efficiency: a deep narrow network often expresses with hundreds of parameters what a shallow wide one needs millions to match.

Counting parameters

Between two adjacent layers, every connection is one weight, and every neuron in the receiving layer adds one bias:

params(layer) = (inputs × neurons) + neurons

Parameter count is the honest measure of a model's size. It drives memory, training time, and how much data you need before the model starts memorising instead of generalising.

Lab 02 · architecture

Build a network and watch the cost

Add hidden layers and neurons. The diagram redraws and the parameter count updates. Notice how widening one middle layer costs far more than adding a narrow one.

Start small. A sensible default is one or two hidden layers a little wider than your input, then grow only when the model is clearly underfitting. Capacity you don't need is capacity that memorises your training set.
Module 46 min read

Forward propagation: making a prediction

Forward propagation is the act of pushing one example through the network from input to output. Layer by layer: multiply by the weights, add the biases, apply the activation, hand the result on. In production this is the whole job — a trained model doing inference is only ever running a forward pass.

Written for a whole layer at once, it is a single matrix multiplication, which is exactly why GPUs matter:

a⁽ˡ⁾ = g( W⁽ˡ⁾ a⁽ˡ⁻¹⁾ + b⁽ˡ⁾ )

Every value produced along the way is an activation. Hold on to them — backpropagation in module 6 needs them.

Lab 03 · forward pass

Step through a 2-2-1 network

A tiny network with fixed weights predicts whether a customer will convert, from two inputs. Step through the arithmetic one stage at a time.

Press Next step to load the inputs.
Inference is cheap, training is expensive. A forward pass touches each parameter once. Training runs that forward pass, then a backward pass, then an update — over every example, for many epochs. It is the same arithmetic, repeated a very large number of times.
Module 56 min read

Loss: putting a number on wrong

The network has made a prediction. Now you need a single number saying how bad it was, because "improve" is meaningless until "worse" is measurable. That number comes from a loss function (the error on one example) averaged into a cost function (the error across a batch or the whole dataset).

The loss function is where you encode what you actually care about. Change it and you change what the network optimises for — it is the most consequential design choice after the data itself.

TaskUsual lossWhat it punishes
Regression (predict a number)Mean squared errorSquared distance from the target — big misses hurt disproportionately, so it is sensitive to outliers.
Regression, noisy dataMean absolute error / HuberDistance without the squaring, so a few wild outliers don't dominate training.
Binary classificationBinary cross-entropyConfident wrong answers, harshly. Predicting 0.99 for a negative case is punished far more than predicting 0.6.
Multi-classCategorical cross-entropyProbability mass placed on the wrong class, paired with a softmax output.

The loss landscape

Now hold the training data fixed and imagine sweeping every parameter across every possible value, recording the cost each time. The result is a surface in a space with one dimension per parameter — millions of dimensions, but the intuition survives in three. Hills are bad parameter settings, valleys are good ones. Training is the search for a low valley, and the tool for that search is slope.

Loss is a proxy, never the goal. You care about conversions, diagnoses or click-through; the model only ever sees the number you told it to minimise. Any gap between the two is where a model quietly optimises for the wrong thing — and it will find that gap.

"Gradient descent, how neural networks learn | Chapter 2, Deep learning" — 3Blue1Brown. Open on YouTube ↗

Module 68 min read

Backpropagation and gradient descent

Two ideas often mashed into one word. Keep them apart:

  • Backpropagation answers which direction. It computes the gradient — how much the loss would change if each individual parameter changed a little.
  • Gradient descent answers what to do about it. It takes that gradient and steps every parameter a small distance in the downhill direction.

Gradient descent in one line

w ← w − η · ∂L/∂w    (η = learning rate)

The derivative says which way is uphill; the minus sign turns you around; the learning rate decides how far you commit. That is the entire update rule, applied to every weight and bias in the network, over and over.

How backpropagation gets the gradient

A network is a chain of nested functions, and calculus already has a rule for differentiating those: the chain rule. Backpropagation applies it in reverse, from the loss backwards to the input, reusing each layer's result as it goes.

  1. Run a forward pass and keep every activation.
  2. At the output, compute how much the loss changes with the prediction.
  3. Push that sensitivity back through the output layer's activation and weights to get the gradient for those weights — and the error attributable to the layer below.
  4. Repeat layer by layer to the input. Each layer's blame is computed from the blame of the layer above it.
  5. Update every parameter using the rule above.

The efficiency is the point. Estimating each gradient by nudging parameters one at a time would take one forward pass per parameter — billions of passes. Backpropagation gets all of them in a single backward sweep, which is the algorithmic breakthrough that made deep learning feasible at all.

Lab 04 · gradient descent

Roll downhill, and learn what step size costs

A single parameter, a bumpy loss curve. Step and watch the descent. Then push the learning rate past ~0.9 and watch the same algorithm blow up — the classic failure mode.

Local minima, saddles, and why it works anyway

That curve has two valleys, and descent lands in whichever one it started nearest. Real loss landscapes have vastly more, which sounds fatal and mostly isn't: in very high dimensions, points where every direction curves upward are rare, most flat spots are saddles that momentum escapes, and the many decent minima tend to perform about as well as each other. You are not looking for the global minimum. You are looking for a low valley that generalises.

Optimisers: gradient descent with better habits

  • Stochastic gradient descent (SGD) — update on small random batches instead of the whole dataset. Noisier steps, far faster, and the noise itself helps escape shallow traps.
  • Momentum — accumulate a running velocity so the path keeps rolling through flat regions and dampens side-to-side oscillation.
  • Adam — adapts a separate effective step size per parameter using running estimates of gradient mean and variance. The pragmatic default for most work.
Vanishing and exploding gradients. Multiply many small numbers through a deep chain and the signal reaching early layers shrinks to nothing; multiply many large ones and it detonates. This is why saturating activations lost hidden layers to ReLU, and why normalisation layers, careful initialisation, residual connections and gradient clipping exist.

"What is backpropagation really doing? | Chapter 3, Deep learning" — 3Blue1Brown. Open on YouTube ↗

Module 78 min read

Training in practice

The mechanics are settled. What remains is the craft: the choices that decide whether a technically correct network is actually useful.

Split the data before you touch it

  • Training set (~70%) — the examples the model learns from.
  • Validation set (~15%) — held out to tune architecture, learning rate and stopping point. The model never trains on it, but you make decisions from it, so it slowly leaks into your choices.
  • Test set (~15%) — touched once, at the end. It is your only honest estimate of real-world performance.

Also scale your inputs. Features on wildly different ranges — age 0–100 next to income 0–500,000 — distort the loss landscape into a steep ravine that gradient descent struggles to navigate. Standardising or normalising is a one-line fix that routinely rescues a "broken" model.

Epochs, batches and steps

TermMeaningPractical note
BatchThe group of examples processed before one parameter update32–256 is typical. Larger is smoother and faster per epoch, but needs more memory and can generalise slightly worse.
Step / iterationOne batch: forward, backward, updateSteps per epoch = examples ÷ batch size.
EpochOne full pass over the training setStop when validation loss stops improving, not at a round number.
Learning rateStep size for each updateThe single most important hyperparameter. Tune it first, on a log scale, and consider decaying it over training.

Overfitting and underfitting

The core tension of all machine learning. Underfitting means the model is too simple to capture the real pattern — it is wrong on training and test data alike. Overfitting means it has enough capacity to memorise the training examples including their noise, so training loss keeps dropping while validation loss turns and climbs. That divergence is the signal to watch.

Lab 05 · capacity

Find the sweet spot between too simple and too clever

Blue points are training data, red are held-out validation points. Raise model capacity and watch the fitted curve start chasing noise — training error falls while validation error turns and rises.

Regularisation: the tools that fight overfitting

  • More and better data — always the strongest remedy. Data augmentation (crops, flips, noise, paraphrases) manufactures variety for free.
  • Early stopping — halt when validation loss stops improving, and keep the best checkpoint. Cheap and effective.
  • Dropout — randomly switch off a fraction of neurons each training step so no unit can rely on a specific partner. Disabled at inference.
  • Weight decay (L2) — add a penalty on large weights, preferring smoother functions over spiky memorisation.
  • Batch / layer normalisation — stabilise the distribution of activations between layers; speeds training and adds mild regularisation.
  • Reduce capacity — the underrated option. A smaller model that generalises beats a bigger one that memorises.
Read the two curves together. High training error means underfitting: add capacity or train longer. Low training error with high validation error means overfitting: add data or regularisation. Both curves low and close together means you're done — go and check the test set, once.
Module 86 min read

Beyond the basic net: CNNs, RNNs, transformers

Everything so far describes a multilayer perceptron — fully connected layers, no assumptions about the data. It works, but it treats an image as an unordered list of pixels and a sentence as an unordered bag of words. The famous architectures are all variations that build a structural assumption into the wiring itself.

ArchitectureBuilt-in assumptionTypical use
MLP (dense)None — every input relates to every otherTabular data, small feature sets, final layers of larger models
CNN (convolutional)Nearby values relate, and a useful pattern is useful anywhere in the inputImages, video, audio spectrograms, anything on a grid
RNN / LSTMOrder matters; carry a memory of what came beforeSequences and time series — largely superseded by transformers for language
TransformerAny element may relate to any other; learn which, in parallelLanguage, code, increasingly vision and audio; the basis of modern LLMs
AutoencoderCompress to a bottleneck, then reconstructDimensionality reduction, denoising, anomaly detection, embeddings

Convolutional networks, briefly

Instead of a weight per pixel, a CNN learns a small filter — say 3×3 — and slides it across the whole image. Two consequences follow. The parameter count collapses, because one filter is reused everywhere rather than relearned per position. And the feature becomes translation-invariant: an edge detector trained on the top-left corner works in the bottom-right too. Stack these layers and you get the edges → textures → parts → objects hierarchy from module 3.

Transformers and attention

A transformer processes a whole sequence at once and uses attention to let every element look at every other and weigh how relevant each one is to it. In "the trophy didn't fit in the case because it was too big", attention is the mechanism that lets "it" bind to "trophy". Because there is no left-to-right recurrence, the computation parallelises across a sequence — which is precisely what made training on internet-scale text practical.

Same engine, different chassis. Every architecture here is still weights, biases, activations, a loss, and backpropagation. What changes is which connections exist and which weights are shared. Learn the engine once and new architectures become variations rather than new subjects.

"But what is a GPT? Visual intro to transformers | Chapter 5, Deep learning" — 3Blue1Brown. Open on YouTube ↗

Module 94 min read

Best practices and common pitfalls

Practices worth making habits

  • Establish a dumb baseline first — a linear model, or predicting the average. If the network can't beat it, the problem is your data or framing, not your architecture.
  • Split the data before any exploration, and keep the test set sealed until the end.
  • Scale and clean inputs before blaming the model. Most "the network won't learn" tickets are data problems.
  • Start with the smallest architecture that could work, and grow only in response to underfitting.
  • Tune the learning rate first, on a log scale (0.1, 0.01, 0.001). It outranks every other hyperparameter.
  • Deliberately overfit a handful of examples as a smoke test. If the model can't memorise ten rows, the pipeline is broken.
  • Plot training and validation loss every run. The shape of those two curves diagnoses nearly everything.
  • Set random seeds and log hyperparameters, so a good result can be reproduced tomorrow.
  • Evaluate with metrics that match the stakes — accuracy is meaningless on a 99:1 class split, where precision, recall and a confusion matrix are not.

Pitfalls that catch capable people

  • Data leakage — scaling or imputing across the full dataset before splitting, or including a feature that encodes the answer. Produces beautiful validation scores and a model that fails in production.
  • Judging on the test set repeatedly — every peek turns it into a second validation set and inflates your estimate.
  • Chasing architecture before fixing data — more labels and cleaner labels beat a fancier model almost every time.
  • Unbalanced classes ignored — 99% accuracy on a 99% negative dataset is a model that learned to say "no".
  • Learning rate left at default — too high and loss oscillates or becomes NaN; too low and it crawls, or stalls in the first flat spot it meets.
  • Training loss watched alone — it only ever goes down. Validation loss is the one that tells the truth.
  • Assuming yesterday's distribution — the world drifts. Monitor live performance and plan to retrain.
  • Treating the output as an explanation — a confidence score is not a reason. Where decisions affect people, budget for interpretability and human review.
The throughline. A network turns inputs into predictions through weighted sums and non-linearities; a loss function scores those predictions; backpropagation assigns blame; gradient descent nudges every parameter downhill; and regularisation keeps the result general rather than memorised. Hold those five together and any architecture you meet becomes a variation on something you already understand.
Knowledge check~6 min

Test yourself — 10 questions

Pick one answer per question, then score. Explanations appear with your result.

0 / 10
Reference16 terms · skim as needed

Glossary

Neuron (unit)
The basic component: computes a weighted sum of its inputs plus a bias, then applies an activation function.
Weight
A learned multiplier on one input, encoding how much that input matters. Weights hold what the network has learned.
Bias
A learned constant added to a neuron's weighted sum, shifting the point at which it activates.
Activation function
A fixed non-linear function (ReLU, sigmoid, tanh, softmax) applied to a neuron's sum. Without it, depth adds nothing.
Parameter
Any value learned during training — all weights and biases. Distinct from a hyperparameter, which you choose.
Hyperparameter
A setting fixed before training: learning rate, batch size, layer count, dropout rate.
Forward propagation
Passing an input through the network layer by layer to produce a prediction. Also called inference.
Loss / cost function
The measure of how far predictions are from targets — loss per example, cost averaged over a batch or dataset.
Gradient
The vector of partial derivatives of the loss with respect to every parameter: which way is uphill, and how steeply.
Backpropagation
The reverse-mode chain-rule algorithm that computes all those gradients in one backward sweep.
Gradient descent
The update rule that moves each parameter a small step against its gradient, repeatedly.
Learning rate (η)
How far to step on each update. Too high diverges, too low crawls or stalls.
Epoch / batch / step
An epoch is one full pass over the training data; a batch is the group processed before one update; a step is one such update.
Overfitting
Learning the training set including its noise, so validation performance degrades while training performance keeps improving.
Regularisation
Any technique that trades a little training accuracy for better generalisation: dropout, weight decay, early stopping, augmentation.
Vanishing / exploding gradient
Gradients shrinking to nothing or blowing up as they propagate through many layers, stalling or destabilising training.
SourcesAll consulted August 2026

Sources and further reading