I would like to enable dropout during inference. So, I am creating the dropout layer as follows:
self.monte_carlo_layer = None
if monte_carlo_dropout:
dropout_class = getattr(nn, 'Dropout{}d'.format(dimensions))
self.monte_carlo_layer = dropout_class(p=monte_carlo_dropout)
And I invoke it in the forward
function as:
def forward(self, x):
...
if self.monte_carlo_layer is not None:
x = self.monte_carlo_layer(x)
My question is will this ensure that the dropout will be invoked even during testing i.e. with eval
activated?