How to check from within a model if it is currently in train or eval mode?
From the Pytorch forum, with a small tweak:
use
if self.training:
# it's in train mode
else:
# it's in eval mode
Always better to have a stack overflow answer than to look at forums.