Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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!

like image 555
elena Avatar asked Mar 06 '23 08:03

elena


1 Answers

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
like image 107
tom Avatar answered Mar 07 '23 22:03

tom