r"""Set 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`, :class:`BatchNorm`, etc. Args:
(self: T, mode: bool = True)
| 2373 | yield from module.named_modules(memo, submodule_prefix, remove_duplicate) |
| 2374 | |
| 2375 | def train(self: T, mode: bool = True) -> T: |
| 2376 | r"""Set the module in training mode. |
| 2377 | |
| 2378 | This has any effect only on certain modules. See documentations of |
| 2379 | particular modules for details of their behaviors in training/evaluation |
| 2380 | mode, if they are affected, e.g. :class:`Dropout`, :class:`BatchNorm`, |
| 2381 | etc. |
| 2382 | |
| 2383 | Args: |
| 2384 | mode (bool): whether to set training mode (``True``) or evaluation |
| 2385 | mode (``False``). Default: ``True``. |
| 2386 | |
| 2387 | Returns: |
| 2388 | Module: self |
| 2389 | """ |
| 2390 | if not isinstance(mode, bool): |
| 2391 | raise ValueError("training mode is expected to be boolean") |
| 2392 | self.training = mode |
| 2393 | for module in self.children(): |
| 2394 | module.train(mode) |
| 2395 | return self |
| 2396 | |
| 2397 | def eval(self: T) -> T: |
| 2398 | r"""Set the module in evaluation mode. |