MCPcopy Create free account
hub / github.com/apple/ml-pointersect / _set_train_mode

Method _set_train_mode

cdslib/core/script/base_train.py:626–635  ·  view source on GitHub ↗

Set all the nn.modules to train mode.

(self)

Source from the content-addressed store, hash-verified

624 getattr(self, name).to(device)
625
626 def _set_train_mode(self):
627 """Set all the nn.modules to train mode."""
628
629 vs = inspect.getmembers(self, lambda v: isinstance(v, BaseModel))
630 for v_name, v in vs:
631 v.train()
632
633 vs = inspect.getmembers(self, lambda v: isinstance(v, torch.nn.Module))
634 for v_name, v in vs:
635 v.train()
636
637 def _set_eval_mode(self):
638 """Set all the nn.modules to evaluation mode."""

Callers 1

runMethod · 0.95

Calls 1

trainMethod · 0.80

Tested by

no test coverage detected