24

How to check from within a model if it is currently in train or eval mode?

1 Answer 1

34

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.

Explanation about the modes

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.