CAB212 · Unit 6: Evaluation and practice
Perceptron and a first neural network
7 practice questions
Key points
- Perceptron = linear classifier
- Cannot learn XOR alone
- ReLU is the default hidden activation
- Backpropagation uses the chain rule
A perceptron computes y = step(w.x + b): output 1 if the weighted sum is non-negative, else 0. It learns with the rule w := w + eta (t - y) x. It converges only if the classes are linearly separable; a single perceptron cannot learn XOR.
A multilayer perceptron (MLP) stacks layers of neurons with non-linear activation functions:
| Activation | Formula | Notes |
|---|---|---|
| Sigmoid | 1/(1+e^-z) | (0,1); vanishing gradients |
| Tanh | (e^z - e^-z)/(e^z + e^-z) | (-1,1); zero-centred |
| ReLU | max(0, z) | Fast; default in hidden layers |
| Softmax | e^zi / sum(e^zj) | Output probabilities over classes |
Training uses forward pass (compute outputs), a loss function, backpropagation (chain rule to compute gradients), and a gradient-descent optimiser. Without non-linear activations, any stack of layers collapses to a single linear model.
Worked example: a perceptron with w = (1, 1) and b = -1.5 outputs 1 only when both inputs are 1, which is logical AND. Its weighted sum for input (1,1) is 0.5, so output is 1.
Exam pitfall: XOR needs at least one hidden layer.
Try two questions
Why are non-linear activation functions needed in an MLP?
- They make the network smaller and cheaper
- They remove the need for a loss function
- Without them stacked layers reduce to a single linear map
- They are required only for feature scaling
Show the answer
C. Composition of linear functions is linear.
Backpropagation computes gradients using the:
- Central limit theorem
- Bayes rule
- Pigeonhole principle
- Chain rule
Show the answer
D. It propagates derivatives backward through layers.