1,为什么要池化。
为了降低卷积之后得到的特征数量。
2,怎么池化?
最大值池化,均值池化等。例如最大值池化就是把几个相邻的特征用他们的最大值来表示。
3,最大值池化
示意图:
4,tensorflow实现池化
import tensorflow as tf
import numpy as np
M=np.array([[[[1],[2],[-1],[0]],
[[0],[-2],[-1],[0]],
[[3],[-2],[-3],[0]],
[[0],[0],[0],[0]]],
[[[-3],[3],[-2],[0]],
[[2],[-1],[1],[0]],
[[-1],[0],[-2],[0]],
[[0],[0],[0],[0]]]], dtype='float32')
print M.shape
max_pool =tf.nn.max_pool(value=M,ksize=[1,2,2,1],strides=[1,2,2,1],padding='VALID')
with tf.Session() as sess:
init_op=tf.initialize_all_variables()
sess.run(init_op)
print sess.run(max_pool)
更多细节参考 https://blog.csdn.net/mzpmzk/article/details/78636184