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/


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM