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)
| 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""" |