ValueError:编组数据错误(类型代码未知),如何解决此问题?

时间:2019-06-20 01:50:50

标签: python-2.7 tensorflow keras

当我运行代码时,该错误消息就会出现。

我正在使用centos,python 2.7.5,keras 2.2.4和tensorflow 1.14.0。有人说“删除所有.pyc文件”,但是我没有sudo帐户,因此无法删除其他帐户中的文件。所有进程都在虚拟环境上运行。

错误消息是

Using TensorFlow backend.
WARNING: Logging before flag parsing goes to stderr.
W0619 17:45:27.349198 139629504448320 deprecation_wrapper.py:119] From /home/sea/Programs/generalized-phase-detection/generalized-phase-detection-master/venv/lib/python2.7/site-packages/keras/backend/tensorflow_backend.py:517: The name tf.placeholder is deprecated. Please use tf.compat.v1.placeholder instead.

Traceback (most recent call last):
  File "./gpd_predict.py", line 164, in <module>
    model = model_from_json(loaded_model_json, custom_objects={'tf':tf})
  File "/home/sea/Programs/generalized-phase-detection/generalized-phase-detection-master/venv/lib/python2.7/site-packages/keras/engine/saving.py", line 492, in model_from_json
    return deserialize(config, custom_objects=custom_objects)
  File "/home/sea/Programs/generalized-phase-detection/generalized-phase-detection-master/venv/lib/python2.7/site-packages/keras/layers/__init__.py", line 55, in deserialize
    printable_module_name='layer')
  File "/home/sea/Programs/generalized-phase-detection/generalized-phase-detection-master/venv/lib/python2.7/site-packages/keras/utils/generic_utils.py", line 145, in deserialize_keras_object
    list(custom_objects.items())))
  File "/home/sea/Programs/generalized-phase-detection/generalized-phase-detection-master/venv/lib/python2.7/site-packages/keras/engine/network.py", line 1022, in from_config
    process_layer(layer_data)
  File "/home/sea/Programs/generalized-phase-detection/generalized-phase-detection-master/venv/lib/python2.7/site-packages/keras/engine/network.py", line 1008, in process_layer
    custom_objects=custom_objects)
  File "/home/sea/Programs/generalized-phase-detection/generalized-phase-detection-master/venv/lib/python2.7/site-packages/keras/layers/__init__.py", line 55, in deserialize
    printable_module_name='layer')
  File "/home/sea/Programs/generalized-phase-detection/generalized-phase-detection-master/venv/lib/python2.7/site-packages/keras/utils/generic_utils.py", line 145, in deserialize_keras_object
    list(custom_objects.items())))
  File "/home/sea/Programs/generalized-phase-detection/generalized-phase-detection-master/venv/lib/python2.7/site-packages/keras/layers/core.py", line 735, in from_config
    function = func_load(config['function'], globs=globs)
  File "/home/sea/Programs/generalized-phase-detection/generalized-phase-detection-master/venv/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)

我不知道这是否是问题行,但这行只是我在错误消息中的代码。 (最后一行)

# load json and create model
    json_file = open('model_pol.json', 'r')
    loaded_model_json = json_file.read()
    json_file.close()
    model = model_from_json(loaded_model_json, custom_objects={'tf':tf})

如何运行该程序?

0 个答案:

没有答案