Skip to content

declearn.optimizer.list_optim_modules

Return a mapping of registered OptiModule subclasses.

This function aims at making it easy for end-users to list and access all available OptiModule optimizer plug-ins at any given time. The returned dict uses unique identifier keys, which may be used to add the associated plug-in to a declearn.optimizer.Optimizer without going through the fuss of importing and instantiating it manually.

Note that the mapping will include all declearn-provided plug-ins, but also registered plug-ins provided by user or third-party code.

See also

Returns:

Name Type Description
mapping Dict[str, Type[OptiModule]]

Dictionary mapping unique str identifiers to OptiModule class constructors.

Source code in declearn/optimizer/_utils.py
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
def list_optim_modules() -> Dict[str, Type[OptiModule]]:
    """Return a mapping of registered OptiModule subclasses.

    This function aims at making it easy for end-users to list and access
    all available OptiModule optimizer plug-ins at any given time. The
    returned dict uses unique identifier keys, which may be used to add
    the associated plug-in to a [declearn.optimizer.Optimizer][] without
    going through the fuss of importing and instantiating it manually.

    Note that the mapping will include all declearn-provided plug-ins,
    but also registered plug-ins provided by user or third-party code.

    See also
    --------
    * [declearn.optimizer.modules.OptiModule][]:
        API-defining abstract base class for the OptiModule plug-ins.
    * [declearn.optimizer.list_optim_regularizers][]:
        Counterpart function for Regularizer plug-ins.

    Returns
    -------
    mapping:
        Dictionary mapping unique str identifiers to OptiModule
        class constructors.
    """
    return access_types_mapping("OptiModule")