ptrblck:

This flag is then used in some modules (e.g. nn.Dropout and batchnorm layers) so switch the behavior in their forward method.


Do you mean that I should put train() in this function?
def forward(self, x):
    return self.model(x)