'Sequential' object has no attribute 'predict_classes'

Hello All,

I’m trying to run my model but facing "‘Sequential’ object has no attribute ‘predict_classes’ " I have
Name: tensorflow Version: 2.9.1 Name: keras Version: 2.9.0. Is deprecated? If not then please help me to resolve it. If yes, then help me alternate. I have searched but no luck.

Thank you.

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

It appears @Tina_Sabri was going to cite the Keras RStudio reference:

If your model does multi-class classification: (e.g. if it uses a softmax last-layer activation).

model %>% predict(x) %>% k_argmax()

if your model does binary classification (e.g. if it uses a sigmoid last-layer activation).

model %>% predict(x) %>% >(0.5) %>% k_cast("int32")

The equivalents in Python would be:

Multi-class Classification
predictions = np.argmax(model.predict(x_test), axis=-1)

Binary Classification
predictions = (model.predict(x_test) > 0.5).astype("int32")

Additional Source


Updated Keras RStudio Reference - TensorFlow for R – predict_proba