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

Siddhant Bansal picture Siddhant Bansal · Jun 13, 2018 · Viewed 23.2k times · Source

I trained and downloaded a model(a CNN) using Keras from google colaboratory when I tried to load the model on my local machine(Mac OS X El Capitan), I received the following error.

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

I tried loading the model by changing the backend from Theano to TensorFlow but still got the same error.

Answer

nuric picture nuric · Jun 13, 2018

You might be using a different version between platforms. Updating Keras to the same / latest should resolve the issue, with pip:

pip install --upgrade keras