elena
elena

Reputation: 41

ValueError: bad marshal data (unknown type code)

My operating system is Ubuntu.

And I got this error message when I was running my keras model.

I have googled for some solutions but they don't work. For example, I have tried the mentioned solutions in this post: How to fix Python ValueError:bad marshal data?

Using TensorFlow backend.
[INFO] loading network...
Traceback (most recent call last):
File "classify.py", line 43, in <module>
color_model = load_model(color_model_path, custom_objects={"tf": tf})
File "/home/ubuntufashion/.local/lib/python2.7/site- 
packages/keras/engine/saving.py", line 260, in load_model
model = model_from_config(model_config, custom_objects=custom_objects)
File "/home/ubuntufashion/.local/lib/python2.7/site- 
packages/keras/engine/saving.py", line 334, in model_from_config
return deserialize(config, custom_objects=custom_objects)
File "/home/ubuntufashion/.local/lib/python2.7/site- 
packages/keras/layers/__init__.py", line 55, in deserialize
printable_module_name='layer')
File "/home/ubuntufashion/.local/lib/python2.7/site- 
packages/keras/utils/generic_utils.py", line 145, in 
deserialize_keras_object
list(custom_objects.items())))
File "/home/ubuntufashion/.local/lib/python2.7/site- 
packages/keras/engine/network.py", line 1017, in from_config
process_layer(layer_data)
File "/home/ubuntufashion/.local/lib/python2.7/site- 
packages/keras/engine/network.py", line 1003, in process_layer
custom_objects=custom_objects)
File "/home/ubuntufashion/.local/lib/python2.7/site- 
packages/keras/layers/__init__.py", line 55, in deserialize
printable_module_name='layer')
File "/home/ubuntufashion/.local/lib/python2.7/site- 
packages/keras/utils/generic_utils.py", line 145, in 
deserialize_keras_object
list(custom_objects.items())))
File "/home/ubuntufashion/.local/lib/python2.7/site- 
packages/keras/layers/core.py", line 730, in from_config
function = func_load(config['function'], globs=globs)
File "/home/ubuntufashion/.local/lib/python2.7/site- 
packages/keras/utils/generic_utils.py", line 235, in func_load
code = marshal.loads(raw_code)
ValueError: bad marshal data (unknown type code)

Thanks for reading this post!

Upvotes: 4

Views: 16241

Answers (2)

tom
tom

Reputation: 387

I got the same error as I installed python3.7 on debian 9, the original one was python3.5, and then I got this error. I fixed it by updating setuptools according this page:

https://github.com/pypa/setuptools/issues/1257

pip3 install -U setuptools

Upvotes: 6

李德新
李德新

Reputation: 11

When I was working the Udacity self-driving project(behaviral cloning), I hit the same issue the above. The model.h5 was generated by python 3.6.3, but my python version is 2.7, after I replaced it with python 3.6.3, it is OK. Hope it can help you.

Upvotes: 1

Related Questions