Monitors¶
Monitor¶
-
class
sconce.monitors.
Monitor
(name)[source]¶ Base class for monitors in sconce. A monitor is an object that a
Trainer
uses to record metrics during training or other tasks. This base class defines the interface that trainers use. Monitors can be composed together (using addition operator) to produce aCompositeMonitor
object.Parameters: name (str) – used to gain access to a monitor when it has been composed together into a CompositeMonitor
.-
end_session
(**kwargs)[source]¶ Called by a
Trainer
when a training/evaluation session has ended.Parameters: **kwargs – must be accepted to allow for future use cases.
-
start_session
(num_steps, **kwargs)[source]¶ Called by a
Trainer
when starting a training/evaluation session.Parameters: - num_steps (int) – [1, inf) the number of update/evaluation steps to expect.
- **kwargs – must be accepted to allow for future use cases.
-
write
(data, step, **kwargs)[source]¶ Called by a
Trainer
during a training/evaluation session just after the training/evaluation step.Parameters: - data (dict) – the output of the training/evaluation step. The keys may include, but are not limited to: {‘training_loss’, ‘validation_loss’, ‘learning_rate’}.
- step (float) – (0.0, inf) the step that was just completed.
Fractional steps are possible (see batch_multiplier option on
sconce.trainer.Trainer.train()
). - **kwargs – must be accepted to allow for future use cases.
-
CompositeMonitor¶
-
class
sconce.monitors.
CompositeMonitor
(monitors)[source]¶ A monitor composed of two or more monitors. Using this allows you to pass a single monitor object to a trainer method and have it use all of the composed monitors. Composed monitors can be accessed using their name like so:
>>> from sconce import monitors >>> metric_names = {'training_loss': 'loss', 'validation_loss': 'val_loss'} >>> stdout_monitor = monitors.StdoutMonitor(metric_names=metric_names) >>> dataframe_monitor = monitors.DataframeMonitor() >>> monitor = dataframe_monitor + stdout_monitor >>> monitor.dataframe_monitor <sconce.monitors.dataframe_monitor.DataframeMonitor at 0x7fb1fbd498d0> >>> dataframe_monitor is monitor.dataframe_monitor True
Parameters: monitors (iterable of Monitor
) – the monitors you want to compose together.