本文是关于运行from keras.utils import to_categorical出错如何解决
to_categorical报错
把keras库安装好后,在深度学习标签准备模块那里通常会用到keras.utils中的to_categorical函数,通常我们直接用引入函数:
from keras.utils import to_categorical
但是这样运行后就报错了,报错显示:
ImportError: cannot import name 'to_categorical'
解决办法
keras此时是在tensorflow的环境中
所以从tensorflow中引入就可以了,嘻嘻:
from tensorflow.keras.utils import to_categorical