比如这段代码现在出现TypeError: to_categorical() got an unexpected keyword argument ‘nb_classes’
# data pre-processing
# normalize
X_train = X_train.reshape(X_train.shape[0], -1) / 255
X_test = X_test.reshape(X_test.shape[0], -1) / 255
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
# data pre-processing
# normalize
X_train = X_train.reshape(X_train.shape[0], -1) / 255
X_test = X_test.reshape(X_test.shape[0], -1) / 255
y_train = np_utils.to_categorical(y_train, num_classes = 10)
y_test = np_utils.to_categorical(y_test, num_classes = 10)
详见:https://blog.csdn.net/weixin_45798684/article/details/106507183