VivaPrep
← All modules

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

inputhiddenoutput
Every input node connects to every hidden node; every hidden node connects to every output node. Each connection has its own weight — that's what training adjusts.

Sigmoid function

10x
Any real number in, a value between 0 and 1 out. Far from zero, the curve flattens — that flat region is where gradients vanish.

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

FunctionRangeTypical use
Sigmoid(0, 1)Binary output layer
Softmax(0,1), sums to 1Multi-class output layer
ReLU[0, ∞)Hidden layers (default)
tanh(−1, 1)Hidden layers (older nets, RNN gates)

Vanishing/exploding gradient fixes

ProblemFix
Vanishing gradientReLU family, batch norm, residual connections, He/Xavier init
Exploding gradientGradient 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 questions
#1Mediumbackpropcore

Explain in your own words, as if to a non-expert.

#2Mediummathactivations

Derive or state the of the .

#3Easyactivations

Why do we need non-linear activation functions? What happens if a deep network uses only linear activations?

#4Mediumactivations

Compare , , and — where is each typically used?

#5Hardoptimizationdeep-networks

What causes vanishing/exploding gradients in deep networks, and how do modern architectures fix it?

#6Mediumregularizationnormalization

What does do and why does it help training?

#7Mediumcnn

Why are CNNs a good fit for image data instead of a plain fully-connected network?

#8Mediumrnnsequences

Why were RNNs/LSTMs used for sequence data, and what problem made Transformers replace them for most NLP tasks?

#9Easytraining

What is an versus a versus an iteration?

#10Easyregularization

What is and how does it prevent ?

#11Mediumoptimization

What role does the play, and what happens if it's set too high or too low?

#12Hardscenariodiagnosis

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?

#13Mediumoptimization

How does the Adam optimizer work — how does it combine momentum and adaptive learning rates, and how is that different from plain ?

#14Mediuminitializationtraining

Why does initialization matter? What breaks with all-zero initialization, and what's the difference between Xavier/Glorot and He initialization?

#15Hardregularizationoptimization

Are decay and the same thing?

#16Mediumtransfer-learningfine-tuning

What is transfer learning and fine-tuning? When would you freeze layers versus unfreeze them?

#17Easyregularizationcnn

What is data augmentation? Give examples for images and explain why it fights .

#18Mediumoptimizationtraining

Why use a schedule instead of a fixed , and why does warmup help early in training?

#19Mediumcnnobject-detection

What is used for in object detection, and what's the intuition behind anchor boxes?

#20Mediumregularizationtraining

What does smoothing do to the target distribution, and why can it help generalization?

#21Hardregularizationnormalization

Can you use and together? Does the ordering between them matter?

#22Mediumautoencoderanomaly-detectionfintechbKash

What is an , and how can one be used for fraud/anomaly detection without labeled fraud data?