First exams 2027 · HL only 2027 年首次开考 · 仅 HL

A4.3.9 · Machine learning approaches (HL only)

A4.3.9 · 机器学习方法(仅 HL)

Convolutional Neural Networks

卷积神经网络

A farm's sorting robot needs to tell a ripe apple from an unripe one in a photo. Feeding every pixel into a plain ANN loses the fact that nearby pixels belong together, a patch of red skin, the curve of an edge. A CNN is built to notice exactly that.

一个农场的分拣机器人需要从照片中分辨出苹果是成熟还是未成熟。如果把每个像素单独喂给一个普通的 ANN,就会丢失相邻像素本应属于一起这个事实,比如一片红色的果皮,一道边缘的弧线。CNN 正是为了留意这些而设计的。

CNNs belong to the deep learning family named in A4.1.1, but this statement asks specifically about the mechanism, not just the label.

CNN 属于 A4.1.1 中提到的深度学习家族,但本条考纲具体问的是它的机制,而不只是这个名称。

HL only 仅 HL Typically 3–4 marks · AO2 通常 3–4 分 · AO2 Command term: describe 命令词:describe(描述)

Explainer

讲解

Built for grid-shaped data

为网格状数据而生

Df

A CNN (convolutional neural network) is a deep learning network purpose-built for data laid out on a grid, most often images. A small matrix called a kernel (filter) slides across the input, at every position performing a convolution (a weighted sum over the pixels under it) to produce a feature map that highlights where a specific pattern was detected.

卷积神经网络(CNN)是一种为网格排列的数据(最常见是图像)而设计的深度学习网络。一个称为卷积核(滤波器)的小矩阵在输入上滑动,在每个位置执行一次卷积(对其下方的像素做一次加权求和),生成一张特征图,标出检测到某个特定模式的位置。

LayerWhat it does
Input layerWhere the image enters the network, as a grid of pixel values (three grids stacked for RGB colour)
Convolutional layerSlides several kernels across the input, each producing its own feature map for a specific pattern (an edge, a texture)
Activation functionApplied to each feature map (commonly ReLU), introducing non-linearity so complex patterns can be learned
Pooling layerShrinks each feature map (e.g. max pooling keeps only the largest value in each small block), reducing computation and making detection less sensitive to exact position
Fully connected layerFlattens the surviving features into one vector and reasons over all of them together
Output layerProduces the final probabilities, often via a softmax function, for each possible class
层它做什么
输入层接收原始像素网格(RGB 彩色图像则是三张网格)
卷积层把若干个卷积核滑过输入,每个核为某种特定模式(边缘、纹理)生成自己的特征图
激活函数应用于每张特征图(常用 ReLU),引入非线性,使网络能学到复杂的模式
池化层压缩每张特征图(例如最大池化,只保留每个小区块中最大的值),减少计算量,并让检测对具体位置不那么敏感
全连接层把留下的特征展平成一个向量,并对它们整体进行推理
输出层为每个可能的类别产生最终的概率,常通过 softmax 函数实现

Worked example

例题

Sorting ripe from unripe apples

分拣成熟与未成熟的苹果

A tiny 6×6 patch of an apple photo, walked through the pipeline stage by stage.

一小块 6×6 的苹果照片色块,逐个阶段走过整条流水线。

Explainer

讲解

What shapes what a CNN learns

什么决定了 CNN 学到什么

FactorEffect
Number of layersA shallow network learns basic features (edges, blotches of colour); a deeper network builds those up into higher-level features (a bruise shape, the pattern of a stem)
Kernel sizeA larger kernel captures broader, more global patterns in one pass; a smaller kernel focuses on fine local detail
StrideHow far the kernel moves each step; a small stride keeps more detail in the resulting map, a bigger jump between positions trades that detail for less computation
Activation functionReLU is common in hidden layers for speed and to reduce a known training problem (vanishing gradients)
Loss functionGuides training by measuring how wrong the prediction was; cross-entropy loss is common for classification
因素影响
层数较浅的网络只能学到基本特征(边缘、色块);更深的网络会把这些组合成更高层的特征(一处瘀伤的形状、果梗的图案)
卷积核大小更大的核能在一次操作中捕捉更广、更全局的模式;更小的核专注于细节的局部特征
步幅卷积核每一步移动多远;步幅小得到更精细的特征图,步幅大则更粗糙但计算更省
激活函数ReLU 在隐藏层中很常见,速度快,并能缓解一个已知的训练问题(梯度消失)
损失函数通过衡量预测有多离谱来指导训练;交叉熵损失在分类任务中很常见

Check your understanding

检验你的理解

What is the main purpose of a pooling layer in a CNN?

CNN 中池化层的主要目的是什么?

Common mistake

常见错误

Recurring oversimplification 反复出现的过度简化

RecurringDescribing a CNN as "a regular neural network with extra layers". The layer count is not what makes it a CNN. The defining mechanism is convolution: a kernel scanning across the grid to build feature maps that respect which pixels are near each other, something a plain, fully-connected ANN has no way to do, since it treats every input pixel as an unrelated number in a flat list.

反复出现把 CNN 描述成"层数更多的普通神经网络"。让它成为 CNN 的关键并不是层数。它的核心机制是卷积:一个卷积核在网格上扫描,构建出尊重"哪些像素彼此相邻"这一事实的特征图,这是一个普通的、全连接的 ANN 做不到的,因为它把每个输入像素都当成一个扁平列表中互不相关的数字。

✕

Wrong: "A CNN is just an ANN with more hidden layers, which lets it handle images."

错误: "CNN 只是隐藏层更多的 ANN,这让它能处理图像。"

✓

Right: "A CNN's convolutional layers slide a kernel across the grid, so nearby pixels are processed together and a feature map preserves where a pattern was found. A plain ANN flattens the image into a list of unrelated numbers first, losing that spatial relationship."

正确: "CNN 的卷积层让卷积核在网格上滑动,使相邻的像素被一起处理,特征图也保留了模式被发现的位置。而普通的 ANN 会先把图像展平成一串互不相关的数字,丢失了这种空间关系。"

Revision questions

复习题

Specimen-paper style. Write an answer, then reveal the marking points and mark yourself.

采用样卷风格。写下答案,然后展开评分要点给自己打分。

Question 1 · 1 mark 第 1 题 · 1 分

[1]State one layer found in a convolutional neural network.

[1]说出卷积神经网络中的一种层。

Question 2 · 3 marks 第 2 题 · 3 分

[3]Describe how a convolutional layer processes an input image.

[3]描述卷积层如何处理一张输入图像。

Question 3 · 1 mark 第 3 题 · 1 分

[1]State one problem that could result from training a CNN on a set of images that still contains mislabelled or corrupted examples.

[1]说出在一组仍含有标签错误或损坏样本的图像上训练 CNN,可能引发的一个问题。

Question 4 · 3 marks 第 4 题 · 3 分

[3]Explain why the F1 score would be a more informative choice than accuracy alone for judging this apple-sorting CNN.

[3]解释为什么用 F1 分数来评判这个苹果分拣 CNN,会比单看准确率更有参考价值。

Flashcards

记忆卡片

Active recall for this statement’s key terms.

针对本条考纲陈述关键术语的主动回忆练习。

Prototype render · grounded in the IB CS 2027 subject guide, the specimen papers and the Hodder and Oxford IB CS 2027 texts for A4.3.9 · not yet wired to live routes