Machine Learning (Aerospace Applications)
Level 4 — Application (novel problems, no hints) Time limit: 60 minutes Total marks: 60
Answer all questions. Show all working. Calculators permitted. Where numeric answers are requested, keep at least 4 significant figures unless told otherwise.
Question 1 — System Identification via Ridge Regression (12 marks)
A quadrotor's pitch-rate dynamics are approximated by the linear model , where is elevator deflection (deg) and is measured pitch acceleration (deg/s²). You collect three flight-test samples:
(a) Write the ridge-regularized cost that penalizes only (not the bias ) with strength . (2 marks)
(b) Derive the closed-form normal equation for this ridge problem and state the modified matrix that must be inverted. (3 marks)
(c) With , solve for and numerically. (5 marks)
(d) Explain physically why regularizing but not is the standard convention. (2 marks)
Question 2 — Backpropagation Through a Tiny Network (14 marks)
Consider a single-input network for a fault-detection classifier:
Loss is binary cross-entropy .
Given: .
(a) Perform the forward pass: compute and the loss . (4 marks)
(b) Show that and evaluate it. (3 marks)
(c) Using the chain rule, derive and evaluate . (Recall .) (5 marks)
(d) One gradient-descent step with learning rate updates . Give the new . (2 marks)
Question 3 — Scaled Dot-Product Self-Attention (12 marks)
A transformer processes two token embeddings. After projection you obtain:
with key dimension .
(a) Write the self-attention formula and compute the scaled score matrix . (3 marks)
(b) Apply row-wise softmax to obtain the attention weight matrix. Give entries to 4 decimals. (5 marks)
(c) Compute the output matrix (attention weights times ). (3 marks)
(d) State one reason the scaling is used. (1 mark)
Question 4 — Q-Learning for a Guidance MDP (12 marks)
An interceptor operates in a 2-state MDP (states ; is terminal). From , action fire gives reward and transitions to ; action wait gives reward and stays in . Discount . Learning rate . All Q-values initialised to 0.
(a) Write the Q-learning update rule. (2 marks)
(b) Starting from , apply the update for the transition , then for where is terminal (). Give the updated Q-values. (5 marks)
(c) Determine the exact converged optimal values and using the Bellman optimality equation, and state the optimal policy. (5 marks)
Question 5 — Bias–Variance and Cross-Validation (10 marks)
You fit polynomial models of degree to noisy aerodynamic drag data using 5-fold cross-validation.
(a) Sketch (describe) the expected trend of training error and validation error as increases, and identify which regime each degree likely occupies (underfit / good / overfit). (4 marks)
(b) Define bias and variance in one sentence each, and state which dominates the error for and for . (3 marks)
(c) In 5-fold CV, a dataset of 200 samples is split. State how many samples are used for training and validation in each fold, and give one reason to prefer k-fold CV over a single train/test split. (3 marks)
Answer keyMark scheme & solutions
Question 1 (12 marks)
(a) Cost with bias unpenalized: (2) (1 mark squared-error term, 1 mark for only on .)
(b) With design matrix , the normal equation is , where the penalty matrix (zero in bias slot). (3) Solution: .
(c) Compute: (5) , .
With : , .
.
.
(2 for ; 1 for adding ; 2 for inversion & solve.)
(d) The bias merely sets the output offset (mean level); shrinking it toward zero would introduce systematic error and makes the fit depend on the arbitrary origin of . Penalizing only slopes keeps the model shift-invariant and controls model complexity without biasing the intercept. (2)
Question 2 (14 marks)
(a) Forward pass: (4) (1 each for + values.)
(b) ; and . Product gives . (3) Value: .
(c) Chain rule: (5) . .
(d) Update: . (2)
Question 3 (12 marks)
(a) . (3) , so scaled scores .
(b) Row softmax of : (5) , sum . Weight on diagonal ; off-diagonal .
(c) Output , : (3) Row 1: . Row 2: .
(d) Scaling by keeps the dot-product magnitudes from growing with dimension, preventing softmax saturation (tiny gradients). (1)
Question 4 (12 marks)
(a) (2)
(b) (5) Update 1 — , : .
Update 2 — , terminal : .
Result: , . (2.5 each)
(c) Bellman optimality. (5) Fire is terminal-transition: . Wait: . Since fire gives 10, : . Optimal policy: choose fire in (10 > 8). (2 + 2 + 1)
Question 5 (10 marks)
(a) Training error decreases monotonically as increases (more flexibility fits data). Validation error is U-shaped: high at (underfit), minimum around (good fit), rising again at (overfit, high variance). (4)
- : underfit; : good; : overfit.
(b) (3) Bias = error from wrong/too-simple model assumptions (systematic). Variance = sensitivity of the fit to particular training samples (fluctuation). : bias dominates; : variance dominates.
(c) (3) 5-fold on 200 samples: each fold uses for validation and for training. Prefer k-fold because every sample serves in validation exactly once, giving a lower-variance, more reliable performance estimate than one arbitrary split (and uses data efficiently).
[
{"claim":"Ridge Q1 solution w0=4/3, w1=2/3","code":"X=Matrix([[1,1],[1,2],[1,3]]); y=Matrix([2,2,4]); R=Matrix([[0,0],[0,1]]); A=X.T*X+R; w=A.inv()*(X.T*y); result = (w[0]==Rational(4,3)) and (w[1]==Rational(2,3))"},
{"claim":"Q2 dL/dw1 approx -0.30396","code":"import math; a1=math.tanh(0.5); z2=a1; yh=1/(1+math.exp(-z2)); g=(yh-1)*1*(1-a1**2)*1; result = abs(g-(-0.30396))<1e-3"},
{"claim":"Q3 softmax diagonal weight approx 0.6698","code":"import math; e=math.exp(1/math.sqrt(2)); w=e/(e+1); result = abs(w-0.6698)<1e-3"},
{"claim":"Q4 Bellman Q*(wait)=8, Q*(fire)=10","code":"g=Rational(9,10); qfire=10; qwait=-1+g*max(qfire,0); result = (qfire==10) and (qwait==8)"}
]