Search code examples
paddingconvolutionkeraskeras-layer

Padding of size greater than 1 in keras


As much as I know in keras border_mode is used for padding. What I need to know how can I specify a value like Padding/border_mode=2 in keras? The problem is border_mode take only two values: valid and same So any help?

p.s already asked on data science. But may be it is beta so getting no response :(


Solution

  • You can try a ZeroPadding2D layer:

    https://keras.io/layers/convolutional/#zeropadding2d

    Note: the Keras Convolution2D layer is backed by either the theano.nnet.conv2d or tf.nn.conv2d. The latter doesn't seem to support custom padding (although there's tf.pad for this).