InputMonitor¶
- class InputMonitor(reducer: Reducer, module: Module = None, train_update: bool = True, eval_update: bool = True, prepend: bool = False, filter_: Callable[[tuple[Any, ...]], bool] | None = None, map_: Callable[[tuple[Any, ...]], tuple[Tensor, ...]] | None = None)[source]¶
Bases:
MonitorRecords the inputs passed to a Module.
- Parameters:
reducer (Reducer) – underlying means for reducing samples over time and storing them.
module (Module, optional) – module to register as the target for monitoring, can be modified after construction. Defaults to
None.train_update (bool, optional) – if this monitor should be called when the module being monitored is in train mode. Defaults to
True.eval_update (bool, optional) – if this monitor should be called when the module being monitored is in eval mode. Defaults to
True.prepend (bool, optional) – if this monitor should be called before other registered forward prehooks. Defaults to
False.filter (Callable[[tuple[Any, ...]], bool] | None, optional) – test if the input should be passed to the reducer, ignores empty when
None. Defaults toNone.map (Callable[[tuple[Any, ...]], tuple[torch.Tensor, ...]] | None, optional) – modifies the input before being passed to the reducer, identity when
None. Defaults toNone.
Note
The inputs, which are received as a tuple, will be sent to
filter_. If this evaluates toTrue, they are forwarded tomap_, then unpacked intoreducer.- classmethod partialconstructor(reducer: Reducer, train_update: bool = True, eval_update: bool = True, prepend: bool = False, filter_: Callable[[tuple[Any, ...]], bool] | None = None, map_: Callable[[tuple[Any, ...]], Tensor] | None = None) MonitorConstructor[source]¶
Returns a function with a common signature for monitor construction.
- Parameters:
reducer (Reducer) – underlying means for reducing samples over time and storing them.
train_update (bool, optional) – if this monitor should be called when the module being monitored is in train mode. Defaults to
True.eval_update (bool, optional) – if this monitor should be called when the module being monitored is in eval mode. Defaults to
True.prepend (bool, optional) – if this monitor should be called before other registered forward prehooks or posthooks. Defaults to
False.filter (Callable[[tuple[Any, ...]], bool] | None, optional) – test if the input should be passed to the reducer, ignores empty when
None. Defaults toNone.map (Callable[[tuple[Any, ...]], torch.Tensor] | None, optional) – modifies the input before being passed to the reducer, \(0^\text{th}\) input if
None. Defaults toNone.
- Returns:
partial constructor for monitor.
- Return type: