I'm confused what to use, valid,same or full. I also don't know what does it do. I can't find it in the Docs. And border_mode
for MaxPooling2D
layer does not make sense to me. (It does make sense to me for the Convolution layers though).
When you use a two-dimentional image with m rows and n cols
, and a a*b size kernel
to convolute the input image, this is what happens:
If border_mode is 'full', returns a (m+a-1)x(n+b-1)
image;
if border_mode is 'same', returns the same dimention as the input image;
if border_mode is 'valid',returns a (m-a+1)x(n-b+1)
image.
for example,
Input: In following 4x4 image
A = [12 13 14 15;1 2 3 4;16 17 18 19;5 6 7 8], and a 3x3 kernel B = [1 2 3;4 5 6;7 8 9]
,
if border_mode is 'full', then returns a 6x6
matrix;
if border_mode is 'same', then returns a 4x4
matrix;
if border_mode is 'valid', then returns a 2x2
matrix.
you can also use function conv2(A,B,border_mode) in MATLAB to test the output matrix.
Hope this answer could help.
This is for Keras 2+ as they replaced the Border_mode with padding And it can be used for down and upsampling in a network.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With