Python – TypeError: ‘Keyword argument not understood:’, ‘padding’

keraspython

I am trying to implement the following python code, but I get the following error. Could anyone help me?

from keras.models import Sequential
from keras.constraints import maxnorm
from keras.layers.convolutional import Convolution2D

# Create the model
model = Sequential()
model.add(Convolution2D(32, 3, 3, input_shape=(3, 32, 32), activation='relu', padding='same', kernel_constraint=maxnorm(3)))

The error I get:

File "C:\Users\Lenovo\Anaconda2\envs\example_env\lib\site-packages\keras\layers\convolutional.py", line 388, in init
super(Convolution2D, self).init(**kwargs)

File "C:\Users\Lenovo\Anaconda2\envs\example_env\lib\site-packages\keras\engine\topology.py", line 323, in init
raise TypeError('Keyword argument not understood:', kwarg)

TypeError: ('Keyword argument not understood:', 'padding')

Best Answer

You seem to be completely mixing Keras 2 API use with Keras 1, and you seem to have Keras 1 installed (as you are using Convolution2D).

In Keras 1, the parameter to control padding is not called padding, but border_mode.

But in any case, don't mix Keras 2 code with Keras 1, be careful about what documentation you read.

Related Topic