Perceptrons and Multilayer Networks
From a single neuron to stacked layers: weights, biases, forward passes and why depth plus nonlinearity makes networks expressive.
Intermediate · about 5 hours · difficulty 3/5
Learn first: Logistic Regression and Linear Classifiers, Calculus and Gradients
A neuron computes a weighted sum of its inputs plus a bias, then applies a nonlinear activation. A multilayer perceptron (MLP) stacks layers of neurons so each layer transforms the previous one's output.
Core ideas
- The perceptron is a linear classifier; logistic regression is essentially a single neuron with a sigmoid.
- Layers as matrix multiplies:
h = activation(W @ x + b). A batch of inputs is a matrix, so a layer is one matrix product. - Why nonlinearity: without it, stacked linear layers collapse into one linear layer.
- Universal approximation: a wide enough network can approximate any function, but depth makes learning efficient.
- Representation learning: hidden layers learn features automatically instead of you engineering them.
When neural networks win
Unstructured data (images, text, audio) and very large datasets. On small or medium tabular data, gradient boosting still usually wins.
Good enough to move on when you can implement the forward pass of a two-layer MLP in NumPy and explain every shape along the way.
Key concepts
- Perceptron
- Neurons, weights and biases
- Layers as matrix multiplication
- Why nonlinearity matters
- Universal approximation
Mini project
Build a two-layer MLP forward pass in NumPy and experiment in TensorFlow Playground to find the smallest network that separates the spiral dataset.
Check yourself
Why does a network of ten linear layers with no activations have the same power as a single linear layer?
Free resources
- Neural Networks series (3Blue1Brown)
- TensorFlow Playground (TensorFlow)
- Dive into Deep Learning (d2l.ai)