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