Framework source C:\ProgramData\anaconda3\envs\bigbro\Lib\site-packages\torch\nn\modules\module.py
SHA256 4385eb888c1ba86393d05b36212eddde134d10f5bed8eaf69580f78835c4454c
2872:     def train(self, mode: bool = True) -> Self:
2873:         r"""Set the module in training mode.
2874: 
2875:         This has an effect only on certain modules. See the documentation of
2876:         particular modules for details of their behaviors in training/evaluation
2877:         mode, i.e., whether they are affected, e.g. :class:`Dropout`, :class:`BatchNorm`,
2878:         etc.
2879: 
2880:         Args:
2881:             mode (bool): whether to set training mode (``True``) or evaluation
2882:                          mode (``False``). Default: ``True``.
2883: 
2884:         Returns:
2885:             Module: self
2886:         """
2887:         if not isinstance(mode, bool):
2888:             raise ValueError("training mode is expected to be boolean")
2889:         self.training = mode
2890:         for module in self.children():
2891:             module.train(mode)
2892:         return self
2893: 
2894:     def eval(self) -> Self:
2895:         r"""Set the module in evaluation mode.
2896: 
2897:         This has an effect only on certain modules. See the documentation of
2898:         particular modules for details of their behaviors in training/evaluation
2899:         mode, i.e. whether they are affected, e.g. :class:`Dropout`, :class:`BatchNorm`,
2900:         etc.
2901: 
2902:         This is equivalent with :meth:`self.train(False) <torch.nn.Module.train>`.
2903: 
2904:         See :ref:`locally-disable-grad-doc` for a comparison between
2905:         `.eval()` and several similar mechanisms that may be confused with it.
2906: 
2907:         Returns:
2908:             Module: self
2909:         """
2910:         return self.train(False)
2911: 
2894:     def eval(self) -> Self:
2895:         r"""Set the module in evaluation mode.
2896: 
2897:         This has an effect only on certain modules. See the documentation of
2898:         particular modules for details of their behaviors in training/evaluation
2899:         mode, i.e. whether they are affected, e.g. :class:`Dropout`, :class:`BatchNorm`,
2900:         etc.
2901: 
2902:         This is equivalent with :meth:`self.train(False) <torch.nn.Module.train>`.
2903: 
2904:         See :ref:`locally-disable-grad-doc` for a comparison between
2905:         `.eval()` and several similar mechanisms that may be confused with it.
2906: 
2907:         Returns:
2908:             Module: self
2909:         """
2910:         return self.train(False)
2911: 
2912:     def requires_grad_(self, requires_grad: bool = True) -> Self:
2913:         r"""Change if autograd should record operations on parameters in this module.
2914: 
2915:         This method sets the parameters' :attr:`requires_grad` attributes
2916:         in-place.
2917: 
2918:         This method is helpful for freezing part of the module for finetuning
2919:         or training parts of a model individually (e.g., GAN training).
2920: 
2921:         See :ref:`locally-disable-grad-doc` for a comparison between
2922:         `.requires_grad_()` and several similar mechanisms that may be confused with it.
2923: 
2924:         Args:
2925:             requires_grad (bool): whether autograd should record operations on
2926:                                   parameters in this module. Default: ``True``.
2927: 
2928:         Returns:
2929:             Module: self
2930:         """
2931:         for p in self.parameters():
2932:             p.requires_grad_(requires_grad)
2933:         return self