Search code examples
machine-learningkerasdropout

Keras: how to use dropout at train and test phase?


Is it possible to use dropout at train and test phase in Keras?

Like described here: https://github.com/soumith/ganhacks#17-use-dropouts-in-g-in-both-train-and-test-phase


Solution

  • Sure, you can set training argument to True when calling the Dropout layer. In this way, dropout would be applied in both training and test phases:

    drp_output = Dropout(rate)(inputs, training=True)  # dropout would be active in train and test phases