How to know the status for the model? train or eval?

Hi all,

It is a simple question. What function can help me to know whether my model is in train mode or eval mode? Just print out the status of the model is enough. Thanks!


All nn.Modules have an attribute .training which is True by default.

nn.Module().training  # True


Thanks! That’s exactly what I need.