报错 AttributeError: ‘str‘ object has no attribute ‘decode‘

在进行keras.models.load_model(path)时报错如下

File "C:\Users\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow_core\python\keras\saving\hdf5_format.py", line 160, in load_model_from_hdf5
    model_config = json.loads(model_config.decode('utf-8'))
AttributeError: 'str' object has no attribute 'decode'

因为model_config是str类型,所以没法decode(“utf-8”),所以把这部分去掉就可以了。
继续运行还是会在其他地方报错如下

File "C:\Users\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow_core\python\keras\saving\hdf5_format.py", line 160, in load_model_from_hdf5
    model_config = json.loads(model_config.decode('utf-8'))
AttributeError: 'str' object has no attribute 'decode'

继续把其他地方的decode(“utf-8”)去掉即可。

你可能感兴趣的:(tensorflow,tensorflow)