2
$\begingroup$

I have a simple LSTM network developped using keras:

model = Sequential()
model.add(LSTM(rnn_size,input_shape=(2,w),dropout = 0.25 , recurrent_dropout=0.25))
model.add(Dense(2))

I would like to apply the MC dropout method. How can I enable dropout in the test phase in order to compute the uncertainty?

Thanks.

$\endgroup$
  • 1
    $\begingroup$ Welcome! What do you mean by MC? Please consider dropout is used while training not testing. $\endgroup$ – Media Mar 26 at 14:29
  • $\begingroup$ i mean montecarlo dropout ,which is a bayesien neural network approach for computing the uncertainty in deep learning $\endgroup$ – khaoula Mar 26 at 14:38
1
$\begingroup$

Well, in order to enable dropout during test phase you can do something like this:

keras.layers.Dropout(0.5)(x, training=True)

Then you'll probably want to run it multiple times. If you don't care about the inference time just run forward pass multiple times and at the end calculate mean and variance of your output.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.