torchliter.engine.base
EngineBase
Base class of Engine classes.
Attributes ———- epoch : int Current epoch iteration : int Current interation fractional_epoch: float fractional_epoch = epoch + iteration/epoch_length fractional_iteration : float fractional_iteration = iteration/epoch_length epoch_length : Optional[int] Total number of iterations in an epoch absolute_iterations : int absolute_iterations = epoch_length * epoch + iteration _registry : Tuple[Dict[str, Any]] Registry of engine components.
EngineBase.__init__
__init__()
EngineBase.after_iteration
after_iteration(**kwargs)
EngineBase.before_iteration
before_iteration(**kwargs)
EngineBase.eval
eval()
EngineBase.execute
execute(**kwargs: Any) → None
Executes stubs in queue.
Parameters ———- **kwargs : Any
Returns ——- None
Raises —— AttributeError No action attached to current stub.
EngineBase.load_state_dict
load_state_dict(state_dict: Dict[str, Dict[str, Any]]) → None
Load state into engine.
Parameters ———- state_dict : Dict[str, Dict[str, Any]] Engine state dict.
Returns ——- None
EngineBase.per_batch
per_batch(batch: Union[Tuple[Any], Dict[str, Any]], **kwargs: Any)
EngineBase.per_epoch
per_epoch(**kwargs)
Train, eval model or performe a lambda op by one epoch.
The stub must have dataloader
.
EngineBase.queue
queue(stubs: List[torchliter.stub.StubBase]) → None
Adds stubs to queue.
Parameters
———- stubs : List[StubBase] A list of stubs
.
Returns ——- None
EngineBase.reset_engine
reset_engine() → None
Reset engine state.
epoch -> 0 iteration -> 0 stubs -> []
EngineBase.reset_queue
reset_queue() → None
Resets stubs queue to empty.
EngineBase.state_dict
state_dict() → Dict[str, Dict[str, Any]]
Generate current state of the engine as Dict
.
Returns ——- Dict[str, Dict[str, Any]] Dict of component state dicts.
EngineBase.train
train()
EngineBase.when_epoch_finishes
when_epoch_finishes(**kwargs)
EngineBase.when_epoch_starts
when_epoch_starts(**kwargs)