Lesson 4 of 8 · The Idea
Why Now: Data, Compute, Algorithms
Why neural networks, invented in the 1950s, took off only after 2012: big labelled datasets like ImageNet, GPUs for fast maths, and better training methods.
- 7 min read
- Beginner
- Reviewed
- The short history of neural networks, from the perceptron to AlexNet
- How large labelled datasets changed what networks could learn
- Why GPUs suit neural networks so well
- Which new ideas made deep networks trainable
An old idea that waited
Neural networks are not new. Most of the core ideas are decades old:
| Year | What happened |
|---|---|
| 1958 | Frank Rosenblatt publishes the perceptron, a single artificial neuron that learns from examples. |
| 1969 | Marvin Minsky and Seymour Papert's book Perceptrons shows that a single-layer perceptron cannot learn simple patterns such as XOR. Interest in neural networks fades for years. |
| 1986 | David Rumelhart, Geoffrey Hinton and Ronald Williams show that backpropagation can train networks with hidden layers. |
| 1989 | Yann LeCun's convolutional network reads handwritten zip codes for the US Postal Service. |
| 1998 | The MNIST dataset of handwritten digits and the LeNet-5 network are published. |
| 2009 | The ImageNet dataset is released. |
| 2012 | AlexNet wins the ImageNet challenge by a huge margin, and deep learning takes off. |
| 2017 | The Transformer is published. It later powers ChatGPT and other large language models. |
So why did it take until 2012? Three things had to come together: data, compute and better algorithms.
Pillar 1: data
MNIST, the classic benchmark of the 1990s, has 70,000 small grayscale images of digits, each 28 × 28 pixels. That is enough for digits, but far too little for a network to learn what dogs, cars and chairs look like.
In 2009, a team led by Fei-Fei Li released ImageNet: more than 14 million photos from the web, labelled by hand into over 20,000 categories using the crowd-working site Amazon Mechanical Turk. Its yearly challenge used about 1.2 million images in 1,000 categories. For the first time, there was enough labelled data to train a network with tens of millions of parameters without it simply memorising the examples.
Pillar 2: compute
A CPU (central processing unit) has a few to a few dozen powerful cores that run complicated instructions one after another. A GPU (graphics processing unit) has thousands of simpler cores that run the same small calculation on lots of numbers at once. It was built to work out the colour of millions of pixels for video games.
The core calculation of a neural network is the same kind of work: multiply many inputs by many weights and add them up, over and over. That is matrix multiplication, and GPUs are built for it.
In 2012, Alex Krizhevsky, Ilya Sutskever and Geoffrey Hinton trained AlexNet on two gaming GPUs. It cut the top-5 error on the ImageNet challenge (the share of images where the right answer was not among the network's five guesses) from 26% for the next-best entry to about 15%.
You can feel the difference between one-at-a-time and many-at-once maths in your browser. NumPy runs the same multiply-and-add as optimised code over whole arrays:
import time
import numpy as np
size = 200_000
rng = np.random.default_rng(0)
weights = rng.random(size)
inputs = rng.random(size)
start = time.perf_counter()
total = 0.0
for i in range(size):
total += weights[i] * inputs[i]
loop_ms = (time.perf_counter() - start) * 1000
start = time.perf_counter()
for _ in range(100):
fast = np.dot(weights, inputs)
numpy_ms = (time.perf_counter() - start) * 1000 / 100
print("same answer:", bool(np.isclose(total, fast)))
print(f"Python loop: {loop_ms:.1f} ms")
print(f"NumPy dot: {numpy_ms:.3f} ms")
print(f"NumPy was about {loop_ms / numpy_ms:.0f} times faster")Your numbers will differ from run to run and from computer to computer, but the gap is always large. A GPU widens it much further by spreading the work over thousands of cores.
Pillar 3: better algorithms
Data and hardware were not enough. Deep networks were also hard to train because of the vanishing gradient problem.
During training, a learning signal travels backwards through the network, and at each layer it is multiplied by the slope of that layer's activation function. The popular sigmoid function has a slope of at most 0.25. Multiply by 0.25 ten times and almost nothing is left, so the early layers barely learn.
Several ideas fixed this and other problems:
- ReLU activation: its slope is exactly 1 for every positive input, so the signal does not shrink there.
- Better starting weights: scaling the random starting values to the size of each layer keeps signals from shrinking or exploding.
- Dropout: randomly switching off some neurons during training, so the network cannot rely on any single one. This reduces overfitting.
- Batch normalisation: rescaling the numbers between layers to keep training stable.
- Residual connections (ResNet, 2015): shortcuts that let the signal skip layers, making networks with over 100 layers trainable.
- Adam: an optimiser that adapts the step size for each weight.
- The Transformer (2017): a design that processes all the words of a text in parallel, which made very large language models practical.
Common mistakes
See the vanishing gradient problem in numbers. Work out how much of the learning signal can survive a stack of sigmoid layers, compared with ReLU layers.
# The learning signal is multiplied by each layer's slope on its way back. # A sigmoid's slope is at most 0.25. A ReLU's slope is 1 for positive inputs. # For 5, 10 and 20 layers, print the largest signal left after that many # sigmoid layers (format it with :.2e) and after that many ReLU layers. # Output must be exactly: # 5 layers: sigmoid 9.77e-04, relu 1 # 10 layers: sigmoid 9.54e-07, relu 1 # 20 layers: sigmoid 9.09e-13, relu 1
Which three things came together to make deep learning take off around 2012?
Summary
- The main ideas behind neural networks are decades old; deep learning took off around 2012.
- Data: ImageNet gave networks millions of labelled examples.
- Compute: GPUs do the many multiplications of a network in parallel.
- Algorithms: ReLU, dropout, residual connections and better optimisers made deep networks trainable.
Next: what happens inside a single neuron, and how neurons form layers.
Finished reading? Tick it off to track your progress.