问题描述
我的操作系统是Ubuntu。
当我运行我的keras模型时,我收到了此错误消息。
我已经用谷歌搜索了一些解决方案,但是它们不起作用。 例如,我已经尝试了本文中提到的解决方案:
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)
感谢您阅读这篇文章!
1楼
当我在进行Udacity自动驾驶项目(行为克隆)时,遇到了上述相同的问题。 model.h5是由python 3.6.3生成的,但是我的python版本是2.7,用python 3.6.3替换后,就可以了。 希望它能对您有所帮助。
2楼
我在Debian 9上安装python3.7时遇到了相同的错误,原始错误是python3.5,然后出现此错误。 我通过根据此页面更新setuptools来修复它:
pip3 install -U setuptools