2
votes

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')

2

2 Answers

6
votes

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.

0
votes

as said by Matias Valdenegro Me too had the same error, when i was trying to use a model file generated by keras 2.1.3 in keras 2.0.4.

solved by upgrading keras to latest version(for more infor check here)

pip install --upgrade keras

check keras version

import keras
print('keras: %s' % keras.__version__)