×

CNN-最大池化

96
cuizixin Excellent
2018.10.26 16:22* 字数 403

最大池化的过程

Let's say we have a 4x4 matrix representing our initial input.
Let's say, as well, that we have a 2x2 filter that we'll run over our input. We'll have a stride of 2 (meaning the (dx, dy) for stepping over our input will be (2, 2)) and won't overlap regions.

For each of the regions represented by the filter, we will take the max of that region and create a new, output matrix where each element is the max of a region in the original input.

In order to make this super easy, with a nice pictorial representation - I give you this:

image.png

取了每个区域的最大值。

优点

image.png
  1. 不增加额外的参数。
    所以不用担心最大池化会导致过拟合。
  2. 通常会提高模型的准确性。
  3. 更大的计算量。Since the convolutions that went below run at lower stride, the model then becomes a lot more expensive to compute.
  4. 更多的超参数。比如:池区尺寸、池化步幅。

缺点

近期,池化层并不是很受青睐。部分原因是:

  • 现在的数据集又大又复杂,我们更关心欠拟合问题。
  • Dropout 是一个更好的正则化方法。
  • 池化导致信息损失。想想最大池化的例子,n 个数字中我们只保留最大的,把余下的 n-1 完全舍弃了。

tensorflow 实现

题目描述

H = height, W = width, D = depth
输入维度是 4x4x5 (HxWxD)
滤波器大小 2x2 (HxW)
stride 的高和宽都是 2 (S)


image.png

实现

input = tf.placeholder(tf.float32, (None, 4, 4, 5))
filter_shape = [1, 2, 2, 1]
strides = [1, 2, 2, 1]
padding = 'VALID'
pool = tf.nn.max_pool(input, filter_shape, strides, padding)

最大池化后,数据维度变为2x2x5。
???参数padding的作用,VALID和SAME的区别?

参考资料:

  1. https://www.quora.com/What-is-max-pooling-in-convolutional-neural-networks#
计算机
Web note ad 1