tensorflow2加载model出现AttributeError: ‘str‘ object has no attribute ‘decode‘

tensorflow2.6加载模型,出现AttributeError: ‘str’ object has no attribute ‘decode’

import tensorflow as tf
model = tf.keras.models.load_model('/root/Web/test.h5')

报错:
Traceback (most recent call last):
File “”, line 1, in
File “/usr/local/lib64/python3.6/site-packages/tensorflow_core/python/keras/saving/save.py”, line 146, in load_model
return hdf5_format.load_model_from_hdf5(filepath, custom_objects, compile)
File “/usr/local/lib64/python3.6/site-packages/tensorflow_core/python/keras/saving/hdf5_format.py”, line 166, in load_model_from_hdf5
model_config = json.loads(model_config.decode(‘utf-8’))
AttributeError: ‘str’ object has no attribute ‘decode’

解决方法:

pip install h5py==2.10.0

猜你喜欢

转载自blog.csdn.net/qq_32650831/article/details/120894156