Observers¶
Olympus use a set of Observer objects to monitor a training in progress.
This allow Olympus to keep the training code short and focused on its purpose.
For example, all metrics, validation, online accuracy, speed are computed through observer, making that logic easily reusable for different tasks.
Observer Interface¶
-
olympus.observers.observer.Metric¶ alias of
olympus.observers.observer.Observer
-
class
olympus.observers.observer.Observer(frequency_new_epoch: int = 0, frequency_new_batch: int = 0, frequency_new_trial: int = 0, priority: int = 0) → None[source]¶ Bases:
objectMetrics are observers that receives events periodically
Attributes: - frequency_epoch: int
Controls how often
on_new_epochis called, 0 disables it- frequency_batch: int
Controls how often
on_new_batchis called, 0 disables it- frequency_trial: int
Controls how often
on_new_trialis called, 0 disables it- priority: int
Controls which metric is called first
Methods
every(*args[, epoch, batch])Define how often this metric should be called load_state_dict(state_dict)Load a state dictionary to resume a previous training on_end_train(task[, step])Called at the end of training after the last epoch on_new_batch(task, step[, input, context])Called after a batch has been processed on_new_epoch(task, epoch, context)Called at the end of an epoch, before a new epoch starts on_new_trial(task, step, parameters, uid)Called after a trial has been processed on_start_train(task[, step])Called on ce the training starts state_dict()Return a state dictionary used to checkpointing and resuming value()Return the key values that metrics computes -
frequency_new_batch= 0¶
-
frequency_new_epoch= 0¶
-
frequency_new_trial= 0¶
-
on_new_epoch(task, epoch, context)[source]¶ Called at the end of an epoch, before a new epoch starts
-
on_start_train(task, step=None)[source]¶ Called on ce the training starts
Notes
You should not rely on this function to initialize your metric as it will not be called if the training is resumed from a previous state
-
priority= 0¶
Observer List¶
-
olympus.observers.MetricList¶ alias of
olympus.observers.ObserverList
-
class
olympus.observers.ObserverList(*args, task=None, name=None)[source]¶ Bases:
objectMetricList relays the Event to the Metrics/Observers
Methods
append(m[, key])Insert a new metric to compute end_batch(step[, input, context])Broadcast a new_batchevent to all metricsend_epoch(epoch[, context])Broadcast a new_epochevent to all metricsend_train()Broadcast a finish event to all metrics get(key[, default])Retrieve a metric from its key load_state_dict(state_dict[, strict])Resume all children metrics using a state_dict new_batch(step[, input, context])Broadcast a new_batchevent to all metricsnew_epoch(epoch[, context])Broadcast a new_epochevent to all metricsnew_trial(parameters, uid)Broadcast a new_trialeventreport([pprint, print_fun])Pretty prints all the metrics resume_train(start_epoch)Broadcast a resume event to all metrics start_train()Broadcast a startevent to all metricsstate_dict([destination, prefix, keep_vars])Save all the children states value()Returns a dictionary of all computed metrics broadcast_event should_run -
append(m: olympus.observers.observer.Observer, key=None)[source]¶ Insert a new metric to compute
Parameters: - m: Metric
new metric to insert
- key: Optional[str]
optional key used to retrieve the metric by default the type name will be used as key
-