/en-tutor-prep-ib-cs-artificial-neural-networks-mlp-cnn/
/en-tutor-prep-ib-cs-artificial-neural-networks-mlp-cnn/
General Inquiry: info@TutorZone.com.hk
Office Hours: Monday to Saturday - 9:00 AM to 6:00 PM
WhatsApp Monday to Sunday - 24 hours
Hotline: +852 6828 1809
Instant Support: +852 9061 3106

IB Computer Science lesson prep: neural networks and CNNs, weighted sum 0.18, 21 against 101,770 parameters

IB Computer Science lesson prep: neural networks and CNNs, weighted sum 0.18, 21 against 101,770 parameters

  • 2026-11-27

Students hear “neural network” and treat it as a black box, then see 101,770 parameters and assume they must be computed by hand. This session turns the perceptron into one weighted sum, depth into a parameter ledger, and convolution into a sliding window of multiplications.

Objectives — Students can: 1) draw the five parts of a single perceptron and compute the weighted sum: 0.5 times 0.8 plus 0.3 times 0.6 plus 0.4 times 0.5 is 0.78, add the bias -0.6 to get 0.18, and the output is 1 after activation; explain that the bias is the threshold 0.6; 2) give three activation outputs: a step gives 1, sigmoid gives 0.5449, ReLU gives 0.18; 3) count parameters: 3 in, 4 hidden, 1 out is 21; 784 in, 128 hidden, 10 out is 101,770; one more hidden layer of 128 makes 118,282, which is 5,632 times the small network; 4) compute a convolution: a 32 by 32 input with 8 kernels of 3 by 3 at stride 1 gives 30 by 30 by 8, that is 7,200 outputs, with only 80 parameters where a dense layer on the same input needs 102,500; 5) carry the shape through pooling and the fully connected layer: 15 by 15, then 13 by 13 by 16, then 6 by 6 by 16 equal to 576 values, with 7,018 parameters in the whole network; 6) read a loss: predicting 0.9 on a true label gives cross entropy 0.1054, predicting 0.1 gives 2.3026, a factor of 21.8.

01 Prerequisites (3-minute check)

If any of these fails, fix it before the lesson starts.

Skill Quick check Pass mark
Weighted sum What is 0.5 times 0.8 plus 0.3 times 0.6 0.4 plus 0.18 is 0.78
Exponentials Roughly what is e to the power of minus 0.18 About 0.835, so sigmoid gives 0.545
Area and depth How many values are in a 30 by 30 map with 8 channels 7,200 values

02 Lesson flow (60 minutes)

Time Stage Tutor does Student does
0-8 min Entry check Ask which number in a network is actually learned Write an answer first, test it against weights later
8-26 min Single perceptron Contributions 0.4, 0.18, 0.2, bias -0.6 Compute the sum and the output
26-40 min Multi-layer networks 21 then 101,770 parameters Count parameters, justify hidden layers
40-52 min Convolution 32 by 32 input, 3 by 3 kernel, stride 1 gives 30 Compute shape and parameter count
52-57 min Pooling and dense layers Pool to 6, total 7,018 Compute the rest and the loss
57-60 min Exit check Collect and mark three questions Work independently

03 Teaching script (read it out)

Scene 1: The perceptron: one weighted sum and one threshold

Start by turning three inputs into 0 to 1 ratios rather than raw scores: study time as 0.8, attendance as 0.6, homework completion as 0.5. The weights are 0.5, 0.3 and 0.4, so the contributions are 0.4, 0.18 and 0.2, adding to 0.78: the three inputs carry 51.3 per cent, 23.1 per cent and 25.6 per cent of the total. The bias is -0.6, so the sum drops by 0.6 to reach 0.18.
The bias is a threshold in disguise: move it across the inequality “0.78 plus bias is at least zero” and the weighted sum must reach 0.6. It is not an extra input, it pushes the decision boundary away from the origin. Without a bias, an all zero input can never produce a one, so the model cannot even learn the case where several weak signals together should still fire.
The activation decides the shape of the output: a step function gives 1 because 0.18 is positive; sigmoid gives 1 over (1 plus e to the minus 0.18), which is 0.5449, a 54.5 per cent confidence; ReLU returns zero for negatives and passes positives, so it gives 0.18. The same sum, three activations, three answers, and that is exactly what exam questions probe.
Two counter examples: drop attendance to 0.1 and the sum is 0.4 plus 0.03 plus 0.2, namely 0.63, minus 0.6 gives 0.03, still firing; drop study time to 0.3 and the sum is 0.53, minus 0.6 gives -0.07, so it stays off. Ask which input mattered most, and demand the answer from weight times gap, not from intuition.

Student task: change the weights to 0.6, 0.2 and 0.2, recompute the three contributions and the output, then write one sentence naming the kind of student who now passes but did not before.

Scene 2: The multi-layer network: what one layer cannot separate

Use XOR first: the four input pairs give 0, 1, 1, 0, and no single straight line separates them, so a one layer perceptron tops out at three out of four, that is 75 per cent. One hidden layer with two units separates them exactly, 100 per cent. The reason is that the hidden layer maps inputs into a new feature space where the classes happen to be linearly separable: every layer builds new features, and only the last one draws the line.
Now keep the parameter ledger, which is where marks are actually won: 3 inputs into 4 hidden units needs 12 weights and 4 hidden biases, then 4 hidden into 1 output needs 4 weights and 1 output bias, so 21 parameters in total. Switch to images: 784 inputs (28 by 28) into 128 hidden units needs 100,352 weights and 128 biases, then 1,280 weights and 10 biases for the output, giving 101,770 in total. Add one more hidden layer of 128 and you pay 16,384 weights plus 128 biases, so the total rises to 118,282, which is 5,632 times the small network.
Make the ledger mean something: parameters are what has to be learned, so parameters drive the data and the compute you need. A model of 101,770 parameters has to adjust each one from examples, so a small training set guarantees overfitting. Depth buys expressive power and costs parameters, data and time, and all three have to be said together.

Student task: count the parameters of a 10 in, 6 hidden, 4 hidden, 3 out network, then write one sentence on what goes wrong if the training set holds only 40 examples.

Scene 3: The CNN: one small window that slides over the whole image

A convolutional layer is simple: take a 3 by 3 kernel, slide it over the image, and at every stop multiply nine pixels by nine weights and add them up. With a 32 by 32 input, stride 1 and no padding, the first stop is at position 1 and the last leaves two cells at the edge, so each side holds 32 minus 3 plus 1, which is 30 positions. One feature map is 30 by 30, and 8 kernels give 8 maps, so 7,200 values in total.
Parameters: 8 times (9 weights plus 1 bias) is 80. A dense layer on the same input, 1,024 into 100, needs 102,500 parameters, which is 1,281 times more. Two ideas save the cost: local connectivity, since each output only looks at 3 by 3 inputs, and weight sharing, since the same kernel sweeps the whole image.
Pooling takes the maximum of each 2 by 2 block, so 30 by 30 becomes 15 by 15 times 8, that is 1,800 values, adding no parameters and buying a little shift invariance. The second convolution uses 16 kernels of 3 by 3 over 15 by 15 by 8 and gives 13 by 13 by 16, that is 2,704 values, with 16 times (3 times 3 times 8 plus 1) equal to 1,168 parameters. Pool again: 13 divided by 2 rounds down to 6, so 6 by 6 by 16 is 576 values. The fully connected layer maps 576 into 10, which is 5,760 weights plus 10 biases, so 5,770 parameters. The whole network is 80 plus 1,168 plus 5,770, that is 7,018 parameters, about one fourteenth of the dense first layer alone.
Three dials, three costs: stride 2 cuts the output from 7,200 to 1,800, four times less arithmetic; a 5 by 5 kernel gives 28 by 28 with 26 parameters per kernel; and depth changes the receptive field, since three stacked 3 by 3 kernels see 7 by 7 with 30 parameters, while one 7 by 7 kernel sees the same area with 50. Deep and narrow is cheaper than shallow and wide.
Finish on loss: a true label of 1 answered 0.9 gives minus ln 0.9, which is 0.1054; answered 0.5 it is 0.6931; answered 0.1 it is 2.3026, a factor of 21.8. That is why the model works hardest on examples it gets confidently wrong. For several classes use softmax: scores 2.0, 1.0 and 0.1 exponentiate to 7.389, 2.718 and 1.105, and dividing by the total 11.213 gives 0.659, 0.242 and 0.099.

Student task: for a 48 by 48 input with 6 kernels of 5 by 5 at stride 1, write the output shape and the parameter count, then repeat at stride 2 and say which setting is cheaper and what it costs.

04 Question types and worked steps

Type Example Steps Answer
Compute a perceptron output Inputs, weights, bias and an activation are given Four steps: multiply each input by its weight, add, add the bias, apply the activation 0.78 plus -0.6 gives 0.18, step output 1
Count parameters in a multi-layer network The unit count of each layer is given Three rules: previous times next gives weights, one bias per receiving unit, add layer by layer 21; 101,770
Compute a convolutional output shape Input side, kernel size, stride and padding are given One formula: (input minus kernel) divided by stride, rounded down, plus one; then multiply by channels (32 minus 3) over 1 plus 1 is 30, times 8 gives 7,200
Carry pooling and dense layers Feature map size and pooling window are given Two steps: divide the side by the window and round down, multiply by channels; then dense is flattened length times outputs plus bias 15 by 15 times 8 and 6 by 6 times 16; dense 5,770
Compute cross entropy loss The true label and the predicted probability are given Two steps: take the natural log, then negate; for several classes apply softmax first and take the negative log of the true class 0.1054, 0.6931, 2.3026
Sanity check (teach this): Five sanity checks. 1) Output sides must stay whole and keep shrinking: 30, 15, 13, 6 only ever fall, and a student who writes 13 divided by 2 as 6.5 has forgotten to round down. 2) Parameters are weights plus biases only, never inputs or activations: the first convolutional layer has 80 parameters, not 7,200 values, and confusing the two is the commonest error. 3) The number of values in a feature map is side squared times channels, 6 by 6 by 16 is 576, which must equal the dense input length. 4) Cross entropy is never negative and grows as the prediction falls: 0.1054 is below 0.6931 is below 2.3026, so a negative answer means the sign of the log was flipped. 5) Convolution always uses fewer parameters than a dense layer of the same width, 80 against 102,500, because of local connectivity and weight sharing; answering “convolution has more parameters so it is more accurate” mixes arithmetic volume with parameter count. The deeper misjudgement is treating depth as free: every layer adds parameters and one more thing to tune, and 101,770 rising to 118,282 is 5,632 times the small network.

05 Independent practice (3 questions)

Question Answer What to watch
A perceptron has inputs 0.8, 0.6 and 0.5, weights 0.5, 0.3 and 0.4, and bias -0.6. (a) Give the weighted sum and the step output. (b) What threshold does the bias imply? (a) Sum 0.78, output 1 because 0.18 is positive. (b) 0.6 Moving the bias across to become a threshold
A network is 784 in, 128 hidden, 10 out. (a) How many parameters? (b) If the test set has 500 examples, what is the likely problem? (a) 101,770. (b) Far more parameters than examples, so it memorises the training set Weights and biases must both be counted
A 32 by 32 single channel input passes through 8 kernels of 3 by 3 at stride 1 with no padding, then 2 by 2 pooling. Give both output shapes and the parameter count of the first layer. Convolution 30 by 30 by 8, pooling 15 by 15 by 8, parameters 80 Feature map size is not parameter count

06 Common mistakes and what to say

Mistake Student writes Say this
Reporting values as parameters Writing “the first layer has 7,200 parameters” “7,200 is the number of output values. Parameters are what gets learned: 8 kernels of 9 weights plus 1 bias each, so 80. One parameter is reused at 900 positions, and that reuse is exactly why convolution is cheap.”
Assuming more layers always help Writing “ten layers must beat three” “Every layer adds parameters. 784 in, 128 hidden, 10 out is 101,770; one more hidden layer of 128 makes 118,282, which is 5,632 times the small network. Parameters need examples, so without data the extra depth just overfits.”
Dismissing pooling Writing “pooling is only there to keep the numbers tidy” “Pooling shrinks 30 by 30 to 15 by 15, so every later layer works on a quarter of the area. It also buys a little shift invariance: a cat two pixels to the left is still a cat.”
Confusing loss with accuracy Writing “loss 0.1054 means 10.5 per cent accuracy” “Loss is the penalty the model takes, here minus ln 0.9. Accuracy is the share of correct answers, a different unit. Answering 0.1 gives 2.3026, which is 21.8 times the loss of answering 0.9, and that is how loss is used: to compare which example is punished hardest.”

07 Homework (paper, section and question numbers)

08 Exit check (last 5 minutes)

Question Answer Decision
Perceptron Sum 0.78, output 0.18, threshold 0.6 No meaning for the bias means repeat act one
Parameters 21, 101,770, 7,018 Counting values as parameters is a fail
Convolution 30 by 30, 6 by 6, loss 0.1054 No rounding down means recompute

09 Tutor FAQ

Do students need to memorise a CNN diagram?

They need the six layer order: input, convolution, activation, pooling, fully connected, output. Marks come from saying what each layer does and why: convolution finds local features, activation adds non-linearity, pooling shrinks the map, the dense layer makes the final decision. No real network architecture needs memorising.

Is backpropagation required?

A4.3.8 asks students to sketch a perceptron and an MLP and describe the role of each part. The gradient derivation is not required. One sentence is enough: weights are adjusted by the derivative of the loss with respect to them. Spend the time on the forward pass and the parameter ledger, because those are where numbers appear.

Why softmax for many classes and sigmoid for two?

Softmax makes the class probabilities sum to one, which suits a single-label problem. Sigmoid treats each output independently, which suits multi-label data where several answers can hold at once. The scores 2.0, 1.0 and 0.1 become 0.659, 0.242 and 0.099, which add to exactly one.

Find a tutor — freeTutor Registration →

A TutorZone lesson-prep guide. Written by the TutorZone team; questions and lesson flow are original and are not taken from any school or publisher material.

Join as a tutor or coach — academic, music, sports, arts, STEM. Free to register. See how it works →