Part 4 cheat sheet: deep learning
Neural networks and the families built from them.
One neuron
- Multiply each input by its weight, add them and a bias, then bend the result with an activation function.
- ReLU keeps positive numbers and turns negative ones into 0.
- A network is thousands of these stacked in layers.
output = ReLU(weight1 x input1 + weight2 x input2 + bias)
Learn more: Neural networks in plain words
Training a network
- Forward pass: compute and remember each step.
- Backward pass: hand out blame with the chain rule to get a gradient for every weight.
- The optimiser nudges the weights; a batch is a group of examples; an epoch is one pass over the data.
Learn more: Backpropagation and automatic differentiation · Training deep networks well
Training well
- Dropout switches random neurons off while training so none is relied on too much.
- Stop early when validation loss stops improving.
- Normalise, use a sensible learning-rate schedule, clip huge gradients.
Learn more: Training deep networks well
Images
- A convolution slides a small filter over the image; early filters find edges, later ones shapes.
- Classification: what is in it. Detection: what and where. Segmentation: which pixels.
- Transfer learning: start from a pretrained model.
Learn more: Computer vision: classification, detection and segmentation
Text and sequences
- Tokens become ids, then embeddings: lists of numbers where similar meanings sit close together.
- An RNN reads one step at a time and carries a memory forward; early words fade.
Learn more: Text and sequences: tokens, embeddings and RNNs
Transformers
- Every word makes a query, a key and a value; attention mixes values by weights that add up to 1.
- A causal mask hides later words in decoders.
- A block is attention, then a small network, each with shortcuts and normalisation.
- Encoder-decoder models add cross-attention.
new value = weight1 x value1 + weight2 x value2 (weights add up to 1)
Learn more: Transformers and attention
Generative models
- Autoencoder: squeeze and rebuild.
- GAN: a forger against a detective.
- Diffusion: add noise step by step, learn to undo each step, then generate from noise.
Learn more: Generative models: autoencoders, GANs and diffusion · More generative models, VAEs, flows and diffusion in detail
Graphs, speech, reinforcement
- Graph networks pass messages between neighbours.
- Speech models read spectrograms: sound over time.
- Reinforcement learning: act, get a reward and a new state, repeat for the most total reward.
Learn more: Graph neural networks: learning from connections · Speech and audio: recognition and text-to-speech · Reinforcement learning