当我尝试在我的本地计算机(Mac OS X El Capitan)上加载模型时,我使用Keras从google colaboratory训练并下载了一个模型(CNN),我收到了以下错误。
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.6/site-packages/keras/models.py", line 243, in load_model
model = model_from_config(model_config, custom_objects=custom_objects)
File "/usr/local/lib/python3.6/site-packages/keras/models.py", line 317, in model_from_config
return layer_module.deserialize(config, custom_objects=custom_objects)
File "/usr/local/lib/python3.6/site-packages/keras/layers/__init__.py", line 55, in deserialize
printable_module_name='layer')
File "/usr/local/lib/python3.6/site-packages/keras/utils/generic_utils.py", line 143, in deserialize_keras_object
list(custom_objects.items())))
File "/usr/local/lib/python3.6/site-packages/keras/models.py", line 1352, in from_config
layer = layer_module.deserialize(conf, custom_objects=custom_objects)
File "/usr/local/lib/python3.6/site-packages/keras/layers/__init__.py", line 55, in deserialize
printable_module_name='layer')
File "/usr/local/lib/python3.6/site-packages/keras/utils/generic_utils.py", line 145, in deserialize_keras_object
return cls.from_config(config['config'])
File "/usr/local/lib/python3.6/site-packages/keras/engine/topology.py", line 1269, in from_config
return cls(**config)
File "/usr/local/lib/python3.6/site-packages/keras/layers/core.py", line 483, in __init__
super(Flatten, self).__init__(**kwargs)
File "/usr/local/lib/python3.6/site-packages/keras/engine/topology.py", line 292, in __init__
raise TypeError('Keyword argument not understood:', kwarg)
TypeError: ('Keyword argument not understood:', 'data_format')
我尝试通过将后端从Theano更改为TensorFlow来加载模型,但仍然遇到相同的错误。
答案 0 :(得分:10)
您可能在平台之间使用不同的版本。将Keras更新为相同/最新应解决此问题,请使用pip:
pip install --upgrade keras