AI · 7.1
Neural Networks: Layers, Matrices and the Forward Pass
Name
Class
Date
Mark / 22
Section A
Circle the letter of the correct answer. One mark each.
- 1What is a dense layer?1
- AA layer that only connects each neuron to one input
- BA layer where every neuron receives every input from the previous layer
- CA layer whose weights are all fixed and never trained
- DA layer with more neurons than any other layer in the network
- 2A layer has 5 inputs and 3 neurons. What shape is its weight matrix?1
- A3 × 3
- B5 × 5
- C3 × 5
- D5 × 3
- 3How is a matrix multiplied by a vector?1
- AEach entry of the matrix is added to the vector
- BThe matrix is turned into a vector first
- COnly the first row is used
- DEach row of the matrix is dot-producted with the vector
- 4In the XOR network, h₁ = ReLU(x₁ + x₂) and h₂ = ReLU(x₁ + x₂ − 1). What are h₁ and h₂ for input (1, 1)?1
- A2 and 1
- B1 and 0
- C1 and 1
- D2 and 0
- 5How does a hidden layer let a network solve XOR?1
- AIt changes the labels of two of the points
- BIt moves the points to a new space where one line separates them
- CIt removes the points that are hard to classify
- DIt adds more training examples to the data
- 6How many parameters does a dense layer from 10 inputs to 4 neurons have?1
- A4
- B14
- C40
- D44
- 7Why are GPUs good at running neural networks?1
- AGPUs can run Python code faster than processors can
- BGPUs have more memory than any other kind of chip
- CLayers are matrix multiplications, which GPUs do massively in parallel
- DGPUs store the training data permanently
- 8What do the early layers of an image network typically learn?1
- ASimple features such as edges and colours
- BNothing until the last layer has trained
- CWhole objects such as faces
- DThe labels of the training images
- 9What does 'deep' mean in deep learning?1
- AThe network uses a lot of data
- BThe network has many hidden layers
- CThe network understands meaning deeply
- DThe network is trained for a long time
- 10A model has 1 million parameters stored as 32-bit numbers. Roughly how much memory is that?1
- A4 MB
- B1 MB
- C4 GB
- D32 MB
Section B
Answer in the space provided. The number of marks tells you how many separate points to make.
- 1ExplainExplain why a layer of a neural network can be written as a single matrix multiplication.4
- 2CalculateA network has 4 inputs, one hidden layer of 5 neurons and 2 outputs. Calculate its total number of parameters, showing your working.4
- 3ExplainExplain how the hidden layers of a deep image classifier build up an understanding of an image.4
Mark scheme
Section A
Section B
1 Explain why a layer of a neural network can be written as a single matrix multiplication. 4
One mark for each of the following, to a maximum of 4.
- Each neuron computes a weighted sum of the same inputs
- Each neuron's weights form a row of a matrix
- Multiplying the matrix by the input vector gives every weighted sum at once
- Then the bias is added and the activation applied, f(Wx + b)
Model answer. Every neuron in a layer computes a weighted sum of the same inputs, each with its own weights. If each neuron's weights are written as one row of a matrix W, then multiplying W by the input vector x takes the dot product of every row with x, giving all of the neurons' weighted sums in one operation. Adding the bias vector and applying the activation function gives the whole layer's output, f(Wx + b).
2 A network has 4 inputs, one hidden layer of 5 neurons and 2 outputs. Calculate its total number of parameters, showing your working. 4
One mark for each of the following, to a maximum of 4.
- 4 × 5 = 20 weights into the hidden layer
- 5 hidden biases, so 25 for the first layer
- 5 × 2 = 10 weights and 2 biases, so 12 for the second layer
- Total 37
Model answer. The first layer has 4 × 5 = 20 weights and 5 biases, which is 25 parameters. The second layer has 5 × 2 = 10 weights and 2 biases, which is 12 parameters. The total is 25 + 12 = 37 parameters.
3 Explain how the hidden layers of a deep image classifier build up an understanding of an image. 4
One mark for each of the following, to a maximum of 4.
- Early layers detect simple features such as edges or colours
- Later layers combine these into textures, parts or shapes
- The final layers represent whole objects or classes
- These features are learned in training, not programmed
Model answer. Each layer re-represents the image for the next. The early layers learn to detect simple features such as edges, lines and patches of colour. Later layers combine those into more complex features such as textures, corners and parts of objects, like an eye or a wheel. The final layers combine parts into whole objects, so the output layer can decide between classes such as cat or aeroplane. None of these features is programmed by a person: they are learned automatically during training.