Keras AttributeError: ‘Sequential’ object has no attribute ‘predict_classes’

This function was removed in TensorFlow version 2.6.
According to the keras in rstudio reference

update to

predict_x=model.predict(X_test) 
classes_x=np.argmax(predict_x,axis=1)

Or use TensorFlow 2.5.x .

If you are using TensorFlow version 2.5, you will receive the following warning:

tensorflow\python\keras\engine\sequential.py:455: UserWarning: model.predict_classes() is deprecated and will be removed after 2021-01-01. Please use instead:* np.argmax(model.predict(x), axis=-1), if your model does multi-class classification (e.g. if it uses a softmax last-layer activation).* (model.predict(x) > 0.5).astype("int32"), if your model does binary classification (e.g. if it uses a sigmoid last-layer activation).

Leave a Comment