MCPcopy Create free account
hub / github.com/Project-MONAI/MONAI / test_eval_mode

Method test_eval_mode

tests/networks/utils/test_train_mode.py:23–30  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

21class TestEvalMode(unittest.TestCase):
22
23 def test_eval_mode(self):
24 t = torch.rand(1, 1, 4, 4)
25 p = torch.nn.Conv2d(1, 1, 3)
26 p.eval()
27 self.assertFalse(p.training) # False
28 with train_mode(p):
29 self.assertTrue(p.training) # True
30 p(t).sum().backward()
31
32
33if __name__ == "__main__":

Callers

nothing calls this directly

Calls 2

train_modeFunction · 0.90
backwardMethod · 0.45

Tested by

no test coverage detected