> For the complete documentation index, see [llms.txt](https://baozoulin.gitbook.io/neural-networks-and-deep-learning/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://baozoulin.gitbook.io/neural-networks-and-deep-learning/di-si-men-ke-juan-ji-shen-jing-wang-luo-convolutional-neural-networks/convolutional-neural-networks/foundations-of-convolutional-neural-networks/19-chi-hua-ceng-ff08-pooling-layers.md).

# 1.9 池化层（Pooling layers）

Pooling layers是CNN中用来减小尺寸，提高运算速度的，同样能减小noise影响，让各特征更具有健壮性

Pooling layers没有卷积运算，仅在滤波器算子滑动区域内取最大值，即max pooling，这是最常用的做法。超参数p很少在pooling layers中使用

![](/files/-Le0cePHRZpAVxpEycGH)

[![](https://github.com/fengdu78/deeplearning_ai_books/raw/master/images/a800c70b250dc43b7003aaeebb4eefc2.png)](https://legacy.gitbook.com/book/baozou/neural-networks-and-deep-learning/edit#)

Max pooling的好处是只保留区域内的最大值（特征），数字大意味着可能探测到了某些特定的特征，忽略了其它值，降低了noise影响，提高了模型健壮性。max pooling需要的超参数仅为滤波器尺寸f和滤波器步进长度s，没有其他参数需要模型训练得到，计算量很小

如果是多个通道，每个通道单独进行max pooling操作：

[![](https://github.com/fengdu78/deeplearning_ai_books/raw/master/images/c225755635059449e2a9a84135e2548e.png)](https://legacy.gitbook.com/book/baozou/neural-networks-and-deep-learning/edit#)

average pooling是在滤波器算子滑动区域计算平均值：

![](/files/-Le0cePKq4xWgoC9bd9O)

实际应用中，max pooling比average pooling更为常用，也有例外，深度很深的神经网络可以用平均池化来分解规模为7×7×1000的网络的表示层，在整个空间内求平均值，得到1×1×1000

总结：

池化的超级参数包括过滤器大小$$f$$和步幅$$s$$，常用的参数值为$$f=2$$，$$s=2$$，应用频率非常高，其效果相当于高度和宽度缩减一半。最大池化时，往往很少用到超参数**padding**，$$p$$最常用的值是0，即$$p=0$$。最大池化的输入就是：

$$
n\_{H} \times n\_{W} \times n\_{c}
$$

假设没有**padding**，则输出：

$$
\lfloor\frac{n\_{H} - f}{s} +1\rfloor \times \lfloor\frac{n\_{w} - f}{s} + 1\rfloor \times n\_{c}
$$

输入通道与输出通道个数相同，因为对每个通道都做了池化。最大池化只是计算神经网络某一层的静态属性，池化过程中没有需要学习的参数。执行反向传播时，反向传播没有参数适用于最大池化

[![](https://github.com/fengdu78/deeplearning_ai_books/raw/master/images/6bd58a754152e7f5cf55a8c5bbac3100.png)](https://github.com/fengdu78/deeplearning_ai_books/blob/master/images/6bd58a754152e7f5cf55a8c5bbac3100.png)
