AttributeError: module ‘keras.utils‘ has no attribute ‘to_categorical‘
y_train = utils.to_categorical(y_train, num_classes=7)代码报错,因为TensorFlow与keras版本不对,需要指定版本TensorFlow2.5.0keras2.4.3用pip list查看下两者的版本或者输入命令查看查看:pythonimport tensorflowprint(tensorflow.__version__)卸载安装:pi
·
y_train = utils.to_categorical(y_train, num_classes=7)
代码报错,因为TensorFlow与keras版本不对,需要指定版本
TensorFlow2.5.0 keras2.4.3
用pip list查看下两者的版本或者输入命令查看
查看:
python
import tensorflow
print(tensorflow.__version__)
卸载安装:
pip uninstall tensorflow
pip install tensorflow==2.5.0
pip uninstall keras
pip install keras==2.4.3
更多推荐



所有评论(0)