This allows the construction of training logic from the simplest to the most complicated scenarios.
The type of output of the process functions (i.e.
y_pred, y in the above examples) is not restricted. These functions can return everything the user wants. Output is set to an engine's internal object
engine.state.output and can be used further for any type of processing.
Events and Handers¶
To improve the engine’s flexibility, a configurable event system is introduced to facilitate the interaction on each step of the run. Namely,
Engine allows to add handlers on various
Events that are triggered during the run. When an event is triggered, attached handlers (named functions, lambdas, class functions) are executed. Here is a schema for when built-in events are triggered by default:
fire_event(Events.STARTED) while epoch < max_epochs: fire_event(Events.EPOCH_STARTED) # run once on data for batch in data: fire_event(Events.ITERATION_STARTED) output = process_function(batch) fire_event(Events.ITERATION_COMPLETED) fire_event(Events.EPOCH_COMPLETED) fire_event(Events.COMPLETED)
Note that each engine (i.e.
evaluator) has its own event system which allows to define its own engine's process logic.
Events and handlers, it is possible to completely customize the engine's runs in a very intuitive way: