Warning with GridSearchCV when using to train ANN

Solution for Warning with GridSearchCV when using to train ANN
is Given Below:

I’m learning to build an ANN, but I got some error when I tried to tune the parameters using GridSearchCV:

 def build_classifier(optimizer):
            classifier = Sequential()
            # First layer
            classifier.add(Dense(units = 6, activation = "relu", 
                                 kernel_initializer = "uniform", input_dim = 13))
            #classifier.add(Dropout(rate = 0.1)) # randomly dropout some neurons
            # Second layer
            classifier.add(Dense(units = 6, activation = "relu", 
                                 kernel_initializer = "uniform"))
            #classifier.add(Dropout(rate = 0.1)) # randomly dropout some neurons
            # Last layer
            classifier.add(Dense(units = 1, activation = "sigmoid", 
                                 kernel_initializer = "uniform"))
            classifier.compile(optimizer = "adam", loss = "BinaryCrossentropy", 
                              metrics = "accuracy")
            return classifier
            classifier = KerasClassifier(build_fn = build_classifier)
        parameters = {"batch_size": [25, 32], "epochs": [100, 500], 
                      "optimizer": ["adam", "rmsprop"]}
        grid_search = GridSearchCV(estimator = classifier, param_grid = parameters,
                                  scoring = "accuracy", cv = 10)
        grid_search = grid_search.fit(x_train, y_train)

So when I ran this:

parameters = {"batch_size": [25, 32], "epochs": [100, 500], 
              "optimizer": ["adam", "rmsprop"]}
grid_search = GridSearchCV(estimator = classifier, param_grid = parameters,
                          scoring = "accuracy", cv = 10)
grid_search = grid_search.fit(x_train, y_train)

I met this warning:

D:Anacondalibsite-packagestensorflowpythonkerasenginesequential.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).
  warnings.warn('`model.predict_classes()` is deprecated and '

I have tried many ways to fix this, but it didn’t work. I would be very appreciate if anyone could give any solution to this!

As mentioned in the warning model.predict_classes() is deprecated it will be removed in the new release. It recommended to use model.predict(x) instead. Take a look at the model predict api in detail here.

This warning message does not stop from execution, still you can train model without any error. You can suppress the Warning by

import logging, os
logging.disable(logging.WARNING)
os.environ["TF_CPP_MIN_LOG_LEVEL"] = "3"
import tensorflow as tf