edflow.iterators.template_iterator module¶
Summary¶
Classes:
A specialization of PyHookedModelIterator which adds reasonable default behaviour. |
Reference¶
-
class
edflow.iterators.template_iterator.
TemplateIterator
(*args, **kwargs)[source]¶ Bases:
edflow.iterators.model_iterator.PyHookedModelIterator
A specialization of PyHookedModelIterator which adds reasonable default behaviour. Subclasses should implement save, restore and step_op.
-
__init__
(*args, **kwargs)[source]¶ Constructor.
- Parameters
model (object) – Model class.
num_epochs (int) – Number of times to iterate over the data.
hooks (list) – List containing
Hook
instances.hook_freq (int) – Frequency at which hooks are evaluated.
bar_position (int) – Used by tqdm to place bars at the right position when using multiple Iterators in parallel.
-
step_ops
()[source]¶ Defines ops that are called at each step.
- Returns
- Return type
The operation run at each step.
-
step_op
(model, **kwargs)[source]¶ Actual step logic. By default, a dictionary with keys ‘train_op’, ‘log_op’, ‘eval_op’ and callable values is expected. ‘train_op’ should update the model’s state as a side-effect, ‘log_op’ will be logged to the project’s train folder. It should be a dictionary with keys ‘images’ and ‘scalars’. Images are written as png’s, scalars are written to the log file and stdout. Outputs of ‘eval_op’ are written into the project’s eval folder to be evaluated with edeval.
-