2017-04-22 65 views
2

我想实现下面的Python代码,但我得到了下面的错误。任何人都可以帮我吗?类型错误:“不明白关键字参数:”,“填充”

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

的错误,我得到:

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

回答

5

你似乎完全混合Keras 2 API使用与Keras 1,你似乎已经安装Keras 1(因为你正在使用Convolution2D)。

在Keras 1中,控件填充的参数不叫padding,而是border_mode

但在任何情况下,不与Keras 1混合Keras 2码,小心你所读的文档。

0

Matias Valdenegro如说我也有同样的错误,当我试图在keras 2.0.4使用生成的模型文件通过keras 2.1.3。

通过升级keras到最新版本(for more infor check here

pip install --upgrade keras

检查keras版本

import keras 
print('keras: %s' % keras.__version__) 
解决
相关问题