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

Method test_eval_mode

tests/networks/utils/test_eval_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 self.assertTrue(p.training) # True
27 with eval_mode(p):
28 self.assertFalse(p.training) # False
29 with self.assertRaises(RuntimeError):
30 p(t).sum().backward()
31
32
33if __name__ == "__main__":

Callers

nothing calls this directly

Calls 2

eval_modeFunction · 0.90
backwardMethod · 0.45

Tested by

no test coverage detected