tf.nn.max_pool
of tensorflow
?tensorflow
. But what is 'SAME' padding of max pool in tensorflow
?Padding is an operation to increase the size of the input data. In case of 1-dimensional data you just append/prepend the array with a constant, in 2-dim you surround matrix with these constants. In n-dim you surround your n-dim hypercube with the constant. In most of the cases this constant is zero and it is called zero-padding.
Here is an example of zero-padding with p=1 applied to 2-d tensor:
You can use arbitrary padding for your kernel but some of the padding values are used more frequently than others they are:
To use arbitrary padding in TF, you can use tf.pad()
This post was edited by Vaibhav Mali at September 9, 2021 12:56 PM ISTComplementing YvesgereY's great answer, I found this visualization extremely helpful:
Padding 'valid' is the first figure. The filter window stays inside the image.
Padding 'same' is the third figure. The output is the same size.
Found it on this article
Visualization credits: vdumoulin@GitHub