torchtraining.iterations¶
-
class
torchtraining.iterations.
Eval
(step: Any, module: torch.nn.modules.module.Module, data: Union[torch.utils.data.dataset.Dataset, torch.utils.data.dataloader.DataLoader], log: Union[int, str] = 'NONE', *args, **kwargs)[source]¶ Bases:
torchtraining.iterations.Iteration
Perform evaluation step until
data
is exhausted.Provided
module
will be passed to everystep
.- Parameters
step (torchtraining.steps.Step) – Single step to run. Usually subclass of
torchtraining.steps.Step
, but could be anyCallable
takingmodule
anddata
arguments and returning anything.module (torch.nn.Module) – Torch module (or modules) passed to
step
during each call.data ([torch.utils.data.Dataset | torch.utils.data.DataLoader]) – Iterable object (usually data or dataloader) yielding data passed to
step
.
- logstr | int, optional
Severity level for logging object’s actions. Available levels of logging:
NONE 0
TRACE 5
DEBUG 10
INFO 20
SUCCESS 25
WARNING 30
ERROR 40
CRITICAL 50
Default:
NONE
(no logging,0
priority)
-
class
torchtraining.iterations.
Iteration
(step: Any, module: torch.nn.modules.module.Module, data: Union[torch.utils.data.dataset.Dataset, torch.utils.data.dataloader.DataLoader], train: bool, log: Union[int, str] = 'NONE', *args, **kwargs)[source]¶ Bases:
torchtraining._base.Iteration
Perform
step
(train
oreval
) untildata
is exhausted.Provided
module
will be passed to everystep
.- Parameters
step (torchtraining.steps.Step) – Single step to run. Usually subclass of
torchtraining.steps.Step
, but could be anyCallable
takingmodule
anddata
arguments and returning anything.module (torch.nn.Module) – Torch module (or modules) passed to
step
during each call.data ([torch.utils.data.Dataset | torch.utils.data.DataLoader]) – Iterable object (usually data or dataloader) yielding data passed to
step
.
- train: bool
Whether
module
should be in training state (module.train()
) with enabled gradient or in evaluation mode (module.eval()
) with disabled gradient- logstr | int, optional
Severity level for logging object’s actions. Available levels of logging:
NONE 0
TRACE 5
DEBUG 10
INFO 20
SUCCESS 25
WARNING 30
ERROR 40
CRITICAL 50
Default:
NONE
(no logging,0
priority)
-
class
torchtraining.iterations.
Train
(step: Any, module: torch.nn.modules.module.Module, data: Union[torch.utils.data.dataset.Dataset, torch.utils.data.dataloader.DataLoader], log: Union[int, str] = 'NONE', *args, **kwargs)[source]¶ Bases:
torchtraining.iterations.Iteration
Perform training step until
data
is exhausted.Provided
module
will be passed to everystep
.- Parameters
step (torchtraining.steps.Step) – Single step to run. Usually subclass of
torchtraining.steps.Step
, but could be anyCallable
takingmodule
anddata
arguments and returning anything.module (torch.nn.Module) – Torch module (or modules) passed to
step
during each call.data ([torch.utils.data.Dataset | torch.utils.data.DataLoader]) – Iterable object (usually data or dataloader) yielding data passed to
step
.
- logstr | int, optional
Severity level for logging object’s actions. Available levels of logging:
NONE 0
TRACE 5
DEBUG 10
INFO 20
SUCCESS 25
WARNING 30
ERROR 40
CRITICAL 50
Default:
NONE
(no logging,0
priority)