We Are Going To Discuss About **Keras AttributeError: ‘Sequential’ object has no attribute ‘predict_classes’**. So lets Start this Python Article.

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

**How to solve Keras AttributeError: 'Sequential' object has no attribute 'predict_classes'**This function were 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 or later.**

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).**Keras AttributeError: 'Sequential' object has no attribute 'predict_classes'**This function were 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 or later.**

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).

## Solution 1

This function were 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 or later.**

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).

Original Author Xueke Of This Content

## Solution 2

I experienced the same error, I use this following code, and succeed

Replaced:

```
predictions = model.predict_classes(x_test)
```

With this one:

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

Type of python packages : Tensorflow 2.6.0

Original Author M.Nuramzan Iftari Of This Content

## Solution 3

We can replace the problematic code line with the following:

```
y_predict = np.argmax(model.predict(x_test), axis=-1)
```

Original Author Jaden Tseng Of This Content

## Solution 4

I used following code for predictions

```
y_pred = model.predict(X_test)
y_pred = np.round(y_pred).astype(int)
```

Original Author arun Of This Content

## Conclusion

So This is all About **This Tutorial.** Hope This Tutorial Helped You. Thank You.