Pooling layers help with overfitting and improve performance by reducing the size of the input tensor. Typically, they are used to scale down the input, keeping important information. Pooling is a much faster mechanism for input size reduction compared with tf.nn.conv2d
.
The following pooling mechanisms are supported by TensorFlow:
- Average
- Max
- Max with argmax
Each pooling operation uses rectangular windows of size ksize
separated by offset strides
. If strides
are all ones (1, 1, 1, 1), every window is used; if strides
are all twos (1, 2, 2, 1), every other window is used in each dimension; and so on.
The following defined function provides max pooling for the input 4D tensor tf.nn.max_pool
:
max_pool( value, ksize, strides, padding, data_format='NHWC', name=None )
The preceding arguments are explained here:
value
: This is the 4D tensor with shape [batch, height, width, channels], typetf.float32
on which max pooling needs to be done.ksize
: This is the list of ints that haslength...