tensorflow2.1.0/tensorflow2.0.0版本报如下错误:
File "/databricks/python/lib/python3.7/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 "/databricks/python/lib/python3.7/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'
https://github.com/tensorflow/tensorflow/issues/44467
是由于tensorflow2.1.0支持h5py<3.0.0,而在安装tensorflow会自动安装h5py 3.1.0 。
只要运行如下命令即可:
pip install tensorflow h5py == 2.10.0