MonitorPool¶
- class MonitorPool[source]¶
Bases:
ModuleCollection of shared monitors.
- add_monitor(observed: str, name: str, attr: str, constructor: MonitorConstructor, unique: bool = False, /, **tags: Any) Monitor[source]¶
Adds a monitor to an observable.
- Parameters:
observed (str) – name of the observable to which the monitor will be added.
name (str) – name of the monitor to add (unique to the observable).
attr (str) – dot-separated attribute to monitor, relative to the observable.
constructor (MonitorConstructor) – partial constructor for the monitor.
unique (bool, optional) – if the monitor should never be aliased from the pool. Defaults to
False.**tags (Any) – tags to determine if the monitor is unique amongst monitors with the same name, targeting the same attribute (aligned to the basis).
- Raises:
AttributeError – specified observable does not exist.
- Returns:
added or retrieved monitor.
- Return type:
- add_observed(name: str, value: Observable) Observable[source]¶
Adds an observable.
- Parameters:
name (str) – name of the observable to add.
value (Observable) – observable to add to this pool.
- Raises:
RuntimeError – an observable with the specified name already exists.
RuntimeError – an observable with the specified name existed and was registered, but removed from memory without deleting it from the pool.
- Returns:
added observable.
- Return type:
- del_monitor(observed: str, monitor: str) None[source]¶
Deletes an added monitor.
- Parameters:
- Raises:
AttributeError – specified observable does not exist, or does not have a monitor with the specified name added to it.
- del_observed(name: str) None[source]¶
Deletes an added observable.
- Parameters:
name (str) – name of the observable to delete.
Important
This does not strictly delete the observable, it is still owned by its basis. Its monitors are however deleted.
- get_observed(name: str) Observable[source]¶
Gets an added observable.
- Parameters:
name (str) – name of the observable to get.
- Returns:
specified observable, if it exists.
- Return type:
- property monitors: Iterator[Monitor]¶
Added monitors.
Because monitors for each
Poolare pooled together for each trainer, duplicate monitors are not created where possible. The number of monitors here may be less than the number of added monitors.- Yields:
Monitor – added monitors.
- property named_monitors: Iterator[tuple[tuple[str, str], Monitor]]¶
Iterable of added monitors and tuples of the cell and monitor name.
- Yields:
tuple[tuple[str, str], Monitor] – tuple of an added monitor and a tuple of the observable name and monitor name corresponding to it.