Convolutional Neural Networks
Level: 4 — Application (novel problems, no hints) Time limit: 60 minutes Total marks: 60
Answer all questions. Show all working. Use notation for mathematics where required.
Question 1 — Spatial Dimension & Cost Analysis (14 marks)
A network processes an RGB input of size .
The first block applies:
- Conv-A: 64 filters, kernel , stride , padding
- MaxPool: kernel , stride , padding
- Conv-B: 128 filters, kernel , stride , dilation , padding
(a) Compute the output spatial size and number of channels after each of the three layers. Use . (6)
(b) Compute the number of learnable parameters (including biases) in Conv-A and Conv-B. (4)
(c) Compute the number of multiply–accumulate (MAC) operations required by Conv-B (ignore bias). (4)
Question 2 — Receptive Field Design (12 marks)
A designer stacks convolution layers, each , stride , no pooling.
(a) Derive/state the receptive field size after stacking such layers, and compute it for . (4)
(b) The designer needs a receptive field of at least using only stride-1 layers. What is the minimum number of layers? (3)
(c) Explain quantitatively why stacking three conv layers is preferred over a single layer for the same receptive field, comparing parameter counts (assume input and output channels throughout, no bias). (5)
Question 3 — Architecture Reasoning (14 marks)
(a) An Inception module receives a input. It contains a conv reducing to 64 channels before a conv (padding 2, stride 1) that outputs 128 channels. Compare the MAC cost of this bottleneck path against a naive conv applied directly from 256 → 128 channels. State the reduction factor. (6)
(b) A ResNet residual block computes . Explain, with reference to gradient flow, why this helps train very deep networks, and state what must hold about the dimensions of and . Describe the fix used when they differ. (4)
(c) Contrast how DenseNet and ResNet combine features from earlier layers, and state one consequence for parameter efficiency. (4)
Question 4 — Detection & Segmentation Application (12 marks)
(a) A YOLO-style detector divides a image into a grid. Each cell predicts 3 anchor boxes, and the dataset has 20 classes. Each box predicts 4 box coordinates + 1 objectness + class scores. Compute the number of output values per cell and the total output tensor size. (5)
(b) You must segment medical images where objects are small and precise boundaries matter. Justify choosing a U-Net over a plain FCN, referencing skip connections and resolution recovery. (4)
(c) Object detection with two-stage R-CNN is accurate but slow. Give one architectural reason for the speed gap versus single-stage YOLO/SSD. (3)
Question 5 — Transfer Learning & Augmentation Strategy (8 marks)
You have 800 labelled X-ray images (2 classes) and access to an ImageNet-pretrained ResNet-50.
(a) Propose a concrete transfer-learning strategy (which layers to freeze/train, what to replace). Justify given the small dataset. (5)
(b) Give three data-augmentation transforms appropriate for X-rays, and name one common augmentation you should avoid for medical X-rays, with reasoning. (3)
Answer keyMark scheme & solutions
Question 1 (14 marks)
(a) Formula:
Conv-A (): . → . (2)
MaxPool (): . → (channels unchanged). (2)
Conv-B (): effective kernel . . → . (2)
(b) Params .
- Conv-A: . (2)
- Conv-B: . (2)
(Dilation does not change parameter count — kernel weights unchanged.)
(c) MACs for Conv-B . → MACs. (4)
Question 2 (12 marks)
(a) For stride-1 layers, receptive field after layers: for . For : → . (4)
(b) Need . Minimum 15 layers. (3)
(c) Both give RF (three : ).
- Three : params.
- One : params. Ratio → ~45% fewer parameters, plus extra non-linearities (more representational power) and less compute. (5) (2 for correct param counts, 2 for ratio, 1 for non-linearity point.)
Question 3 (14 marks)
(a) Output spatial size (padding preserves).
- Naive 256→128, : MACs . . (2)
- Bottleneck: (256→64) then (64→128).
- : .
- : .
- Total . (2)
- Reduction factor . (2)
(b) The skip connection lets gradients flow directly to earlier layers via the identity path: , so gradients don't vanish even if is small. It's easier to learn a residual (near-zero) than a full mapping, mitigating degradation in deep nets. (2) Dimensions of and must match (same ). When they differ (e.g., stride/channel change), use a conv (projection shortcut) on to match dimensions. (2)
(c) ResNet adds (element-wise sum) the identity to the block output; DenseNet concatenates all previous feature maps as input to each layer. Consequence: DenseNet reuses features so each layer can be narrow (few filters), giving high parameter efficiency; ResNet's sum requires matching channel counts and doesn't grow input width. (4)
Question 4 (12 marks)
(a) Per box: values. Per cell: values. (3) Total tensor: values (or shape ). (2)
(b) U-Net's encoder–decoder with skip connections copies high-resolution feature maps from encoder to decoder, restoring fine spatial detail lost during downsampling — critical for small objects and precise boundaries. Plain FCN upsamples from coarse features with fewer/weaker skip fusions, giving blurrier boundaries. U-Net's symmetric expansive path progressively recovers resolution while combining semantic + spatial info. (4)
(c) Two-stage R-CNN first runs a region-proposal stage then classifies each proposal (many forward passes / per-region computation), whereas single-stage detectors predict boxes + classes in one dense forward pass over the grid — eliminating the separate proposal stage. (3)
Question 5 (8 marks)
(a) With only 800 images, freeze the early/mid convolutional layers (generic edge/texture features), replace the final FC/classification head with a new 2-unit (or 1-unit sigmoid) layer, and fine-tune only the head (and optionally the last conv block) at a low learning rate. Freezing prevents overfitting the many pretrained parameters on scarce data; the new head adapts to the X-ray task. (5) (Reasonable variants accepted: full fine-tune with low LR + heavy regularization noted as riskier.)
(b) Suitable: small rotations, horizontal flips (if anatomically valid), random brightness/contrast, small translations/scaling, elastic/crop. (2) Avoid: vertical flips or large arbitrary rotations / left-right flips if orientation is diagnostically meaningful — they create anatomically impossible/mislabeled images (e.g., flipping heart to wrong side). (1)
[
{"claim":"Conv-A output spatial size is 112","code":"I=224;p=3;d=1;k=7;s=2; O=(I+2*p-d*(k-1)-1)//s+1; result=(O==112)"},
{"claim":"Conv-B output spatial size is 56","code":"I=56;p=2;d=2;k=3;s=1; O=(I+2*p-d*(k-1)-1)//s+1; result=(O==56)"},
{"claim":"Conv-B parameters = 73856","code":"result=((3*3*64+1)*128==73856)"},
{"claim":"Conv-B MACs = 231211008","code":"result=(56*56*128*9*64==231211008)"},
{"claim":"Three 3x3 vs one 7x7 param ratio 27/49","code":"result=(Rational(27,49)==Rational(3*9,49))"},
{"claim":"Inception bottleneck reduction ~3.70x","code":"naive=28*28*128*25*256; bott=28*28*64*1*256 + 28*28*128*25*64; result=(round(naive/bott,2)==3.70)"},
{"claim":"YOLO per-cell values = 75 and total 12675","code":"per=3*(4+1+20); tot=13*13*per; result=(per==75 and tot==12675)"}
]