pytorch_pfn_extras.training.extension.make_extension#

pytorch_pfn_extras.training.extension.make_extension(trigger=(1, 'iteration'), default_name=None, priority=100, finalizer=<function <lambda>>, initializer=<function <lambda>>, on_error=<function <lambda>>)#

Decorator to make given function into an extension.

This decorator just adds some attributes to a given function. The value of the attributes are given by the arguments of this decorator.

See Extension for details of extensions. Most of the default values of arguments also follow those for this class.

Parameters:
  • trigger (TriggerLike) – Default trigger of the extension.

  • default_name (Optional[str]) – Default name of the extension. The name of a given function is used by default.

  • priority (int) – Default priority of the extension.

  • finalizer (ExtensionLike) – Finalizer function of this extension. It is called at the end of the training loop.

  • initializer (ExtensionLike) – Initializer function of this extension. It is called at the beginning of the training loop.

  • on_error (Callable[[ExtensionsManagerProtocol, Exception, TracebackType], None]) – Error handler callback function of this extension. It is called after an error is raised during the training loop.

Return type:

Callable[[ExtensionLike], ExtensionLike]