TypeError: to_categorical() got an unexpected keyword argument 'nb_classes'

在学习莫烦教程中keras教程时,报错:TypeError: to_categorical() got an unexpected keyword argument 'nb_classes',代码如下

X_train = X_train.reshape(X_train.shape[0],-1) / 255 #normalize
X_test  = X_test.reshape(X_test.shape[0],-1) / 255 #normalize
y_train = np_utils.to_categorical(y_train, nb_classes=10)
y_test = np_utils.to_categorical(y_test, nb_classes=10)

错误原因:keras版本问题,将nb_classes改为num_classes
参考keras文档:http://keras-cn.readthedocs.io/en/latest/utils/

原文地址:https://www.cnblogs.com/zeroingToOne/p/8484804.html