Keras Dropout Layer Model Predict

Viewed 1060

The dropout layer is only supposed to be used during the training of the model, not during testing.

If I have a dropout layer in my Keras sequential model, do I need to do something to remove or silence it before I do model.predict()?

1 Answers

No, you don't need to silence it or remove it. Keras automatically takes care of it.

It is clearly mentioned in the documentation. A Keras model has two modes:

  1. training
  2. testing

Regularization mechanisms, such as Dropout and L1/L2 weight regularization, are turned off at testing time.

Note: Also, Batch Normalization is a much-preferred technique for regularization, in my opinion, as compared to Dropout. Consider using it.

Related