COMP5318 Practice Exam 1 整卷逐题解析
COMP5318 Practice Exam 1 整卷逐题解析
课程:COMP4318/COMP5318 — Machine Learning and Data Mining 材料:
Exam Prep/COMP5318_Practice_Exam_1.pdf(题目,20 页)+COMP5318_Practice_Exam_1_Solutions.pdf(官方答案与评分指引,10 页) 答案来源:所有答案都按官方 Solutions 给出。「为什么其他选项错」和知识点归属是我补充的。 形式:2 小时 + 10 分钟阅读,闭卷,可用非编程计算器;Part A 30 道选择题 × 2 分 = 60 分,Part B 4 道计算题 × 10 分 = 40 分。
答案速查(官方)
| Q | 答 | Q | 答 | Q | 答 | Q | 答 | Q | 答 |
|---|---|---|---|---|---|---|---|---|---|
| 1 | A | 7 | C | 13 | C | 19 | C | 25 | A |
| 2 | C | 8 | B | 14 | D | 20 | B | 26 | A |
| 3 | A | 9 | D | 15 | D | 21 | A | 27 | B |
| 4 | B | 10 | A | 16 | B | 22 | C | 28 | D |
| 5 | D | 11 | A | 17 | A | 23 | D | 29 | C |
| 6 | C | 12 | B | 18 | D | 24 | B | 30 | B |
按周分布:W01 ×1、W02 ×2、W03 ×3、W04 ×3、W05 ×4(含规则学习 Q4)、W06 ×4、W07 ×3、W08 ×3、W09 ×2、W11 ×2、W12 ×3;Part B 覆盖 W05、W07、W09、W11。W10 Transformer 本卷没考。
Part A:选择题
Q1 学习任务类型 → A
Original question (English) · [2 marks] A property service uses past sales with known prices to predict the sale price of a new home. Which learning task is this?
- A. Supervised regression.
- B. Supervised classification.
- C. Reinforcement learning.
- D. Unsupervised clustering.
题干:用已知成交价的历史房屋数据预测新房价格。
- 答案 A 监督回归:有标签(价格已知)→ 监督;目标是连续数值 → 回归。
- B 分类要求离散类别;C 强化学习没有「带标签样本」,靠奖励交互;D 聚类没有目标标签。
- 知识点:W01 机器学习任务分类
English answer (Official): A — Learning tasks. The target is a known numeric price. Learning from labelled examples to predict a continuous target is supervised regression.
Q2 kNN 流水线里标准化参数从哪来 → C
Original question (English) · [2 marks] A k-NN pipeline uses a standard scaler. When evaluating the pipeline on a held-out test set, how should the scaling parameters be obtained?
- A. Estimate them from the combined training and test sets.
- B. Standardise each test example separately using its own feature values.
- C. Estimate means and standard deviations from the training set, then apply them to both sets.
- D. Estimate them from the test set, then apply them to the training set.
- 答案 C:在训练集上估计均值和标准差,再用同一组参数变换训练集和测试集。
- A、D 用到了测试集统计量 → 数据泄漏;B 每个测试样本用自己的值标准化,变换后特征没有意义(单个样本的「标准差」无从谈起),而且与训练集尺度不一致。
- 知识点:W02 标准化与 kNN、W04 评估流程
English answer (Official): C — k-NN preprocessing. Preprocessing must be fitted using training data only. Test-set statistics would leak information into model development.
Q3 不加权 vs 反距离平方加权投票 → A
Original question (English) · [2 marks] The three selected neighbours have (class, distance) pairs (Red, 2), (Blue, 3) and (Blue, 4). What do unweighted voting and inverse-square weighted voting predict, respectively?
- A. Unweighted Blue; weighted Red.
- B. Both Blue.
- C. Unweighted Red; weighted Blue.
- D. Both Red.
三个近邻 (Red, 2)、(Blue, 3)、(Blue, 4)。
- 不加权:Red 1 票,Blue 2 票 → Blue。
- 加权(权重
):Red ;Blue → Red。 - 所以「不加权 Blue、加权 Red」= A。离得最近的那个点在加权后权重翻盘,这是题目的设计点。
- 知识点:W02 Weighted Nearest Neighbour
图解
flowchart LR
N(("新样本"))
N -->|"d=2, w=1/4=0.25"| R1["Red"]
N -->|"d=3, w=1/9≈0.111"| B1["Blue"]
N -->|"d=4, w=1/16≈0.063"| B2["Blue"]
R1 --> V1["不加权: Red 1 票, Blue 2 票 → Blue"]
B1 --> V1
B2 --> V1
R1 --> V2["加权: Red 0.25 > Blue 0.174 → Red"]
B1 --> V2
B2 --> V2
English answer (Official): A — Weighted k-NN. Unweighted votes are Red = 1 and Blue = 2. Weighted votes are Red = 1/4 = 0.25 and Blue = 1/9 + 1/16 ≈ 0.174, so the weighted prediction is Red.
Q4 PRISM 为规则再加一个条件的目的 → B
Original question (English) · [2 marks] While growing a PRISM rule for class Yes, the current rule covers both Yes and No examples. What is the purpose of adding a further condition?
- A. Make the rule cover every training example.
- B. Restrict the covered set to improve its purity for class Yes.
- C. Force the rule to include every available attribute.
- D. Turn each Yes example into a separate output class.
- 答案 B:每加一个条件就是在合取式上多一个限制,缩小覆盖集,提高对 Yes 类的纯度(把混进来的 No 排除掉)。
- A 正好相反(加条件只会让覆盖变少);C PRISM 不要求用上所有属性,纯了就停;D 胡扯。
- 知识点:规则学习(1R / PRISM)。周总结里没有单独成节,最接近的是 W05 决策树(树的每条路径就是一条合取规则)。
English answer (Official): B — PRISM. A conjunction adds a restriction. PRISM seeks a rule whose covered examples are pure for the target class; adding conditions can remove covered negatives.
Q5 降低单个大残差影响 → D
Original question (English) · [2 marks] A regression model has one unusually large residual. Which change would reduce the relative influence of that residual on the reported loss?
- A. Use MSE instead of MAE.
- B. Square the residuals twice before averaging.
- C. Report the largest squared residual as the loss.
- D. Use MAE instead of MSE.
- 答案 D 用 MAE 代替 MSE:MAE 随残差线性增长,MSE 平方增长,离群点在 MSE 里被放大。
- A 方向反了;B 四次方更放大;C 只看最大残差,离群点直接决定整个损失。
- 知识点:W03 三类误差
English answer (Official): D — Regression losses. MAE grows linearly with residual magnitude, whereas MSE grows quadratically. The outlier therefore has less relative influence under MAE.
Q6 L1 让多个系数恰好为 0 → C
Original question (English) · [2 marks] Two otherwise comparable linear models are fitted. One uses an L1 penalty and gives several coefficients exactly equal to zero. What property does this illustrate?
- A. L1 regularisation requires all features to remain in the fitted model.
- B. L1 regularisation always improves test accuracy.
- C. L1 regularisation can produce sparse coefficient vectors.
- D. L1 regularisation removes the need for choosing a penalty strength.
- 答案 C:L1(Lasso)能产生稀疏系数向量,相当于自动做特征选择。
- A 反了;B 正则化不保证提高测试精度;D 惩罚强度 λ 仍需调(交叉验证)。
- 知识点:W03 正则化
English answer (Official): C — Regularisation. The L1 penalty can set coefficients exactly to zero. Its strength still needs to be selected, and better test performance is not guaranteed.
Q7 最小二乘截距与预测 → C
Original question (English) · [2 marks] For a simple least-squares fit, the mean of x is 3, the mean of y is 7, Sxy = 10 and Sxx = 5. What are the intercept and the prediction at x = 5?
- A. Intercept 1; prediction 9.
- B. Intercept 7; prediction 17.
- C. Intercept 1; prediction 11.
- D. Intercept 2; prediction 12.
- 答案 C(截距 1,预测 11)。A 的 9 是算成了
之类;B、D 截距错。 - 知识点:W03 最小二乘
English answer (Official): C — Least squares. The slope is 10/5 = 2. The intercept is 7 - 2×3 = 1. At x = 5, the prediction is 1 + 2×5 = 11.
Q8 Laplace 平滑解决什么 → B
Original question (English) · [2 marks] A binary feature combination never occurs with class No in a small training sample. Without smoothing, one estimated likelihood is zero. What problem can Laplace smoothing address?
- A. The classifier otherwise cannot accept categorical features.
- B. A single unseen feature value otherwise makes the product likelihood zero for that class.
- C. The class priors must otherwise sum to more than one.
- D. Smoothing otherwise has to delete every correlated feature.
- 答案 B:朴素贝叶斯把各特征似然相乘,只要一个似然为 0,整类得分就是 0(零频问题)。平滑给未见取值一个非零估计。
- A 朴素贝叶斯本来就能处理类别特征;C 先验之和永远是 1;D 平滑与删特征无关。
- 知识点:W04 零频问题
English answer (Official): B — Naive Bayes. Naive Bayes multiplies feature likelihoods. A zero factor makes the class score zero; smoothing supplies nonzero estimates for unseen categorical values.
Q9 调树深度同时保留独立的性能估计 → D
Original question (English) · [2 marks] A team wants to choose the maximum depth of a decision tree while retaining an independent estimate of final performance. Which procedure is appropriate?
- A. Choose the depth that maximises test accuracy, and report that same accuracy.
- B. Use the deepest tree because training accuracy is the final performance estimate.
- C. Merge test labels into the training set before selecting depth.
- D. Tune depth on validation data or training-set cross-validation, then evaluate once on the reserved test set.
- 答案 D:用验证集或训练集上的交叉验证选深度,最后在保留的测试集上只评估一次。
- A 用测试集调参再报告同一个分数 → 乐观偏差;B 训练精度不是泛化估计;C 把测试标签并入训练,测试集就不独立了。
- 知识点:W04 评估流程
English answer (Official): D — Evaluation. Validation or training-set cross-validation supports model selection. An untouched test set is used once to estimate the selected model’s performance.
Q10 精确率与召回率 → A
Original question (English) · [2 marks] A binary classifier has TP = 12, FP = 4, FN = 8 and TN = 26. What are positive-class precision and recall?
- A. Precision 0.75; recall 0.60.
- B. Precision 0.24; recall 0.76.
- C. Precision 0.60; recall 0.75.
- D. Precision 0.75; recall 0.68.
- 答案 A。C 把两者颠倒了;TN 不进入这两个指标。
- 知识点:W04 性能度量
English answer (Official): A — Classification metrics. Precision = 12/(12+4) = 0.75. Recall = 12/(12+8) = 0.60. True negatives do not enter these two positive-class measures.
Q11 两个划分比较 → A
Original question (English) · [2 marks] Two candidate splits are applied to the same decision-tree parent node. Split X has lower size-weighted child entropy than split Y. What follows?
- A. Split X has higher information gain.
- B. The two splits must have equal information gain.
- C. Split Y has higher information gain.
- D. The parent entropy must be zero.
,父节点熵固定。加权子节点熵越小,减掉的越少,增益越大 → X 的 IG 更高,A。- B、C 与推理矛盾;D 父熵是否为 0 无法推出(为 0 时两个划分都没有增益)。
- 知识点:W05 熵与信息增益
English answer (Official): A — Decision trees. Information gain subtracts weighted child entropy from a fixed parent entropy. A smaller subtracted quantity gives a larger gain.
Q12 Bagging 的定义性操作 → B
Original question (English) · [2 marks] What is the defining training-data operation used in bagging?
- A. Use the test set as an additional bootstrap training sample.
- B. Fit base learners on bootstrap samples drawn with replacement.
- C. Partition the features once and assign exactly one feature to each learner.
- D. Fit each learner only on the examples misclassified by the previous learner.
- 答案 B:在有放回抽样的 bootstrap 样本上训练各个基学习器。
- A 用测试集训练是泄漏;C 是一种(不常见的)随机子空间变体,不是 bagging 的定义;D 是 boosting 的思路。
- 知识点:W05 Bagging
English answer (Official): B — Bagging. Bagging trains base learners on bootstrap samples of the training observations. Sampling with replacement creates varied datasets.
Q13 平方损失下梯度提升树的训练目标 → C
Original question (English) · [2 marks] Under squared-error loss, a later regression tree is trained to correct what the current ensemble has not explained. What are the appropriate training targets for this later tree?
- A. Current ensemble predictions minus the observed targets.
- B. The current ensemble predictions themselves.
- C. Observed targets minus the current ensemble predictions.
- D. The original targets without accounting for current predictions.
- 答案 C 残差
:平方损失的负梯度正好是「观测值 − 当前预测」,新树去拟合还没解释的部分。 - A 符号反了(拟合它再相加会把误差放大);B、D 没有利用当前误差。
- 知识点:W05 Boosting
English answer (Official): C — Gradient boosting. For squared-error gradient boosting, the residual target is observed value minus current prediction, so the learner aims to correct the remaining error.
Q14 两个支持平面之间的距离 → D
Original question (English) · [2 marks] A hard-margin SVM uses support planes wᵀx + b = +1 and wᵀx + b = -1, with w = (3, 4). What is the full distance between the planes?
- A. 0.20.
- B. 2.50.
- C. 5.00.
- D. 0.40.
- 答案 D。A 的 0.20
是决策面到一侧支持平面的距离
,题目问的是两平面之间的全宽。B、C 是把 放到分子上了。 - 知识点:W06 间隔与支持向量
图解
flowchart LR
H1["支持平面 w·x+b=+1"] ---|"1/‖w‖ = 0.2"| H["决策面 w·x+b=0"]
H ---|"1/‖w‖ = 0.2"| H2["支持平面 w·x+b=−1"]
H1 -.->|"全宽 2/‖w‖ = 0.4(答案)"| H2
English answer (Official): D — SVM margin. The norm is √(3²+4²) = 5. The full margin width is 2/5 = 0.40; 1/5 is the distance from the decision plane to one support plane.
Q15 核 SVM 为什么不必显式存储映射后的向量 → D
Original question (English) · [2 marks] Why can a kernel SVM operate without explicitly storing each transformed feature vector?
- A. Every nonlinear kernel creates a linear boundary in the original input space.
- B. The kernel replaces the class labels with distances.
- C. The kernel removes all dependence on training observations.
- D. Its optimisation and predictions can use inner products supplied by the kernel.
- 答案
D:对偶形式的优化和预测只用到内积,核函数直接给出
(核技巧)。 - A 错:非线性核在原空间里给的是非线性边界;B 核不替换标签;C 预测仍依赖支持向量(训练样本)。
- 知识点:W06 核技巧
English answer (Official): D — Kernel methods. A kernel computes the inner product of implicit feature mappings. The SVM can use these values without forming the mapped vectors explicitly.
Q16 PCA 前缩放会改变第一主成分 → B
Original question (English) · [2 marks] PCA is applied to two measurements recorded in very different units. Why might scaling the measurements before PCA change the first component?
- A. PCA uses class labels to choose which unit should dominate.
- B. PCA is driven by variance, and changing units changes relative feature variances.
- C. Scaling converts PCA from an unsupervised method into a supervised method.
- D. PCA always gives the same direction under arbitrary feature rescaling.
- 答案 B:PCA 由方差驱动,换单位就改变各特征的相对方差,数值大的特征会主导第一主成分。
- A、C PCA 是无监督的,不用标签;D 正好是错的。
- 知识点:W06 PCA
English answer (Official): B — PCA. Feature-wise rescaling changes the covariance structure. A large numerical scale can dominate a covariance-based PCA unless scaling is handled deliberately.
Q17 保留至少 85% 方差 → A
Original question (English) · [2 marks] There are exactly four principal components with variances 9, 5, 4 and 2, in descending order. What is the smallest number of leading components needed to retain at least 85% of total variance?
- A. Three components, retaining 90%.
- B. Four components, retaining 100%.
- C. Three components, retaining 85%.
- D. Two components, retaining 70%.
总方差
- C 的「85%」数字算错;B 不是最少;D 不达标。
- 知识点:W06 选几个主成分
English answer (Official): A — PCA retained variance. Total variance is 20. Two components retain 14/20 = 70%, whereas three retain 18/20 = 90%. Three is therefore the smallest qualifying number.
Q18 ReLU 负输入 → D 0
Original question (English) · [2 marks] A ReLU unit has a negative pre-activation. What is its output?
- A. One.
- B. The unchanged negative pre-activation.
- C. A probability strictly between zero and one.
- D. Zero.
- 知识点:W07 激活函数
English answer (Official): D — Neural activations. ReLU(u) = max(0,u), so negative pre-activations produce zero. ReLU does not itself return a probability.
Q19 感知机更新 → C
Original question (English) · [2 marks] A perceptron has w = (0.4, -0.2), b = 0.1 and learning rate 0.2. For x = (2, 1), the supplied actual output is a = 1 and target is t = 0. What are the updated weights and bias?
- A. w = (0.0, -0.4); b = 0.1.
- B. w = (0.8, 0.0); b = 0.3.
- C. w = (0.0, -0.4); b = -0.1.
- D. w = (0.4, -0.2); b = -0.1.
- 答案 C。A 忘了更新偏置(偏置的「输入」恒为 1);B 符号反了;D 只更新了偏置。
- 知识点:W07 感知机学习规则
English answer (Official): C — Perceptron update. The correction is η(t-a) = -0.2. Thus wnew = (0.4,-0.2) - 0.2(2,1) = (0,-0.4), and bnew = 0.1 - 0.2 = -0.1.
Q20 同一个边缘检测器用在整张图上 → B 权重共享
Original question (English) · [2 marks] A learned convolutional filter detects the same edge pattern at many image locations. Which design feature enables this with a small number of parameters?
- A. Discarding the spatial arrangement before convolution.
- B. Sharing the filter weights across spatial locations.
- C. Using an independent parameter vector for every pixel location.
- D. Fixing every convolution weight to the same constant.
- A 卷积恰恰保留空间结构;C 每个位置独立参数就是全连接,参数量爆炸;D 权重是学出来的。
- 知识点:W08 卷积层
English answer (Official): B — CNNs. Weight sharing reuses one detector across the image. Each spatial position does not need its own independently learned filter.
Q21 RNN 中把信息带到下一步的是 → A 循环隐状态
Original question (English) · [2 marks] In a simple recurrent neural network, what carries information from an earlier time step into the next one?
- A. The recurrent hidden state.
- B. A distinct set of unshared recurrent weights for every sequence position.
- C. A new independent label for each hidden unit.
- D. A separate test set at every time step.
- B 错:循环权重在各时间步共享;C、D 无关。
- 知识点:W08 简单 RNN
English answer (Official): A — RNNs. The hidden state is updated using the current input and previous hidden state. Recurrent weights are shared across time.
Q22 卷积层参数量 → C 76
Original question (English) · [2 marks] A convolutional layer has four 3 × 3 filters and receives two input channels. Each filter spans both input channels and has one bias. How many trainable parameters are there?
- A. 72.
- B. 22.
- C. 76.
- D. 40.
每个滤波器
- A 72 忘了偏置;D 40 漏了输入通道维度,只算了
;B 22 远小于正确值,同样是没把「每个滤波器跨越全部输入通道」算进去。 - 知识点:W08 多通道输入
图解
flowchart LR
I["输入 2 通道"] --> F["每个滤波器 3×3×2 = 18 权重 + 1 偏置 = 19"]
F --> T["4 个滤波器 × 19 = 76"]
English answer (Official): C — CNN parameters. Each filter has 3×3×2 = 18 weights and one bias, giving 19 parameters. Four filters give 4×19 = 76.
Q23 Dropout 的目的 → D
Original question (English) · [2 marks] During standard dropout training, why are different subsets of hidden activations temporarily disabled across updates?
- A. To permanently delete every unit disabled at least once.
- B. To make all hidden units produce exactly the same feature.
- C. To replace supervised targets with random labels.
- D. To reduce reliance on particular hidden-unit combinations and help limit overfitting.
- 答案 D:减少对特定隐藏单元组合的依赖(防止共适应),起正则化作用、抑制过拟合。
- A 单元不会被永久删除;B 恰恰相反,要让单元各自有用;C 标签不变。
- 知识点:W07 现代深度网络的技巧
English answer (Official): D — Dropout. Dropout discourages co-adaptation by training with changing subsets of units. It is a regularisation technique; units are not permanently deleted.
Q24 平方欧氏距离下簇的最优代表点 → B 坐标均值
Original question (English) · [2 marks] A cluster contains several points and K-means uses squared Euclidean distance. Which representative minimises the sum of squared distances within that fixed cluster?
- A. The coordinate-wise maximum.
- B. The coordinate-wise mean of its points.
- C. The most distant observed point.
- D. Any randomly selected point, with the same objective value.
对固定簇,
- 知识点:W09 K-means
English answer (Official): B — K-means. For fixed assignments and squared Euclidean loss, the arithmetic mean minimises the within-cluster sum of squared distances.
Q25 GMM 后验隶属度 → A ≈ 0.462
Original question (English) · [2 marks] At observation x, a two-component GMM has π₁ = 0.3, π₂ = 0.7, f₁(x) = 0.4 and f₂(x) = 0.2. What is the posterior membership probability for component 1?
- A. Approximately 0.462.
- B. 0.120.
- C. 0.300.
- D. Approximately 0.538.
- B 0.120 是没归一化的分子;C 0.300 是先验;D 0.538 是分量 2 的隶属度。
- 知识点:W09 GMM
English answer (Official): A — GMM membership. The component scores are 0.3×0.4 = 0.12 and 0.7×0.2 = 0.14. Normalising gives 0.12/(0.12+0.14) ≈ 0.462.
Q26 Viterbi 解决什么 → A 最可能的完整隐状态路径(解码问题)
Original question (English) · [2 marks] For a fixed HMM and an observed sequence, which task is solved by the Viterbi algorithm?
- A. Find the most probable complete hidden-state path.
- B. Sum probabilities over all possible observation alphabets.
- C. Calculate a posterior mixture weight without using transitions.
- D. Estimate the number of observed features by PCA.
- B 无意义;C 不用转移就不是 HMM 了;D 与 HMM 无关。评估问题用 Forward,学习问题用 EM(Baum-Welch)。
- 知识点:W11 HMM 三个问题
English answer (Official): A — HMM tasks. Viterbi performs decoding: dynamic programming finds the single most probable hidden-state sequence for the observations and model.
Q27 两步后处于 B 的概率 → B 0.52
Original question (English) · [2 marks] A two-state Markov chain starts in A. Its transitions are P(A|A) = 0.6, P(B|A) = 0.4, P(A|B) = 0.3 and P(B|B) = 0.7. What is the probability of being in B after exactly two transitions?
- A. 0.48.
- B. 0.52.
- C. 0.24.
- D. 0.28.
两条路径:A→A→B
- C、D 只算了其中一条路径;A 0.48 是两步后处于 A 的概率。
- 知识点:W11 马尔可夫链
图解
flowchart LR
S(("t0: A")) -->|0.6| A1(("t1: A"))
S -->|0.4| B1(("t1: B"))
A1 -->|0.4| AB["A→A→B = 0.24"]
B1 -->|0.7| BB["A→B→B = 0.28"]
AB --> P["P(t2 = B) = 0.24 + 0.28 = 0.52"]
BB --> P
English answer (Official): B — Markov chains. The two routes are A→A→B and A→B→B, with probabilities 0.6×0.4 and 0.4×0.7. Their sum is 0.24 + 0.28 = 0.52.
Q28 经验回放主要减少 → D 相邻训练样本的时间相关性
Original question (English) · [2 marks] A DQN trains on randomly sampled stored transitions rather than only the newest consecutive transitions. What does this sampling primarily help reduce?
- A. All approximation error, regardless of network capacity.
- B. The number of actions permitted by the environment.
- C. The need for a reward signal from the environment.
- D. Temporal correlation between training examples used in successive updates.
- A 不可能消除全部近似误差;B 动作数由环境决定;C 仍需要奖励。
- 知识点:W12 DQN 经验回放
English answer (Official): D — Experience replay. Random minibatches from a replay buffer break up the strong correlations present in consecutive environment interactions and also reuse past experience.
Q29 目标网络参数固定若干步 → C 让自举目标更稳定
Original question (English) · [2 marks] A DQN holds the target-network parameters fixed for several online-network updates. What is the main intended benefit?
- A. Force every action to be chosen with equal probability.
- B. Remove rewards from the Q-learning target.
- C. Make the bootstrap targets more stable during those updates.
- D. Stop the online network from learning at all.
- A 是探索策略的事;B 目标里仍有奖励;D 在线网络照常更新。
- 知识点:W12 目标网络
English answer (Official): C — Target networks. A fixed target network slows changes to the values used for bootstrapping. The online network still updates, and exploration is a separate issue.
Q30 Q-learning 更新 → B 3.50
Original question (English) · [2 marks] For a non-terminal transition, Q_old(s,a) = 1, α = 0.5, reward r = 2, γ = 0.8 and max Q(s′,a′) = 5. What is the updated value?
- A. 2.50.
- B. 3.50.
- C. 6.00.
- D. 4.00.
- C 6.00 是目标值本身(相当于 α = 1);A、D 算错了折扣或学习率。
- 知识点:W12 Q-learning 更新规则
English answer (Official): B — Q-learning. The target is 2 + 0.8×5 = 6. The update is 1 + 0.5(6-1) = 3.5.
Part B:计算题
Q31 熵与信息增益(10 分)
Original question (English) · Question 31. Entropy and information gain [10 marks]
A decision-tree node contains eight examples: four positive and four negative. A proposed split produces child L with three positives and one negative, and child R with one positive and three negatives. Use 0 log₂0 = 0.
- [5 marks] Calculate the entropy of the parent and each child, in bits.
- [5 marks] Calculate the size-weighted child entropy and the information gain. Round non-integer results to three decimal places.
父节点 4 正 4 负;划分后 L = 3 正 1 负,R = 1 正 3 负。
(a) 熵(5 分)
(b) 加权子熵与信息增益(5 分)
两个子节点各 4 个样本,权重都是
评分:(a) 父熵 1 分 + 每个子节点 2 分;(b) 权重与加权熵 2 分、相减 2 分、最终取整 1 分。
知识点:W05 熵与信息增益
图解
flowchart TD
P["父节点 4+ / 4−<br/>H = 1"] -->|"权重 4/8"| L["L: 3+ / 1−<br/>H = 0.811"]
P -->|"权重 4/8"| R["R: 1+ / 3−<br/>H = 0.811"]
L --> W["加权子熵 = 0.5×0.811 + 0.5×0.811 = 0.811"]
R --> W
W --> G["IG = 1 − 0.811 = 0.189"]
English answer (Official)
H(parent) = −0.5 log₂0.5 − 0.5 log₂0.5 = 1 bit. Each child has class proportions 0.75 and 0.25, so H(L) = H(R) = −0.75 log₂0.75 − 0.25 log₂0.25 = 0.75×0.4150 + 0.25×2 = 0.81125 ≈ 0.811 bits.
Each child holds 4 of the 8 examples, so both weights are 4/8 = 0.5. Weighted child entropy = 0.5×0.81125 + 0.5×0.81125 = 0.811 bits. IG = 1 − 0.81125 = 0.18875 ≈ 0.189 bits.
Q32 前向传播与换激活函数(10 分)
Original question (English) · Question 32. Forward pass and activation change [10 marks]
A network receives x₁ = 1 and x₂ = 3. Its hidden units use ReLU and its output uses a sigmoid. The equations (shown as an image in the paper) are u_A = x₁ + x₂ − 3, u_B = 2x₁ − x₂, h = ReLU(u), z = h_A + 2h_B, output = σ(z). Predict class 1 when the output is at least 0.5; otherwise predict class 0. Use e ≈ 2.718 if needed. The identity activation returns its input unchanged.
- [5 marks] Calculate u_A, u_B, h_A and h_B.
- [5 marks] Calculate z, the output probability and the predicted class. Then replace only unit B's ReLU by the identity activation h_B = u_B. Give the new probability and class. Round probabilities to three decimal places.
题目里的方程是图片,原式为:
输入
(a)(5 分)
(b)(5 分)
- 两个都是 ReLU:
, → 类 1。 - 只把 B 换成恒等激活:
,仍为 1, , → 类 0。分类结果翻转。
评分:(a) 预激活 2 分、激活 3 分;(b) 原输出与类别 2 分、修改后计算与类别 3 分。
要点:ReLU 把负的
知识点:W07 多层感知机与前向传播
图解
flowchart LR
x1(("x₁ = 1")) -->|"+1"| uA["u_A = 1+3−3 = 1<br/>ReLU → h_A = 1"]
x2(("x₂ = 3")) -->|"+1"| uA
x1 -->|"+2"| uB["u_B = 2−3 = −1<br/>ReLU → h_B = 0"]
x2 -->|"−1"| uB
uA -->|"×1"| z["z = 1 + 2×0 = 1"]
uB -->|"×2"| z
z --> o["σ(1) ≈ 0.731 → 类 1"]
uB -.->|"B 改恒等: h_B = −1"| z2["z = 1 − 2 = −1<br/>σ(−1) ≈ 0.269 → 类 0"]
English answer (Official)
u_A = 1 + 3 − 3 = 1; u_B = 2×1 − 3 = −1. Applying ReLU: h_A = 1, h_B = max(0, −1) = 0.
With both ReLUs: z = 1 + 2×0 = 1, output = 1/(1 + e⁻¹) ≈ 0.731 → class 1. With the identity activation at B only: h_B = −1 while h_A stays 1, so z = 1 + 2×(−1) = −1, output ≈ 0.269 → class 0. The predicted class changes, because ReLU had been clipping the negative contribution of unit B to zero.
Q33 K-means 一轮(10 分)
Original question (English) · Question 33. One K-means iteration [10 marks]
Run one complete K-means iteration with k = 2. Use initial centroids μ₁ = A and μ₂ = D. Assign every point using these initial centroids before updating either centroid. Points: A (0,1), B (2,1), C (6,3), D (8,3). Use the coordinate-wise mean.
- [5 marks] Calculate the squared distance from each point to each initial centroid and give all cluster assignments.
- [5 marks] Calculate the coordinates of both updated centroids.
点 A(0,1)、B(2,1)、C(6,3)、D(8,3);k = 2,初始
(a) 平方距离与分配(5 分)
| 点 | 到 μ₁ = (0,1) | 到 μ₂ = (8,3) | 分配 |
|---|---|---|---|
| A | 0 | 64 + 4 = 68 | 1 |
| B | 4 + 0 = 4 | 36 + 4 = 40 | 1 |
| C | 36 + 4 = 40 | 4 + 0 = 4 | 2 |
| D | 64 + 4 = 68 | 0 | 2 |
簇 1 = {A, B},簇 2 = {C, D}。
(b) 更新质心(5 分)
评分:(a) 距离对 4 分 + 分配 1 分;(b) 均值方法 2 分 + 两个质心 3 分。
易错:题目要求先用初始质心把所有点都分配完再更新(批量 K-means),不要分一个点就更新一次。
知识点:W09 K-means
图解
flowchart LR
m1(("μ₁ = A(0,1)"))
m2(("μ₂ = D(8,3)"))
A["A(0,1)"] -->|"0"| m1
B["B(2,1)"] -->|"4(vs 40)"| m1
C["C(6,3)"] -->|"4(vs 40)"| m2
D["D(8,3)"] -->|"0"| m2
m1 --> n1["新 μ₁ = 均值(A,B) = (1,1)"]
m2 --> n2["新 μ₂ = 均值(C,D) = (7,3)"]
English answer (Official)
Squared distances (to μ₁ = (0,1), to μ₂ = (8,3)): A (0, 68), B (4, 40), C (40, 4), D (68, 0). Assign each point to the nearer centroid: cluster 1 = {A, B}, cluster 2 = {C, D}.
μ₁,new = ((0+2)/2, (1+1)/2) = (1, 1); μ₂,new = ((6+8)/2, (3+3)/2) = (7, 3).
Q34 HMM 序列似然(10 分)
Original question (English) · Question 34. HMM sequence likelihood [10 marks]
An HMM has states A and B and observations x and y. The observed sequence is (x, y). Priors: π(A) = 0.7, π(B) = 0.3. Emissions: e_A(x) = 0.6, e_A(y) = 0.4, e_B(x) = 0.2, e_B(y) = 0.8. Transitions (rows = current, columns = next): A→A 0.8, A→B 0.2, B→A 0.3, B→B 0.7.
- [5 marks] Calculate f₁(A) and f₁(B).
- [5 marks] Use the Forward algorithm to calculate f₂(A), f₂(B) and P(x,y). Give final probabilities to four decimal places.
| 状态 | π | e(x) | e(y) | → A | → B |
|---|---|---|---|---|---|
| A | 0.7 | 0.6 | 0.4 | 0.8 | 0.2 |
| B | 0.3 | 0.2 | 0.8 | 0.3 | 0.7 |
观测序列 (x, y)。
(a)(5 分)初始化
注意这是「第一个观测 + 处于该状态」的联合概率,不是归一化后的后验。
(b)(5 分)递推
评分:(a) 「初始 × 发射」规则 1 分 + 每个值 2 分;(b) 每个前向概率 2 分 + 总和 1 分。
易错:Forward 是求和,Viterbi 是取最大;转移表行是当前状态、列是下一状态,别读反。
知识点:W11 Forward 算法
图解
flowchart LR
s1A["t=1 A<br/>f₁(A) = 0.7×0.6 = 0.42"]
s1B["t=1 B<br/>f₁(B) = 0.3×0.2 = 0.06"]
s2A["t=2 A<br/>0.4×(0.336+0.018) = 0.1416"]
s2B["t=2 B<br/>0.8×(0.084+0.042) = 0.1008"]
s1A -->|"×0.8 = 0.336"| s2A
s1B -->|"×0.3 = 0.018"| s2A
s1A -->|"×0.2 = 0.084"| s2B
s1B -->|"×0.7 = 0.042"| s2B
s2A --> P["P(x,y) = 0.1416 + 0.1008 = 0.2424"]
s2B --> P
English answer (Official)
f₁(A) = π(A)·e_A(x) = 0.7×0.6 = 0.42; f₁(B) = 0.3×0.2 = 0.06. (These are joint probabilities of the first observation and the state, not normalised posteriors.)
f₂(A) = e_A(y)·[f₁(A)a_AA + f₁(B)a_BA] = 0.4×(0.42×0.8 + 0.06×0.3) = 0.4×0.354 = 0.1416. f₂(B) = e_B(y)·[f₁(A)a_AB + f₁(B)a_BB] = 0.8×(0.42×0.2 + 0.06×0.7) = 0.8×0.126 = 0.1008. P(x,y) = f₂(A) + f₂(B) = 0.2424.
本卷的考法小结
- 计算型选择题占三分之一(Q3、7、10、14、17、19、22、25、27、30),全都是一两步就能算完的公式题,背熟公式就是送分。
- 干扰项的套路:只算一半(Q14 的 0.20、Q27 的 0.24/0.28)、漏掉偏置(Q19、Q22)、未归一化(Q25 的 0.12)、学习率当成 1(Q30 的 6.00)。
- 概念题围绕「为什么」:标准化在哪拟合、测试集只用一次、L1 稀疏、核技巧只用内积、经验回放去相关、目标网络稳目标。
- Part B 四道都是固定套路:信息增益、前向传播、K-means 一轮、HMM Forward。另一套卷子见 Practice Exam 2 解析。