解决方法 将 from keras.utils import to_categorical 改为: from tensorflow.keras.utils import to_categorical 即可