pytorch_pfn_extras.training.extension.Extension¶
- class pytorch_pfn_extras.training.extension.Extension¶
Base class of extensions.
An extension is a callable object that takes the manager object as the argument. It also provides some default configurations as its attributes, e.g. the default trigger and the default priority. This class provides a set of typical default values for these attributes.
There are three ways to define users’ own extensions: inheriting this class, decorating closures by
make_extension()
, or using any callable including lambda functions as extensions. Decorator can slightly reduce the overhead and is much easier to use, while this class provides more flexibility (for example, it can have methods to configure the behavior). Using a lambda function allows one-line coding for simple purposes, but users have to specify the configurations as arguments toExtensionsManager.extend()
. For a callable not inheriting this class, the default configurations of this class are used unless the user explicitly specifies them inExtensionsManager.extend()
method.- trigger¶
Default value of trigger for this extension. It is set to
(1, 'iteration')
by default.- Type
TriggerLike
- priority¶
Default priority of the extension. It is set to
PRIORITY_READER
by default.- Type
int
- ~Extension.name
Name of the extension. It is set to
None
by default. This value will be overwritten when registering an extension to a manager. Seepytorch_pfn_extras.ExtensionsManager.extend()
for details.
- __init__()¶
Methods
__init__
()finalize
()Finalizes the extension.
initialize
(manager)Initializes up the manager state.
load_state_dict
(to_load)on_error
(manager, exc, tb)Handles the error raised during training before finalization.
state_dict
()Serializes the extension state.
Attributes
default_name
Default name of the extension.
is_async
name
needs_model_state