问题描述:
tf=2.5.0中导入包
from keras.utils import to_categorical
报错
ImportError: cannot import name 'to_categorical' from 'keras.utils' (/usr/local/lib/python3.7/dist-packages/keras/utils/__init__.py)
解决方案:
现在keras完全置于tf模块中,这个要从tensoflow根模块导入,修改为:
from tensorflow.keras.utils import to_categorical