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
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
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
You don't want to use Dropout in Test phase.
Dropout is a technique used to force neurons to be more independent each other: each neuron will be deactivate with the probability that you set, but only in the training phase.
In the Test phase you keep all the neurons working.
More details here and here