|
Safemotion Lib
|
Public Member Functions | |
| before_train (self) | |
| after_train (self) | |
| before_step (self) | |
| after_step (self) | |
Base class for hooks that can be registered with :class:`TrainerBase`.
Each hook can implement 4 methods. The way they are called is demonstrated
in the following snippet:
.. code-block:: python
hook.before_train()
for iter in range(start_iter, max_iter):
hook.before_step()
trainer.run_step()
hook.after_step()
hook.after_train()
Notes:
1. In the hook method, users can access `self.trainer` to access more
properties about the context (e.g., current iteration).
2. A hook that does something in :meth:`before_step` can often be
implemented equivalently in :meth:`after_step`.
If the hook takes non-trivial time, it is strongly recommended to
implement the hook in :meth:`after_step` instead of :meth:`before_step`.
The convention is that :meth:`before_step` should only take negligible time.
Following this convention will allow hooks that do care about the difference
between :meth:`before_step` and :meth:`after_step` (e.g., timer) to
function properly.
Attributes:
trainer: A weak reference to the trainer object. Set by the trainer when the hook is
registered.
Definition at line 22 of file train_loop.py.
| fastreid.engine.train_loop.HookBase.after_step | ( | self | ) |
Called after each iteration.
Reimplemented in fastreid.engine.hooks.CallbackHook, fastreid.engine.hooks.IterationTimer, fastreid.engine.hooks.PeriodicWriter, fastreid.engine.hooks.PeriodicCheckpointer, fastreid.engine.hooks.LRScheduler, fastreid.engine.hooks.AutogradProfiler, fastreid.engine.hooks.EvalHook, fastreid.engine.hooks.PreciseBN, and fastreid.engine.hooks.SWA.
Definition at line 68 of file train_loop.py.
| fastreid.engine.train_loop.HookBase.after_train | ( | self | ) |
Called after the last iteration.
Reimplemented in fastreid.engine.hooks.CallbackHook, fastreid.engine.hooks.IterationTimer, fastreid.engine.hooks.PeriodicWriter, and fastreid.engine.hooks.EvalHook.
Definition at line 56 of file train_loop.py.
| fastreid.engine.train_loop.HookBase.before_step | ( | self | ) |
Called before each iteration.
Reimplemented in fastreid.engine.hooks.CallbackHook, fastreid.engine.hooks.IterationTimer, fastreid.engine.hooks.AutogradProfiler, fastreid.engine.hooks.FreezeLayer, and fastreid.engine.hooks.SWA.
Definition at line 62 of file train_loop.py.
| fastreid.engine.train_loop.HookBase.before_train | ( | self | ) |
Called before the first iteration.
Reimplemented in fastreid.engine.hooks.CallbackHook, fastreid.engine.hooks.IterationTimer, and fastreid.engine.hooks.PeriodicCheckpointer.
Definition at line 50 of file train_loop.py.