ValueError:错误的封送数据(未知类型代码)

Posted

技术标签:

【中文标题】ValueError:错误的封送数据(未知类型代码)【英文标题】:ValueError: bad marshal data (unknown type code) 【发布时间】:2019-02-27 12:52:09 【问题描述】:

我的操作系统是 Ubuntu。

我在运行 keras 模型时收到此错误消息。

我已经搜索了一些解决方案,但它们不起作用。例如,我尝试了这篇文章中提到的解决方案: 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)

感谢您阅读这篇文章!

【问题讨论】:

【参考方案1】:

我在debian 9上安装python3.7时遇到了同样的错误,原来是python3.5,然后我就遇到了这个错误。我通过根据此页面更新 setuptools 来修复它:

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

pip3 install -U setuptools

【讨论】:

【参考方案2】:

当我在从事 Udacity 自动驾驶项目(行为克隆)时,我遇到了与上述相同的问题。 model.h5是python 3.6.3生成的,但是我的python版本是2.7,换成python 3.6.3后就OK了。希望对你有帮助。

【讨论】:

以上是关于ValueError:错误的封送数据(未知类型代码)的主要内容,如果未能解决你的问题,请参考以下文章

ValueError:未知标签类型:SVM 中的“连续”错误

ValueError:未知标签类型:拟合数据时的“连续多输出”

MLP 分类器:“ValueError:未知标签类型”

ValueError:未知标签类型

C#中出现的错误

伯努利朴素贝叶斯错误:ValueError:未知标签类型:(array([0, 0, 0, ..., 0, 0, 0], dtype=object),)