Lesson 5.1 · Stage 05: Deep learning and neural networks
Deep learning architectures and how networks are trained
The main neural network architectures, what each is used for, and the five layers of choices behind training any model.
Deep learning is machine learning with neural networks that have many layers. This page maps the architectures you will hear about and the choices that go into training one.
The architectures
| Architecture | What it is good at |
|---|---|
| Feedforward network (multilayer perceptron) | Tables of numbers; the building block inside larger networks |
| CNN (LeNet, AlexNet, VGG, ResNet, EfficientNet) | Images: it slides learned filters across a picture to find edges, textures and shapes |
| RNN, LSTM, GRU | Sequences such as text, speech and time series, read one step at a time |
| Transformer (encoder, decoder, encoder-decoder) | Text, code and now most other data; it uses attention to relate every part of the input to every other part |
| Vision transformer | Images, using the transformer design in place of convolutions |
| Autoencoder | Compressing data and spotting anomalies |
| VAE (variational autoencoder) | Generating new data from a learned, compressed space |
| GAN (generative adversarial network) | Generating images by training two networks against each other |
| Diffusion model | Generating images, audio and video by learning to remove noise step by step |
| Graph neural network (GCN, GAT) | Data shaped as a network of connected items, such as molecules or social graphs |
| Mixture of experts | Large models that route each input to a few specialised sub-networks |
| State-space models (Mamba) | Long sequences, as an alternative to transformers |
| Siamese network | Deciding whether two inputs are the same thing, such as two faces |
Transformers come in three shapes. Encoder-only models such as BERT read text to understand it. Decoder-only models such as GPT and Claude generate text one token at a time. Encoder-decoder models such as T5 read one sequence and write another, which suits translation.
Five layers of choices behind training
When people ask how many training algorithms exist, they are usually mixing five different kinds of choice.
1. The learning paradigm: where the signal comes from
- Supervised learning: labelled examples.
- Self-supervised learning: the data labels itself, as in predicting the next word or filling in a hidden word.
- Reinforcement learning: a reward signal for good behaviour.
- Others: semi-supervised learning, transfer learning, federated learning.
2. The architecture: what is being trained
One of the designs in the table above, or a classical model such as a decision tree.
3. The optimiser: how the weights are updated
This is what most people mean by “training algorithm”.
- Gradient descent family: batch, stochastic (SGD) and mini-batch gradient descent, SGD with momentum, Nesterov momentum.
- Adaptive methods: Adagrad, Adadelta, RMSprop, Adam, AdamW, Nadam, Adafactor, LAMB, Lion.
- Second-order methods: L-BFGS, conjugate gradient, natural gradient. These are rare for very large models.
AdamW is the usual choice for training large language models.
4. Post-training methods for language models
- Supervised fine-tuning: more training on examples of good answers.
- Learning from preferences: RLHF (reinforcement learning from human feedback) and DPO (direct preference optimisation).
- Distillation: training a small model to copy a large one.
5. Efficiency techniques
- LoRA and QLoRA: fine-tune a small set of added weights instead of the whole model.
- Adapters and prefix tuning: other ways to fine-tune cheaply.
- Mixed precision and quantisation: use smaller numbers to save memory and time.
- Gradient checkpointing: trade extra computation for lower memory use.
What comes next
See how these pieces fit together for one kind of model: How a large language model is trained.