Core idea

A deep network learns a sequence of feature transformations. A CNN uses shared filters to find patterns across space. An RNN uses a shared state-update rule to carry information across time. Each architecture still learns by predicting an output, measuring a loss and updating weights.

Use the activation and backpropagation rules from Chapter 3 and Chapter 4. Start here with what depth adds, then study how training is controlled. Leave time to draw and calculate one forward pass in each architecture. CT2 Set A asks about RNNs, regularisation and batching. CT2 Set B asks about depth, optimisation and a complete CNN.

1. Deep feedforward networks

A deep feedforward network has multiple learned layers between its input and output. In a forward pass, each layer transforms the previous layer’s representation. As in Chapter 4, with , one hidden layer computes . Information travels from input toward output in this graph.

Layers can build up representations. In image recognition, early layers may respond to edges, later layers combine edges into shapes, and higher layers combine shapes into object features. Those features are learned through the task loss. Nonlinear activations matter because a stack of affine layers alone simplifies to a single affine transform.

PYQ — CT2 Set B 2026, Q2(a) · What does “deep” mean? (1 mark)

Original question from the paper

Model answer

A deep neural network has multiple successive learned layers. Each layer transforms the representation produced by the preceding one, so later layers can combine simple features into more complex ones. For example, an image model can combine edges into shapes and shapes into object features.

Benefits and practical issues

Depth can reduce the need to design features by hand and can represent complex relationships in images, speech and text. Training often needs substantial data or a suitable pretrained model, as well as more memory and compute. Deep networks can overfit and can be difficult to interpret. Repeated multiplication during backpropagation can cause gradients to shrink or grow sharply, especially with saturated activations or poor initialisation. Appropriate initialisation, input scaling and nonsaturating activations such as ReLU help.

Batch normalisation can help stabilise training by normalising layer activations using batch statistics before a learned rescaling and shift. At inference it typically uses running estimates collected during training.

PYQ — 2021–22 semester, Q8 · Benefits and limitations of deep learning (2 marks)

Original question from the paper

Model answer

Advantages. Deep networks learn useful features directly from raw data and can model complex patterns in images, speech and text.

Disadvantages. They can require substantial data and computing power to train, and their predictions can be difficult to interpret because they arise from many interacting layers.

2. Training, validation, and gradient updates

A typical training step is forward pass → loss → backpropagation → parameter update. Backpropagation calculates the gradients. The optimiser decides how to use those gradients to update the parameters.

SplitUse
TrainingFit the model weights and any learned preprocessing
ValidationChoose hyperparameters, compare architectures, and select a checkpoint
TestEstimate final performance on held-out examples

An epoch processes the whole training set once. A batch contains the examples used for one update. With training examples and batch size , one epoch contains five updates. If the last partial batch is kept, use .

PYQ — CT2 Set A 2026, Q2(c) · Batch GD versus SGD (3 marks)

Original question from the paper

Model answer

Batch gradient descent (BGD) computes the mean gradient of the loss over all training examples at the current weights. It makes one update per epoch. Its gradient is exact for the training set, but each update can be expensive on a large dataset.

Stochastic gradient descent (SGD) computes the gradient from one sampled training example at a time and updates the weights immediately. A single update is cheaper and, for one pass through all examples, SGD makes updates. The gradient varies with the sampled example, so successive updates can be noisier.

For example, with examples, BGD uses all to calculate one update. SGD can process the same examples in shuffled order and make successive updates, each at the latest weights.

Worked example — one epoch by three methods

Let and , so the gradient for each example is . Start at with and process in that order.

  • Batch GD. The gradients at are . Their mean is , giving in one update.
  • SGD. Each example uses the current weight. The weights progress . For example, the second gradient is .
  • Mini-batch GD. The first two gradients average , giving . The last example has gradient , giving .

PYQ — CT2 Set B 2026, Q2(a) · Optimisation techniques (6 marks)

Original question from the paper

Model answer

Optimisation adjusts a network’s weights to reduce its training objective. Backpropagation supplies the gradient at step , and the optimiser uses that gradient to determine the next update.

  1. Gradient descent. Update the weights by , where is the learning rate. Using a mini-batch gives a cheaper estimate of the full gradient and allows efficient parallel computation.
  2. Momentum. Maintain a running direction and update by . Gradients pointing repeatedly in the same direction build up momentum, while alternating components partly cancel. This reduces oscillation and can speed progress.
  3. AdaGrad. Accumulate the squared gradients for each parameter and divide its step by the square root of that accumulation plus a small stabilising term. Parameters that receive frequent large gradients get smaller steps. Because the accumulation only grows, later steps can become very small.
  4. RMSProp. Replace AdaGrad’s cumulative sum with a decaying average of squared gradients. Recent gradients determine the scale, so the step size can respond when gradient magnitudes change.
  5. Adam. Maintain decaying averages of both gradients and squared gradients. After correcting the initial bias of both averages, use the first to set the direction and the second to scale the step for each parameter. A small keeps the denominator away from zero.
  6. Learning-rate scheduling. Change over training. A larger early learning rate allows faster progress, while a smaller later rate allows finer adjustment. A schedule may reduce when validation performance stops improving.

3. Regularisation and diagnosing overfitting

Optimisation aims to reduce the training objective. Regularisation aims to improve generalisation. A model that has high loss on both training and validation may be underfitting. A model whose training loss keeps falling while its validation loss starts rising may be overfitting. Always compare the curves on the same metric.

Training and validation loss diverging after the best validation epoch

PYQ — CT2 Set A 2026, Q2(b) · Regularisation techniques (6 marks)

Original question from the paper

Model answer

Regularisation reduces overfitting so that a deep neural network generalises better to unseen examples. An overfitting network can keep improving on the training set while its validation performance gets worse. The following techniques limit how strongly the network can fit details specific to the training data.

  1. L1 regularisation. Add to the training loss. This encourages sparse weights because some coefficients can become exactly zero.
  2. L2 regularisation. Add to the training loss. Its gradient adds to the update for each weight, discouraging large weights.
  3. Dropout. Randomly set a fraction of the activations to zero in each training pass. This makes the network less dependent on any particular hidden unit. With inverted dropout, surviving activations are rescaled during training and the mask is removed at inference.
  4. Early stopping. Track the validation loss and retain the checkpoint with the lowest value. For example, if the validation losses are , the selected model is the one from epoch 3.
  5. Data augmentation. Generate additional training inputs using transformations that preserve the label. For example, suitable crops of a cat image retain the label “cat”. This exposes the model to more valid variations of its inputs.
  6. Structural regularisation. Limit model capacity by design, for example by reducing the number of hidden units or sharing weights. A CNN uses the same filter at different image positions, reducing the number of independent parameters it can fit.

4. Convolutional neural networks

A convolutional neural network learns filters that respond to local patterns. An image has height, width and one or more channels. Each filter slides across the image or feature map, multiplying its weights with the values in each patch and adding the products and a bias. Each filter produces one output feature map and has weights over every input channel. The same filter weights are reused at each location, so a learned feature can respond wherever it appears. Later convolutions can combine multiple maps into more complex features.

Kernel, stride, padding, and pooling

TermMeaning
Kernel or filterTrainable weights applied to one local patch
Stride Number of positions the kernel moves at each step
Padding Extra values, commonly zeros, placed around each side
ReLU applied to each filter response
PoolingMaximum or average over a local window to summarise responses and usually reduce spatial dimensions

For one spatial dimension of size , kernel size , symmetric padding , and stride , the output size is without dilation. The same rule applies separately to height and width. With a input, filter and no padding, stride 1 makes a map while stride 2 makes a map.

PYQ — CT2 Set B 2026, Q1(b) · Full CNN walkthrough (8 marks)

Original 2021–22 semester Q9 on CNN architecture

Original question from the paper

Model answer

A convolutional neural network (CNN) learns spatial features such as edges and shapes. A convolutional layer applies the same small trainable filter to many patches of the input. This gives one feature map per filter and lets the network detect the same pattern at different locations.

1. Convolution. Consider a grayscale image and a vertical-edge filter . Use stride 1, no padding, and zero bias.

At each location, the network multiplies the patch entries by the corresponding filter weights and sums the products. The first patch gives . The next patch has ones in its left column and zeros in its right column, giving . Sliding the filter over all positions gives a feature map.

2. Activation. ReLU applies to each feature-map entry. It introduces nonlinearity and removes the negative responses in this example.

3. Pooling. Max pooling retains the largest activation in each local window. A window with stride 1 gives , reducing the map from to .

4. Classification. The pooled map is flattened into . A dense layer converts that vector into class scores. Suppose its first output reads the first pooled value and gives score 2 for “edge present”, and its other output gives score 1 for “edge absent”. Softmax converts the scores to probabilities of and . The predicted class is “edge present”.

5. Learning. During training, cross-entropy compares the class probabilities with the true label. Backpropagation computes gradients for the classifier and the filters, and the optimiser updates the weights. Since a filter is reused at all positions, its gradient accumulates contributions from all patches where it was applied. Stacked convolutional layers can build complex features from simple ones.

5. Recurrent neural networks and sequence modelling

Sequence tasks depend on context. “Good” and “not good” contain the same adjective, but its meaning changes after the negation. A recurrent neural network (RNN) processes the input one step at a time and stores a summary in a hidden state. Each new state uses both the current input and the previous state.

RNN cell unrolled across a sequence

For input representation , previous state and output ,

The matrices are shared across time. Use the last state for a whole-sequence prediction such as sentiment, or produce an output at every step for tagging or next-token prediction. In a next-token model, use a softmax over vocabulary scores to predict the following token. A bidirectional RNN combines forward and backward states when both past and future inputs are available, as in offline tagging.

PYQ — CT2 Set A 2026, Q2(a) · How RNNs model sequences (6 marks)

Original question from the paper

Model answer

A recurrent neural network (RNN) models an ordered sequence by carrying a hidden state from one time step to the next. At step , the network combines the current input with the previous state and produces a new state .

An unrolled RNN shows how each input contributes to later states.

The same weights are used at every time step, so the network can process sequences of different lengths. For tasks such as sentiment classification, it predicts from the final state. For tasks such as part-of-speech tagging, it can produce one output for each token.

Example. Let , with , and let the positive-sentiment probability be . Represent “good” by and “not” by . On “good” alone, , giving probability . On “not good”, the first word produces . The second word then gives and probability . The earlier word changes the output for the same current word because it changes the previous hidden state.

During training, backpropagation through time passes the loss gradients through the unrolled sequence and accumulates them for the shared weights.

Training through time and long-range dependencies

Backpropagation through time (BPTT) unrolls the network over time and differentiates through the resulting chain. Gradients from each use of a shared weight are added. Repeated products of derivatives can make the influence of distant tokens vanish or explode. Gradient clipping limits exploding gradients. Gated models such as LSTMs provide a separate cell state, with input, forget and output gates that control writing, retaining and reading information. In particular, the cell update can preserve information when stays near 1.

Feedforward, recurrent, and recursive networks

ArchitectureInformation flowTypical example
FeedforwardSuccessive layers process a given inputPredict the class of a fixed feature vector
RecurrentEach time step uses a previous hidden statePredict the next word from earlier tokens
RecursiveA shared composition function combines child nodes up a treeCombine words into phrases in a parse tree

For a tree example, first combine the nodes for “not” and “good” into a phrase representation. Then combine that phrase with the representation of “the meal was”. A binary recursive model can apply the same rule at both joins. The parse tree decides which nodes to combine.

PYQ — 2021–22 semester, Q10 · Feedforward network versus RNN (4 marks)

Original question from the paper

Model answer

A feedforward neural network sends activations from the input through successive layers to the output. It has no recurrent state connecting one example or time step to the next. A standard feedforward classifier can, for example, classify an image represented by a fixed feature vector.

An RNN passes its hidden state from each time step to the next. Its current output can therefore depend on earlier inputs as well as the current input. The same weights are reused across time, so the network can process variable-length sequences. This makes it appropriate for tasks such as predicting the next word in a sentence.

PYQ — 2021–22 semester, Q13 · RNN training issues (2 marks)

Original question from the paper

Model answer

During backpropagation through time, gradients are repeatedly multiplied by derivatives of the state-update function. If they shrink toward zero, early time steps receive little learning signal and the RNN struggles to learn long-range dependencies. If they grow rapidly, training becomes unstable. Gated architectures such as LSTMs help preserve long-range information, and gradient clipping limits exploding gradients.

6. Closed-book revision

  1. Sketch the training and validation curves for overfitting. Mark the checkpoint to restore and explain why the test set is held out.
  2. Calculate a batch update and the first two stochastic updates using the same examples.
  3. Draw convolution → ReLU → pooling → output. Trace one pixel patch all the way to a predicted class and explain how the kernel learns.
  4. Unroll an RNN for two tokens. Use the same weights twice and show exactly how the first token can change the second prediction.

Write CT2 Set A Q2, then try Set B Q1(b) and Q2(a) without the note.