← COMP5511 全部讲次
Q15

Final 问答|O CNN、RNN 与拓展

期末双语问答 O:CNN、RNN 与训练流程九题,加分类损失、Markov 天气、Agent、推荐、读论文、ML 定义六道拓展题,逐题折叠中文答案、英文答法与回查出处。非官方。

手机上宽表格可左右滑动;自测答案默认收起,点击题目下方按钮查看。

使用边界:期末复习,非官方材料。考试安排按课程公告整理,正式要求以讲师通知和课堂公告为准。本页是同学整理的双语问答,英文可作答卷模板,题目是整理出来的常见问法,不是预测卷。

复习资料:考试安排与范围地图 · 专家系统与推荐系统 · Agent 与生成式 AI

先做题再看解析:G 往年卷:搜索、逻辑、概率 · H 往年卷:CNN 与神经网络 · I 往年卷:延伸与简答 · J 判断 1–25 · K 判断 26–50 · L 选择题 · M 问答:搜索、逻辑、概率 · N 问答:回归、聚类、神经网络 · O 问答:CNN、RNN 与拓展 · P 期中后新内容

怎么做:先只看题面,用英文写出答案要点,再展开核对;页码为 PDF 页序。

O CNN、RNN 与拓展

O1–O9 是 CNN、RNN 与训练流程(Q50–Q58)。O10–O15 是拓展问答(X01–X06),来自旧卷延伸和后几讲的概念题,X03、X04 分别对应 L09a 和 L08,往年卷没有直接出过。

O1 · Q50 Why are CNNs suitable for images?

CNN 为什么适合图像? / Why are CNNs suitable for images?

O1 · 查看答案与解析

答案:图像存在空间局部结构。CNN 用局部连接识别局部模式,并通过同一核在不同位置共享参数,减少相对全连接层的参数量,同时保持空间组织。浅层常学边缘等局部模式,更深层组合为复杂特征。卷积的平移等变不等于整个网络对任何移动都完全不变。

English: Images contain useful local spatial structure. CNNs exploit it through local connectivity and shared filters across positions, reducing parameters compared with fully connected processing while preserving spatial organization. Earlier layers can detect local patterns, and later layers combine them into more complex features. Translation equivariance of convolution does not imply complete translation invariance of the entire network.

回查:L07 p.9–20。

O2 · Q51 How do we calculate convolution output shape and parameter count?

卷积的输出尺寸与参数量如何算? / How do we calculate convolution output shape and parameter count?

O2 · 查看答案与解析

答案:普通无 dilation 卷积,每个空间维度为 floor((N+2P−F)/S)+1;若课堂要求核整齐覆盖,则先检查 (N+2P−F)/S 为整数。输出通道数为 K。参数量为 (F_hF_wC_in+1)K,假设每核一个偏置,不是每个输出像素一个偏置。输出大小改变不直接让共享核权重数量增加。

English: For a standard convolution without dilation, each output spatial dimension is floor((N+2P−F)/S)+1. If the classroom convention requires exact tiling, check divisibility first. The output has K channels. With one bias per filter, the parameter count is (F_hF_wC_in+1)K. Shared-filter parameter count does not multiply by the number of output positions.

回查:L07 p.21–40;F24 Q4。

O3 · Q52 What does pooling do, and does it have parameters or change channel count?

Pooling 的作用、参数和通道变化是什么? / What does pooling do, and does it have parameters or change channel count?

O3 · 查看答案与解析

答案:普通池化逐通道对局部窗口取最大或平均,常降低空间尺寸、计算量,并提供一定局部移动容忍。它通常没有可训练权重,也不混合通道,所以通道数不变。stride=1 加 padding 时未必降尺寸。若最大池化题明确补 0,负值窗口也必须与补入的 0 比较,不能擅自改成 −∞。

English: Standard pooling aggregates local windows independently in each channel, often reducing spatial size and computation and providing some local translation tolerance. It normally has no trainable weights and preserves channel count. Pooling need not downsample if its stride and padding preserve size. If a question specifies zero padding, include those zeros when taking maxima, even if some original values are negative.

回查:L07 p.42–44;F24 Q4.2。

O4 · Q53 How does an RNN differ from a standard feed-forward network?

RNN 与普通前馈网络有什么区别? / How does an RNN differ from a standard feed-forward network?

O4 · 查看答案与解析

答案:RNN 在每个时间步用 xₜ 和 hₜ₋₁ 更新 hₜ,例如 hₜ=tanh(W_xh xₜ+W_hh hₜ₋₁+b)。隐藏状态携带先前信息,各时间步共享参数,所以参数数量不直接随序列长度增加。普通前馈网络不自动保持这种时间状态。句子情感分类可 many-to-one,逐词标注可 many-to-many。

English: An RNN updates hₜ from both xₜ and hₜ₋₁, for example hₜ=tanh(W_xh xₜ+W_hh hₜ₋₁+b). The hidden state carries earlier information, and parameters are shared across time, so parameter count does not directly grow with sequence length. A standard feed-forward model has no such recurrent state. Sentiment classification is commonly many-to-one, while sequence labeling can be many-to-many.

回查:L07 p.50–70。

O5 · Q54 Why do RNN gradients vanish or explode, and what does clipping address?

为什么 RNN 会梯度消失/爆炸?裁剪解决什么? / Why do RNN gradients vanish or explode, and what does clipping address?

O5 · 查看答案与解析

答案:BPTT 会把多个时间步的雅可比矩阵或局部导数连乘;反复收缩会消失,反复放大会爆炸。梯度裁剪把过大的梯度限制在阈值范围,减少不稳定大更新。范数裁剪可写 g←g·min(1,τ/‖g‖),g=0 时保持零。它主要处理爆炸,不能把已接近零的梯度自动放大恢复。

English: BPTT multiplies Jacobians or local derivatives across many time steps. Repeated contraction can cause vanishing gradients, while repeated amplification can cause exploding gradients. Norm clipping rescales an oversized gradient as g←g·min(1,τ/‖g‖), leaving zero gradients unchanged. It limits unstable updates caused by exploding gradients; it does not directly recover gradients that have already vanished.

回查:L07 p.78–81;F24 Q5.3。

O6 · Q55 What are the roles of the three LSTM gates?

LSTM 三个门分别做什么? / What are the roles of the three LSTM gates?

O6 · 查看答案与解析

答案:遗忘门 f 控制保留旧记忆;输入门 i 控制写入候选 g;输出门 o 控制当前隐藏输出。标准更新 cₜ=fₜ⊙cₜ₋₁+iₜ⊙gₜ,hₜ=oₜ⊙tanh(cₜ)。门一般用 sigmoid 得到 0 到 1 的系数。加性记忆路径有利于梯度和长期信息流动,但不保证任何情况下都不消失。

English: The forget gate controls retained old memory, the input gate controls stored candidate content, and the output gate controls the hidden output. The standard updates are cₜ=fₜ⊙cₜ₋₁+iₜ⊙gₜ and hₜ=oₜ⊙tanh(cₜ). Sigmoid gates provide values between zero and one. The additive memory path helps long-term information and gradient flow, without eliminating all possible gradient problems.

回查:L07 p.82–86。

O7 · Q56 What are the steps of a training loop, and why clear gradients?

训练循环有哪些步骤?为什么清零梯度? / What are the steps of a training loop, and why clear gradients?

O7 · 查看答案与解析

答案:读取一批样本;清零旧梯度;前向预测;计算损失;反向求梯度;优化器更新;按批或 epoch 重复。PyTorch 默认累积梯度,所以不清零会把旧批次梯度加进来,除非这正是设计。评估时固定参数,使用正确评估模式,通常不记录梯度。eval 模式与 no_grad 的作用不同。

English: Load a batch, clear old gradients, compute predictions, calculate loss, backpropagate, and update parameters with the optimizer. Repeat over batches and epochs. PyTorch accumulates gradients by default, so clearing is needed unless accumulation is intentional. Evaluation uses fixed parameters and the appropriate evaluation mode, normally without recording gradients. Evaluation mode and gradient disabling serve different purposes.

回查:课程配套 notebook。

O8 · Q57 What are the risks in splitting and normalizing time-series data?

时间序列的划分与归一化有哪些风险? / What are the risks in splitting and normalizing time-series data?

O8 · 查看答案与解析

答案:应保证预测时只使用当时已知的信息;通常早期数据训练,后续验证与测试。若随机混合窗口,重叠样本和未来信息可能泄漏。scaler 只能在训练数据拟合,不能把验证/测试加进去再报告独立评估。递归预测把自身预测反馈作输入,误差可能累积;不能评价时偷用未知未来真实值。

English: A forecasting evaluation should use only information available at prediction time. Earlier data are typically used for training and later data for validation and testing. Randomly mixing overlapping windows can leak future information. Fit scaling statistics on training data only. Recursive forecasting feeds predictions into later inputs and can accumulate error; unknown future targets must not be supplied as if they were available.

回查:课程配套时间序列 notebook;用于理解实践,不要求背长代码。

O9 · Q58 Choose among MLPs, CNNs and RNNs for different tasks

根据任务选择 MLP、CNN、RNN。 / Choose among MLPs, CNNs and RNNs for different tasks.

O9 · 查看答案与解析

答案:固定长度表格特征可考虑 MLP;图像的局部空间结构适合 CNN;带时间或词序依赖的序列可考虑 RNN/LSTM。图像描述可组合 CNN 编码图像与序列解码器生成词。模型选择还依数据量、验证表现和计算限制,不能只凭名字断言某类模型对所有任务最好。

English: An MLP is a reasonable option for fixed-length tabular features, a CNN exploits local image structure, and an RNN or LSTM models ordered sequences. Image captioning can combine a CNN image encoder with a sequence decoder. The final choice also depends on data, validation performance and computational constraints; no architecture is universally best.

回查:L06、L07。

O10 · X01 Compare three classification losses

如何比较零一损失、感知机损失和最小二乘分类损失? / Compare three classification losses.

O10 · 查看答案与解析

答案:对 y∈{−1,+1},令 z=yf(x)。按旧题边界约定,0–1 loss 在 z≥0 时为 0,否则为 1;感知机损失 max(0,−z) 只惩罚负间隔,且错误越大惩罚越重;最小二乘损失 (f(x)−y)²=(z−1)²,不仅惩罚错分,也惩罚偏离目标间隔 1 的正确预测。零一损失不适合普通梯度下降,因为几乎处处导数为零且边界不光滑。

English: Let z=yf(x) for labels ±1. Under the old question’s boundary convention, 0–1 loss is zero for z≥0 and one otherwise. Perceptron loss max(0,−z) penalizes negative margins by their magnitude. Least-squares loss equals (z−1)² and also penalizes correctly classified scores that differ from target margin 1. The 0–1 loss is unsuitable for ordinary gradient descent because it is flat almost everywhere and discontinuous at the boundary.

回查:F24 Q7。

O11 · X02 Why can a Markov weather problem require a later observation?

Markov 天气题为什么不能忽略已知未来观测? / Why can a Markov weather problem require a later observation?

O11 · 查看答案与解析

答案:Markov 性表示给定当前状态,下一状态不依赖更早历史;不表示后来观测对推测中间状态无用。若已知第 5 天和第 7 天状态,问第 6 天,就要同时考虑从第 5 天进入该状态、以及该状态走到第 7 天的概率,并在可能的第 6 天状态间归一化。

English: The Markov property says that the next state depends on the current state rather than earlier history. It does not make later evidence irrelevant when inferring an intermediate state. If days 5 and 7 are observed, the posterior for day 6 is proportional to the probability of reaching that state from day 5 times the probability of reaching the observed day 7 from it, followed by normalization.

回查:F25 Q4;此专题未在主课件中单独完整展开。

O12 · X03 How does an AI agent differ from an LLM?

LLM 与 AI Agent 有什么区别? / How does an AI agent differ from an LLM?

O12 · 查看答案与解析

答案:LLM 提供语言理解/生成与推理相关能力;Agent 系统围绕模型加入任务目标、状态、工具调用、规划和执行反馈循环。记忆保存信息,工具与环境交互,人可以在关键环节审核。多智能体增加分工和协调机制,但不保证自动比单个智能体准确或便宜。

English: An LLM provides language-processing and generation capabilities. An agent system surrounds a model with goals, state, tools, planning and feedback-driven action loops. Memory retains information, tools interact with the environment, and humans may review important steps. Multi-agent systems add division of work and coordination but are not automatically more accurate or efficient.

回查:L09a p.3–5、p.11–13。

O13 · X04 Compare content-based recommendation and collaborative filtering

内容推荐与协同过滤有什么区别? / Compare content-based recommendation and collaborative filtering.

O13 · 查看答案与解析

答案:内容推荐根据物品属性及用户过去喜好推荐相似物品;协同过滤根据用户之间或物品之间的交互模式推荐。评分是显式反馈,点击/浏览是隐式反馈,未点击不一定是不喜欢。矩阵分解可学习用户和物品向量,用点积估计偏好。新用户/物品缺乏交互导致冷启动。

English: Content-based recommendation matches item attributes to a user’s past preferences. Collaborative filtering uses patterns of user–item interactions. Ratings are explicit feedback, whereas clicks and views are implicit feedback; missing interaction does not necessarily mean dislike. Matrix factorization learns user and item vectors whose dot products estimate preferences. Limited interactions create cold-start problems.

回查:L08 p.20–36。原答案里「冷启动」一句课件没有出现,当背景读。

O14 · X05 What do paper sections do, and how should we read a paper?

论文各部分解决什么问题?如何阅读? / What do paper sections do, and how should we read a paper?

O14 · 查看答案与解析

答案:摘要概括问题、方法和结果;引言解释背景、动机和贡献;相关工作说明与已有研究的关系;方法解释设计;实验检验是否有效;结论总结发现和局限。先用标题、摘要、图表和结论建立全貌,再读方法和实验细节。问自己:问题是什么、贡献是什么、证据支持什么、还有什么限制。

English: The abstract summarizes the problem, method and results. The introduction motivates the work; related work positions it; the method explains the design; experiments evaluate it; and the conclusion summarizes findings and limitations. Start with the title, abstract, figures and conclusion, then inspect methods and evidence. Identify the problem, contribution, supporting results and remaining limitations.

回查:T01 p.13–34。

O15 · X06 How do we specify task, performance and experience?

ML 的任务、表现与经验怎样具体化? / How do we specify task, performance and experience?

O15 · 查看答案与解析

答案:以垃圾邮件分类为例,任务 T 是把邮件分为垃圾/正常;表现 P 可用独立测试集准确率或其他适当指标;经验 E 是带正确标签的历史邮件。必须说清楚三者,不能把“用 AI”当成明确任务,也不能把训练集准确率直接当成真实泛化表现。

English: For spam classification, task T is assigning emails to spam or non-spam, performance P may be accuracy or another suitable metric on held-out data, and experience E is a collection of labeled past emails. These must be specified concretely. “Using AI” is not a precise task, and training accuracy alone is not a reliable measure of generalization.

回查:L01 p.38。

下一页 →
Q16 Final 自拟练习|P 期中后新内容

个人整理的学习笔记,不是官方材料;数字与结论以课件和讲师为准。