MCPcopy Create free account
hub / github.com/Oneflow-Inc/oneflow / train

Method train

python/oneflow/nn/modules/module.py:758–779  ·  view source on GitHub ↗

r""" train(mode=True) Sets the module in training mode. This has any effect only on certain modules. See documentations of particular modules for details of their behaviors in training/evaluation mode, if they are affected, e.g. :class:`Dropout`, :cl

(self: T, mode: bool = True)

Source from the content-addressed store, hash-verified

756 yield m
757
758 def train(self: T, mode: bool = True) -> T:
759 r"""
760 train(mode=True)
761
762 Sets the module in training mode.
763
764 This has any effect only on certain modules. See documentations of
765 particular modules for details of their behaviors in training/evaluation
766 mode, if they are affected, e.g. :class:`Dropout`, :class:`BatchNorm1d`,
767 etc.
768
769 Args:
770 mode (bool): whether to set training mode (``True``) or evaluation
771 mode (``False``). Default: ``True``.
772
773 Returns:
774 Module: self
775 """
776 self.training = mode
777 for module in self.children():
778 module.train(mode)
779 return self
780
781 def eval(self: T) -> T:
782 r"""

Callers 4

test_train_evalMethod · 0.95
evalMethod · 0.95
stepMethod · 0.45
update_bnFunction · 0.45

Calls 1

childrenMethod · 0.95

Tested by 1

test_train_evalMethod · 0.76