Question bank › IB Computer Science › A4 Machine learning

Neural networks, CNNs and model selection (HL)

Answer on paper first, then reveal the mark scheme one mark at a time.

1StandardHL only4 marks

A single artificial neuron has weights w1 = 0.5, w2 = −0.4, w3 = 0.3 and bias b = −0.6. It uses a step activation: output 1 if the total is > 0, otherwise 0.

(a) Calculate the output for inputs (1, 0, 1). [3]

(b) State the output for inputs (0, 1, 1). [1]

2CoreHL only4 marks

A perceptron is the basic building block of an artificial neural network (ANN).

(a) Outline the function of the weights in a perceptron. [1]

(b) Outline the function of the bias in a perceptron. [1]

(c) Outline two functions of the activation function in a perceptron. [2]

3StandardHL only4 marks

The diagram shows a small multi-layer perceptron. Each hidden neuron uses the ReLU activation, $\text{ReLU}(z)=\max(0,z)$. The output neuron uses the sigmoid activation, $\sigma(z)=\dfrac{1}{1+e^{-z}}$. The bias of each neuron is shown next to it. The weights are: $x_1 \to h_1 = 0.4$, $x_2 \to h_1 = -0.2$, $x_1 \to h_2 = -0.6$, $x_2 \to h_2 = 0.8$, $h_1 \to y = 1.5$, $h_2 \to y = 0.9$.

The inputs are $x_1 = 1.0$ and $x_2 = 0.5$.

Calculate the output $y$ of the network. Show your working and give your answer to 3 decimal places. [4]

0.4−0.2−0.60.81.50.9x1x2h1h2yb = 0.1b = −0.3b = −0.2Input layerHidden layer (ReLU)Output(sigmoid)
Stuck on Neural networks, CNNs and model selection (HL)?

Get it sorted in a free 30-minute session

We work through your weakest questions on this topic on Zoom. I reply the same day.

4HardHL only5 marks

A single perceptron has two binary inputs $x_1$ and $x_2$, weights $w_1 = w_2 = 1$, bias $b = -1.5$ and a step activation that outputs 1 if the total is greater than 0 and outputs 0 otherwise.

(a) Show that this perceptron implements the logical AND function. [2]

(b) The XOR function outputs 1 only when exactly one input is 1. Explain why no single perceptron can implement XOR, and how a multi-layer perceptron overcomes this. [3]

5StandardHL only4 marks

A convolutional neural network (CNN) applies the 3×3 kernel shown to the 4×4 greyscale image shown. The kernel moves with a stride of 1 and no padding is used.

(a) State the dimensions of the resulting feature map. [1]

(b) Calculate the value in the top-left position of the feature map. Show your working. [2]

(c) State the type of image feature that this kernel responds to most strongly. [1]

Input image (4 × 4)1021013021011012Kernel (3 × 3)10−110−110−1
6HardHL only6 marks

A CNN is trained to identify species of bird from photographs. Its architecture contains several convolutional layers, each followed by a pooling layer, and then fully connected layers.

Describe how this CNN adaptively learns a spatial hierarchy of features from the photographs. [6]

7CoreHL only4 marks

The table shows a 4×4 feature map produced by a convolutional layer.

3102
5241
0622
1370

(a) Max pooling with a 2×2 window and a stride of 2 is applied. Determine the output. [2]

(b) Outline two reasons why pooling layers are used in a CNN. [2]

8HardHL only6 marks

A developer is building a plant-identification app that must work offline on a mid-range smartphone. Three models were trained on the same training set and tested on the same validation set.

ModelTypeTraining accuracy (%)Validation accuracy (%)Size (MB)Time per image (ms)
ASmall CNN91891230
BLarge CNN99.890480900
CMulti-layer perceptron on flattened pixels78764025

(a) Identify the model that shows the most overfitting. Justify your answer using the data. [2]

(b) Recommend which model the developer should choose. Justify your recommendation with reference to the data. [3]

(c) Suggest why model C is less accurate than the CNNs on this task. [1]

9StandardHL only4 marks

The graph shows the training loss and validation loss of a neural network recorded every 2 epochs during training.

(a) State the epoch at which training should be stopped. [1]

(b) Explain what is happening to the model after this epoch. [2]

(c) The developer also keeps a separate test set that is never used while training or choosing the stopping epoch. Outline why. [1]

024681012141618200.00.20.40.60.81.0EpochLosstraining lossvalidation loss
10StretchHL only6 marks

A team compares two classifiers, P and Q, using 5-fold cross-validation. The accuracy on each validation fold is shown.

Fold12345
Model P0.840.860.830.850.87
Model Q0.920.740.880.790.90

(a) Calculate the mean accuracy of each model. [2]

(b) Recommend which model the team should deploy. Justify your answer. [2]

(c) Explain why k-fold cross-validation gives a more reliable comparison of models than a single train/validation split. [2]

Stuck on this topic?

Book a free 30-minute session on WhatsApp and we'll find exactly which step is costing you the marks. Or build a timed paper on it.

Free 30-minute session