Question

Keras has two border_mode for convolution2D, same and valid. Could anyone explain what "same" does or point out some documentation? I could not find any document on the net (except people asking that it be implemented in theano as well).

Was it helpful?

Solution

With border mode "valid" you get an output that is smaller than the input because the convolution is only computed where the input and the filter fully overlap.

With border mode "same" you get an output that is the "same" size as the input. That means that the filter has to go outside the bounds of the input by "filter size / 2" - the area outside of the input is normally padded with zeros.

Note that some libraries also support the border mode "full" where the filter goes even further outside the bounds of the input - up to "filter size - 1". This results in an output shape larger than the input.

There's a short explanation in.. numpy's convolve documentation:

http://docs.scipy.org/doc/numpy-1.10.0/reference/generated/numpy.convolve.html

Licensed under: CC-BY-SA with attribution
Not affiliated with datascience.stackexchange
scroll top