largeQ
我举一个例子来说明一点:x:输入形状[2,3],1通道的图像valid_pad:最大池,2x2内核,步幅2和VALID填充。same_pad:最大池有2x2内核,步幅2和SAME填充(这是经典的方法)输出形状为:valid_pad:这里没有填充,所以输出形状是[1,1]same_pad:在这里,我们将图像填充到形状[2,4](-inf然后应用最大池),因此输出形状为[1,2]x = tf.constant([[1., 2., 3.], [4., 5., 6.]])x = tf.reshape(x, [1, 2, 3, 1]) # give a shape accepted by tf.nn.max_poolvalid_pad = tf.nn.max_pool(x, [1, 2, 2, 1], [1, 2, 2, 1], padding='VALID')same_pad = tf.nn.max_pool(x, [1, 2, 2, 1], [1, 2, 2, 1], padding='SAME')valid_pad.get_shape() == [1, 1, 1, 1] # valid_pad is [5.]same_pad.get_shape() == [1, 1, 2, 1] # same_pad is [5., 6.]