keras调用model.load_weights()函数报错:AttributeError: ‘str‘ object has no attribute ‘decode‘

Traceback (most recent call last):
  File "C:/Users/Guangsheng Li/Desktop/Mask-RCNN-keras源码/mask-rcnn-keras-master/train.py", line 75, in
    model.load_weights(COCO_MODEL_PATH,by_name=True,skip_mismatch=True)
  File "C:\ProgramData\Anaconda3\lib\site-packages\keras\engine\topology.py", line 2653, in load_weights
    reshape=reshape)
  File "C:\ProgramData\Anaconda3\lib\site-packages\keras\engine\topology.py", line 3407, in load_weights_from_hdf5_group_by_name
    original_keras_version = f.attrs['keras_version'].decode('utf8')
AttributeError: 'str' object has no attribute 'decode'

报错原因:

h5py模块版本不对造成的,首先检查自己的h5py。

解决办法

卸载原来的h5py

pip uninstall h5py

重新安装2.10版本的h5py

pip install h5py==2.10 -i https://pypi.tuna.tsinghua.edu.cn/simple/

安装完成之后,程序就可以正常运行了!

参考博客链接:original_keras_version = f.attrs[‘keras_version‘].decode(‘utf8‘)_乐亦亦乐的博客-CSDN博客

你可能感兴趣的:(keras,深度学习,pytorch)