Final 问答|N 回归、聚类、神经网络
Final 双语问答 N 回归、聚类、神经网络:中英题面,逐题折叠中文答案、英文答卷模板与回查出处。非官方。
手机上宽表格可左右滑动;自测答案默认收起,点击题目下方按钮查看。
使用边界:期末复习,非官方材料。考试安排按课程公告整理,正式要求以讲师通知和课堂公告为准。本页是同学整理的双语问答,英文可作答卷模板,题目是整理出来的常见问法,不是预测卷。
复习资料:考试安排与范围地图 · 专家系统与推荐系统 · Agent 与生成式 AI
先做题再看解析:G 往年卷:搜索、逻辑、概率 · H 往年卷:CNN 与神经网络 · I 往年卷:延伸与简答 · J 判断 1–25 · K 判断 26–50 · L 选择题 · M 问答:搜索、逻辑、概率 · N 问答:回归、聚类、神经网络 · O 问答:CNN、RNN 与拓展 · P 期中后新内容
怎么做:先只看题面,用英文写出答案要点,再展开核对;简答题先下结论再给理由;页码为 PDF 页序。
N 回归、聚类、神经网络
底稿问答 Q26–Q49,按「回归、优化与诊断」「K-means」「神经网络」三组排列。「回查」里标了往年卷题号的,表示出过同类题型,不表示今年会出原题。
回归、优化与诊断:N1–N9。
N1 · Q26 State the model, objective and parameters of linear regression.
线性回归的模型、目标、参数是什么?
State the model, objective and parameters of linear regression.
N1 · 查看答案与解析
答案:一元模型 ŷ=wx+b;w 是斜率,b 是截距,x 是输入。常用 J=(1/(2m))Σᵢ(wxᵢ+b−yᵢ)²,选择 w、b 使 J 小。1/2 是方便求导的常数,不改变纯平方误差的最小点,但会改变同一学习率下的梯度步长。多特征模型是 ŷ=wᵀx+b。
English: A one-feature linear regression model is ŷ=wx+b, where w is the slope and b the intercept. A common objective is J=(1/(2m))Σᵢ(wxᵢ+b−yᵢ)². Training chooses w and b to minimize J. The factor 1/2 simplifies derivatives and does not change the minimizer of the unregularized squared loss, but it changes gradient magnitudes. With multiple features, ŷ=wᵀx+b.
回查:L04b p.3–16。
N2 · Q27 Why use the negative gradient and simultaneous updates?
为什么沿负梯度更新?为什么同步更新?
Why use the negative gradient and simultaneous updates?
N2 · 查看答案与解析
答案:梯度指向局部增长最快方向,足够小步长的负梯度步能降低可微目标。每个偏导都应在同一组旧参数上计算,才能形成一次标准梯度下降 θ_new=θ_old−α∇J(θ_old)。如果先改 b 再把新 b 代入求 w,就换成另一更新过程,不是题目规定的同步 GD。
English: The gradient points toward the steepest local increase, so a sufficiently small step in the negative gradient direction decreases a differentiable objective. All partial derivatives for one standard gradient-descent step are evaluated at the same old parameter vector. Updating one parameter and using its new value to compute another update is a different procedure from simultaneous gradient descent.
回查:L04b p.18–26。
N3 · Q28 What happens if the learning rate is too small or too large?
学习率太小或太大有什么现象?
What happens if the learning rate is too small or too large?
N3 · 查看答案与解析
答案:太小通常下降慢;合适时较快且稳定;太大可能跨过最小值、振荡甚至发散。下降法不是每个任意步长都保证下降。看损失对迭代曲线判断时先确认横轴;不要与误差对训练集大小的学习曲线混淆。
English: A very small learning rate usually gives slow progress. A suitable rate can converge efficiently, while an excessive rate may overshoot, oscillate or diverge. Gradient descent does not guarantee a decrease for every arbitrary step size. Check that the horizontal axis is training iteration rather than training-set size before interpreting the curve.
回查:L04b p.27、F25 Q6。
N4 · Q29 Distinguish parameters from hyperparameters.
参数与超参数有什么区别?
Distinguish parameters from hyperparameters.
N4 · 查看答案与解析
答案:参数由训练拟合,例如线性回归 w、b、神经网络权重、K-means 中心。超参数规定训练或结构,例如 α、λ、K、层数、隐藏单元数。通常用训练集学参数,用验证集选超参数。notebook 把 w/b 随口叫 hyperparameters 的地方不应照背。
English: Parameters are fitted during training, such as regression weights, neural-network biases and K-means centroids. Hyperparameters specify learning settings or model structure, such as learning rate, regularization strength, K and hidden-layer width. Parameters are fitted using training data, while hyperparameters are usually selected using validation data.
回查:L04b、L04c、L06。
N5 · Q30 Why separate training, validation and test data?
为什么需要三个数据集?为什么不能用 test 调参?
Why separate training, validation and test data?
N5 · 查看答案与解析
答案:训练集拟合参数;验证集比较模型和超参数;测试集在选择完成后估计泛化。如果反复根据 test 选模型,选择过程就利用了它,报告误差会偏乐观。预处理的均值、标准差、最小最大值也应只在训练集拟合,再应用到验证和测试。60/20/20 等是例子,不是所有任务的硬性规定。
English: Training data fit parameters; validation data guide model and hyperparameter selection; test data estimate final generalization. Repeatedly selecting models using test results makes the test estimate optimistically biased. Preprocessing statistics should also be fitted on training data and then applied to held-out data. Splits such as 60/20/20 are examples, not universal requirements.
回查:L04c p.14–25。
N6 · Q31 How do we diagnose high bias versus high variance?
如何判断高偏差还是高方差?
How do we diagnose high bias versus high variance?
N6 · 查看答案与解析
答案:训练误差高且验证误差也高、差距不大,常是高偏差/欠拟合;训练误差低而验证明显高,常是高方差/过拟合。高偏差可考虑更有表达力模型、更好特征、减小过强正则或训练更充分;高方差可考虑更多有代表性数据、减小容量或加强适量正则。比较前需保证误差定义与数据分布可比。
English: High training and validation errors with a small gap often indicate high bias or underfitting. Low training error with much higher validation error often indicates high variance or overfitting. High bias may call for better features, greater capacity, weaker excessive regularization or sufficient optimization. High variance may call for more representative data, reduced capacity or stronger regularization. Compare errors measured consistently on relevant distributions.
回查:L04c p.27–34。
N7 · Q32 Does more training data always solve poor performance?
更多训练数据总能解决问题吗?
Does more training data always solve poor performance?
N7 · 查看答案与解析
答案:不总能。高偏差时模型连训练集规律都难捕捉,单纯加数据常帮助有限。高方差时更多同分布、有代表性样本常能减少对偶然噪声的依赖,缩小泛化差距。学习曲线以样本量为横轴:高偏差时两条误差在较高位置接近;高方差时存在较明显差距。
English: No. With high bias, the model struggles to fit the underlying pattern even in training data, so additional data alone may help little. With high variance, more representative examples from the relevant distribution often reduce sensitivity to accidental patterns. On learning curves against training-set size, high bias shows high, close errors; high variance often shows a substantial training–validation gap.
回查:L04c p.35–41。
N8 · Q33 Why can regularization reduce overfitting, and is larger λ always better?
正则化为什么能缓解过拟合?λ 越大越好吗?
Why can regularization reduce overfitting, and is larger λ always better?
N8 · 查看答案与解析
答案:正则化在数据损失外加入复杂度代价,使模型不容易为了训练噪声使用过大权重。λ 控制两者权衡,适当增加可能降低方差;过大则限制模型过强,导致高偏差/欠拟合。应根据验证表现选择 λ,比较模型预测误差时使用一致且通常不含惩罚项的评价损失。
English: Regularization adds a complexity penalty to the data-fitting loss, discouraging unnecessarily large weights used to fit noise. λ controls the tradeoff. Increasing it appropriately may reduce variance, but excessive regularization causes high bias and underfitting. Choose λ using validation performance and compare models using a consistent predictive evaluation loss, typically without the training penalty.
回查:L04b p.30–39、L04c p.31–34。
N9 · Q34 Compare L1 and L2 regularization. Which is better?
比较 L1 与 L2,哪一个更好?
Compare L1 and L2 regularization. Which is better?
N9 · 查看答案与解析
答案:L1 惩罚 Σ|w|,常使部分权重为零,可做隐式特征选择;L2 惩罚 Σw²,通常让权重平滑缩小。无普遍更好者:许多无关特征时稀疏模型可能合适;很多特征都有贡献时 L2 常有用。选择依验证数据和任务而定。偏置是否正则化须看题目,常见设置不惩罚偏置。
English: L1 penalizes the sum of absolute weights and often yields sparse solutions, providing implicit feature selection. L2 penalizes squared weights and generally shrinks them smoothly. Neither is universally superior. Sparse solutions may help with many irrelevant features, while L2 can be useful when many features contribute. Select using validation data, and follow the stated convention for regularizing biases.
回查:L04b p.35–39。
K-means:N10–N12。
N10 · Q35 State the K-means objective and algorithm.
写出 K-means 的目标与流程。
State the K-means objective and algorithm.
N10 · 查看答案与解析
答案:目标 J=ΣₖΣₓ∈Cₖ‖x−μₖ‖²。选 K 和初始中心;将每个点分给最近中心;用每簇均值更新中心;重复直到分配或中心不再变化,或满足停止条件。距离比较可使用平方距离,因为平方根是单调的。不能边分配一个点就即时改中心,除非题目明确要求在线变体。
English: K-means minimizes J=ΣₖΣₓ∈Cₖ‖x−μₖ‖². Choose K and initial centroids, assign every point to its nearest centroid, recompute each centroid as the mean of its cluster, and repeat until a stopping condition is met. Squared distances give the same nearest-centroid assignment. Standard batch K-means completes the assignment step before updating centroids.
回查:L05、L04a。
N11 · Q36 Why can K-means converge without finding the global optimum?
K-means 为什么收敛却不保证全局最优?
Why can K-means converge without finding the global optimum?
N11 · 查看答案与解析
答案:固定中心时最近中心分配不会增加 SSE;固定分配时均值最小化该簇平方距离,因此更新也不增加 SSE。SSE 有下界 0,所以标准交替更新会趋于稳定;一致的平局处理与正常非空簇条件下通常停在稳定分配。联合问题非凸,不同初始化可能给不同局部解。可多次随机初始化,选最终 SSE 较小者。
English: With centroids fixed, nearest-centroid assignments do not increase SSE. With assignments fixed, each cluster mean minimizes its squared-error contribution, so the update also does not increase SSE. SSE is bounded below by zero, and standard updates approach a stable result under appropriate tie and empty-cluster handling. The joint problem is nonconvex, so initialization can lead to different local solutions. Multiple restarts can improve the result.
回查:L05。
N12 · Q37 How is K selected, and what are K-means limitations?
怎样选 K?K-means 有什么局限?
How is K selected, and what are K-means limitations?
N12 · 查看答案与解析
答案:可看 SSE 随 K 的肘部并结合任务含义;不能单纯选择 SSE 最小的 K,否则不断增加 K 会偏向更多簇,K=n 可使每点单独成簇、SSE=0。局限包括需要预设 K、对初始化/尺度/离群点敏感、对非球状或密度差异大的簇不理想。每次随机运行的 SSE 不必严格单调,理论最优值则不会随 K 增大而上升。
English: The elbow method looks for diminishing SSE improvement as K increases, combined with domain needs. Minimizing training SSE alone favors excessive clusters; K=n can give zero SSE. K-means requires K in advance and is sensitive to initialization, feature scales and outliers. It may poorly represent non-spherical or uneven-density clusters. The optimal SSE is nonincreasing with K, although separate local runs need not show a perfectly monotonic curve.
回查:L05。
神经网络:N13–N24。
N13 · Q38 How does logistic regression produce a prediction?
逻辑回归如何产生预测?
How does logistic regression produce a prediction?
N13 · 查看答案与解析
答案:先 z=wᵀx+b,再 p=σ(z) 作为正类概率。默认阈值 .5 时,p≥.5 预测正类,即 z≥0;阈值可按题目变化。σ′(z)=σ(z)(1−σ(z))。它能输出非线性变化的概率,但在原始特征空间中的 .5 决策边界仍是 wᵀx+b=0。
English: Logistic regression computes z=wᵀx+b and p=σ(z) as the positive-class probability. With a threshold of 0.5, it predicts the positive class when z≥0. The sigmoid derivative is σ(z)(1−σ(z)). Although probabilities change nonlinearly with z, the default decision boundary is linear in the original feature space.
回查:L06 p.17–20。
N14 · Q39 Why are nonlinear hidden-layer activations needed?
为什么隐藏层要用非线性激活?
Why are nonlinear hidden-layer activations needed?
N14 · 查看答案与解析
答案:若 h=W₁x+b₁,输出 W₂h+b₂,则输出=(W₂W₁)x+(W₂b₁+b₂),仍是一个仿射变换。只堆线性/仿射层不能获得这种意义上的非线性表达能力。ReLU、tanh 等让网络学习复杂非线性关系。不是每层都必须同一种激活;回归输出层常为线性。
English: Without a nonlinear activation, W₂(W₁x+b₁)+b₂ equals one affine transformation, (W₂W₁)x+(W₂b₁+b₂). Stacking affine layers alone therefore does not create nonlinear expressive power. Activations such as ReLU and tanh enable more complex mappings. Different layers may use different activations, and a regression output is often linear.
回查:L06 p.27–41、L07 p.5–7。
N15 · Q40 Derive the sigmoid and tanh derivatives.
推导 sigmoid 和 tanh 的导数。
Derive the sigmoid and tanh derivatives.
N15 · 查看答案与解析
答案:σ=(1+e⁻ᶻ)⁻¹,所以 σ′=e⁻ᶻ/(1+e⁻ᶻ)²=σ(1−σ)。tanh z=(eᶻ−e⁻ᶻ)/(eᶻ+e⁻ᶻ),用商法则得 4/(eᶻ+e⁻ᶻ)²=1−tanh²z。sigmoid 最大导数 .25,在 z=0;tanh 最大导数 1,在 z=0。两者在绝对值很大时导数接近零。
English: Differentiating σ(z)=(1+e⁻ᶻ)⁻¹ gives σ′(z)=e⁻ᶻ/(1+e⁻ᶻ)²=σ(z)(1−σ(z)). Applying the quotient rule to tanh gives tanh′(z)=1−tanh²(z). Sigmoid has maximum derivative 0.25 and tanh has maximum derivative 1, both at zero. Both derivatives approach zero in saturated regions.
回查:L06 p.19、38;F25 Q5.2。
N16 · Q41 Compare four activation functions.
比较 sigmoid、tanh、ReLU、Leaky ReLU。
Compare four activation functions.
N16 · 查看答案与解析
答案:sigmoid 范围 (0,1),适合二分类概率输出,容易饱和;tanh 范围 (−1,1)、零中心,也会饱和;ReLU=max(0,z),正半轴导数 1,计算简单,但负区梯度为零可产生死亡单元;Leaky ReLU 给负区小斜率,缓解这种问题。z=0 处 ReLU 数学上不可导,程序常约定导数为 0,手算按题设。
English: Sigmoid outputs values in (0,1), making it useful for binary probabilities, but it saturates. Tanh is zero-centered with range (−1,1) and also saturates. ReLU is simple and has derivative 1 for positive inputs but zero for negative inputs, potentially causing inactive units. Leaky ReLU retains a small negative-side slope. ReLU is not differentiable at zero, so follow the specified derivative convention.
回查:L06 p.37–41、L07 p.4。
N17 · Q42 What are softmax properties, and why can we subtract the maximum logit?
Softmax 有哪些性质?减去最大 logit 为什么不改变输出?
What are softmax properties, and why can we subtract the maximum logit?
N17 · 查看答案与解析
答案:pₖ=eᶻᵏ/Σⱼeᶻʲ,各 p>0,总和 1;最大概率与最大 logit 同类。所有 logits 减同一常数 c,分子分母都有 e⁻ᶜ,抵消后输出不变。选 c=max z 可减少指数溢出。所有 logits 相等时每类概率 1/K;不能拿未归一化 eᶻ 直接当概率。
English: Softmax produces positive probabilities summing to one, and its largest probability corresponds to the largest logit. Subtracting a shared constant c multiplies both numerator and denominator by e⁻ᶜ, which cancels. Choosing c as the maximum logit improves numerical stability. Equal logits give uniform probabilities 1/K. Unnormalized exponentials are not probabilities.
回查:L06 p.29–30;F24 Q6.3;数值稳定性为公式直接推论。
N18 · Q43 Which losses are used for regression and classification, and why does cross-entropy have a minus sign?
回归与分类通常用什么损失?交叉熵为什么有负号?
Which losses are used for regression and classification, and why does cross-entropy have a minus sign?
N18 · 查看答案与解析
答案:回归常用 MSE;二分类常用 sigmoid+BCE;互斥多分类常用 softmax+CE。one-hot 时 CE=−log p_true。正确类概率越接近 1,损失越接近 0;若概率接近 0,损失很大。log p≤0,最大化 log-likelihood 等价于最小化其负数。省负号后仍做梯度下降会把优化方向写反。
English: Regression often uses MSE, binary classification sigmoid with BCE, and mutually exclusive multiclass classification softmax with cross-entropy. For a one-hot target, CE=−log p_true. It approaches zero as the true-class probability approaches one and grows when that probability approaches zero. Maximizing log-likelihood is equivalent to minimizing its negative; omitting the minus sign while minimizing reverses the objective.
回查:L06 p.30、43、47–48;F25 Q5.1。
N19 · Q44 Is backpropagation the same as gradient descent?
反向传播就是梯度下降吗?
Is backpropagation the same as gradient descent?
N19 · 查看答案与解析
答案:不是。前向算预测和损失;反向传播用链式法则算 ∂L/∂θ;梯度下降用 θ←θ−α∂L/∂θ 更新。一个权重影响多个输出时,要把各输出路径的梯度贡献相加。只算某一个输出分支会漏项。对同一轮全部梯度用旧权重,不能算一项就随手替换。
English: No. The forward pass computes predictions and loss. Backpropagation computes derivatives using the chain rule. Gradient descent then updates θ←θ−α∂L/∂θ. If a weight influences several outputs, its gradient is the sum of contributions along all relevant paths. All derivatives for one simultaneous update use the original parameter values.
回查:L06 p.44–48;F25 Q6。
N20 · Q45 How do we count fully connected network parameters?
如何数全连接网络参数?
How do we count fully connected network parameters?
N20 · 查看答案与解析
答案:n_in 到 n_out 的全连接层有 n_in×n_out 个权重,加 n_out 个偏置,即 (n_in+1)n_out。逐层相加,输入节点本身没有偏置参数。4→10→3 网络:4×10+10+10×3+3=83。ReLU/sigmoid 运算节点没有额外可训练参数。
English: A dense layer from n_in inputs to n_out outputs has n_in×n_out weights and n_out biases, totaling (n_in+1)n_out parameters. Add these counts across layers. A 4→10→3 network has 40+10+30+3=83 parameters. Input nodes and fixed ReLU or sigmoid functions do not add trainable parameters.
回查:L06、L07;F24 Q6.1。
N21 · Q46 Is initializing all sigmoid-network weights to large positive values a good idea?
全部 sigmoid 网络用很大的正权重初始化好吗?
Is initializing all sigmoid-network weights to large positive values a good idea?
N21 · 查看答案与解析
答案:一般不好。大权重容易让预激活绝对值很大,sigmoid 输出接近 0 或 1,导数很小,反向梯度衰减。如果所有隐藏单元还完全相同初始化,则存在对称性,可能学不到不同特征。通常使用适当尺度的随机初始化;“越大信号越强所以越好”不成立。是否一定正饱和仍取决于输入符号与偏置。
English: Generally no. Large weights can create large-magnitude pre-activations, pushing sigmoids toward saturation and making derivatives small. This weakens gradient flow. Identical hidden-unit initialization also creates symmetry, preventing units from learning distinct features. Appropriately scaled random initialization is preferable. Large positive weights do not guarantee positive saturation for every input, since input signs and biases also matter.
回查:F25 Q5.3;L06。
N22 · Q47 Should class-sorted training examples be shuffled before minibatch training?
训练集按类别排好,mini-batch 训练前应打乱吗?
Should class-sorted training examples be shuffled before minibatch training?
N22 · 查看答案与解析
答案:对普通独立样本分类通常应该,且特征与标签成对打乱。否则连续 batch 可能全是同一类,梯度估计不能代表总体,更新带有次序偏向并可能振荡。通常每个 epoch 可重新打乱。时间序列内部顺序、状态型 RNN 的连续性等另有约束,不能机械打乱所有数据。
English: Usually yes for ordinary independent classification examples, keeping each input paired with its label. Class-sorted batches can give unrepresentative gradients and order-dependent updates. Shuffling, often each epoch, improves batch mixing. Temporal order or continuity required by sequence tasks must be preserved; arbitrary shuffling is not appropriate for every dataset.
回查:F25 Q5.4。
N23 · Q48 Does jointly shuffling test inputs and labels change accuracy?
成对打乱测试集会改变准确率吗?
Does jointly shuffling test inputs and labels change accuracy?
N23 · 查看答案与解析
答案:对固定模型、正常评估模式、逐样本独立且确定的预测,以及同一批样本的总体 accuracy,不改变:只是把正确/错误指示量重新排序,总和相同,因此 a₁=a₂。若只打乱 X 不打乱 y,配对破坏,结果会变;若模型跨样本保留状态等,也不满足前面的前提。
English: For a fixed model in proper evaluation mode with independent deterministic predictions, jointly permuting test examples and their labels leaves aggregate accuracy unchanged: a₁=a₂. The same correctness indicators are merely reordered. Shuffling inputs without their labels breaks correspondence. Stateful or order-dependent evaluation does not satisfy the stated assumptions.
回查:F25 Q5.5。
N24 · Q49 Can a 5%-accurate binary classifier be more useful than a 50%-accurate one?
二分类 5% 准确率模型可能比 50% 的更有用吗?
Can a 5%-accurate binary classifier be more useful than a 50%-accurate one?
N24 · 查看答案与解析
答案:可以。在严格两类、每个样本必须给一个标签、在同一评价集上计算的条件下,把 5% 模型的每个预测翻转,正确率变成 95%;50% 翻转仍为 50%。这依赖二分类互补性,不能直接推广到多分类,也不自动保证未来不同分布上仍 95%。这是题设下的逻辑,不是医疗决策建议。
English: Yes. For a strictly binary classifier that always chooses one label, reversing every prediction converts 5% accuracy to 95% on the same evaluation set. Reversing a 50%-accurate classifier still gives 50%. This relies on binary complementarity and does not directly extend to multiclass prediction or guarantee the same performance on a different future distribution.
回查:F24 Q5.2。
个人整理的学习笔记,不是官方材料;数字与结论以课件和讲师为准。