Activating the dropout in model eval mode in Pytorch

101 Views Asked by At
def eval_with_dropout(self):
        self.eval()
        for module in self.modules():
            if isinstance(module, nn.Dropout):
                module.train()

is it possible this way of implementing dropout ensemble in pytorch for model evaluation would mess other things in pytorch? is it the correct way of implementing dropout ensemble?

as I know the only differences in model.train() and model.eval() are in activation of Dropout layers and Batch normalization layers, but I am not sure about messing other components or procedures of training and evaluating in pytorch

0

There are 0 best solutions below