原代码段
import tensorflow as tf
from tensorflow.keras.applications.inception_v3 import InceptionV3
base_model = InceptionV3(weights='imagenet',include_top=False)
报错信息
AttributeError: ‘str’ object has no attribute ‘decode’
报错原因
Python3的str 默认不是bytes,所以不能decode,只能先encode转为bytes,再decode
python2的str 默认是bytes,所以能decode
(转自:Athena-ydy https://www.cnblogs.com/Athena-ydy/p/15218889.html)
问题解决
# 卸载原有 h5py
pip uninstall h5py
# 安装 2.10.0 版本 h5py
pip install h5py==2.10.0
If h5py>3, the code shows the error.
(转自:Narcis https://stackoverflow.com/questions/67236747/str-object-has-no-attribute-decode-for-tensorflow-in-python)