Neural Networks & Deep Learning
Forward/backprop, activations, batch norm, vanishing gradients, CNN/RNN basics.
Start here
A is a stack of simple math steps, loosely inspired by brain neurons. Each unit (a ) does one thing: multiply inputs by , add a , pass the sum through a non-linear . Stack thousands of neurons in layers, chain the layers together, and you get a network — "deep" just means many layers.
- — run input through the layers to get a prediction.
- Loss — a number measuring how wrong that prediction was.
- — work backward from the loss, using the , to find how much each contributed to the error.
- — nudge every slightly in the direction that reduces the error.
This module is about that loop's mechanics — why non-linearity matters, which activation to use where, and what breaks (vanishing gradients, ) when you stack many layers.
Core threads
- : input → weighted sum + → activation → next layer. : applied layer by layer to compute ∂loss/∂, then updates .
- Why non-linearity: stacking linear layers without activation collapses to one linear function — non-linear activations (, , tanh) let the network approximate arbitrary functions (universal approximation).
- Activation functions: saturates () — used for binary output layers; is cheap and avoids saturation for positive inputs but can "die"; turns logits into a probability distribution for multi-class output.
- Vanishing/exploding gradients: deep networks multiply many small (or large) derivatives together → gradient shrinks (or blows up) across layers. Fixes: family, , residual connections, careful init (Xavier/He), gradient clipping.
- : normalizes layer inputs per → stabilizes and speeds up training, acts as mild regularizer.
- Architectures at intuition level: CNNs exploit spatial locality via shared filters (good for images); //GRU process sequences with memory (good for time series/text, now mostly replaced by Transformers for NLP).
Viva angle
Be ready to derive the on paper (σ(1-σ)), explain why we don't just use a huge single linear layer, and reason about a given train/val loss curve (this doubles as a Module 7 scenario question).
Visual reference
Forward pass through a network
Sigmoid function
Cheatsheet
Sigmoid
σ(x) = 1 / (1 + e⁻ˣ)
Squashes to (0, 1).
Sigmoid derivative
σ'(x) = σ(x)·(1 − σ(x))
Reuses the forward-pass output.
ReLU
max(0, x)
Cheap, no saturation for x > 0.
Neuron output
a = f(Σ wᵢxᵢ + b)
Weighted sum + bias, then activation f.
Activation cheat table
| Function | Range | Typical use |
|---|---|---|
| Sigmoid | (0, 1) | Binary output layer |
| Softmax | (0,1), sums to 1 | Multi-class output layer |
| ReLU | [0, ∞) | Hidden layers (default) |
| tanh | (−1, 1) | Hidden layers (older nets, RNN gates) |
Vanishing/exploding gradient fixes
| Problem | Fix |
|---|---|
| Vanishing gradient | ReLU family, batch norm, residual connections, He/Xavier init |
| Exploding gradient | Gradient clipping, careful init, lower learning rate |
- ▸ = compute prediction. = compute how each caused the error.
- ▸No anywhere = whole network collapses to one linear function.
- ▸ normalizes per , speeds up + stabilizes training.
- ▸ → spatial locality (images). / → sequences. → parallelizable long-range context.
Further study
Question bank
22 questionsExplain in your own words, as if to a non-expert.
Derive or state the of the .
Why do we need non-linear activation functions? What happens if a deep network uses only linear activations?
Compare , , and — where is each typically used?
What causes vanishing/exploding gradients in deep networks, and how do modern architectures fix it?
What does do and why does it help training?
Why are CNNs a good fit for image data instead of a plain fully-connected network?
Why were RNNs/LSTMs used for sequence data, and what problem made Transformers replace them for most NLP tasks?
What is an versus a versus an iteration?
What is and how does it prevent ?
What role does the play, and what happens if it's set too high or too low?
You plot train and validation loss. Train loss keeps dropping smoothly but validation loss drops then starts rising after 10. What's happening and what would you do?
How does the Adam optimizer work — how does it combine momentum and adaptive learning rates, and how is that different from plain ?
Why does initialization matter? What breaks with all-zero initialization, and what's the difference between Xavier/Glorot and He initialization?
Are decay and the same thing?
What is transfer learning and fine-tuning? When would you freeze layers versus unfreeze them?
What is data augmentation? Give examples for images and explain why it fights .
Why use a schedule instead of a fixed , and why does warmup help early in training?
What is used for in object detection, and what's the intuition behind anchor boxes?
What does smoothing do to the target distribution, and why can it help generalization?
Can you use and together? Does the ordering between them matter?
What is an , and how can one be used for fraud/anomaly detection without labeled fraud data?