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

迷南。 2022-12-19 06:09 343阅读 0赞

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

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

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

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

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

发表评论

表情:
评论列表 (有 0 条评论,343人围观)

还没有评论,来说两句吧...

相关阅读