Parameters

Parameters

class Parameters(fixed_params={'model': {}, 'training': {}}, variable_params={'model': {}, 'training': {}})[source]

Bases: delira.utils.config.LookupConfig

Class Containing all variable and fixed parameters for training and model instantiation

See also

trixi.util.Config

property hierarchy

Returns the current hierarchy

Returns

current hierarchy

Return type

str

nested_get(key, *args, **kwargs)

Returns all occurances of key in self and subdicts

Parameters
  • key (str) – the key to search for

  • *args – positional arguments to provide default value

  • **kwargs – keyword arguments to provide default value

Raises

KeyError – Multiple Values are found for key (unclear which value should be returned) OR No Value was found for key and no default value was given

Returns

value corresponding to key (or default if value was not found)

Return type

Any

permute_hierarchy()[source]

switches hierarchy

Returns

the class with a permuted hierarchy

Return type

Parameters

Raises

AttributeError – if no valid hierarchy is found

permute_to_hierarchy(hierarchy: str)[source]

Permute hierarchy to match the specified hierarchy

Parameters

hierarchy (str) – target hierarchy

Raises

ValueError – Specified hierarchy is invalid

Returns

parameters with proper hierarchy

Return type

Parameters

permute_training_on_top()[source]

permutes hierarchy in a way that the training-model hierarchy is on top

Returns

Parameters with permuted hierarchy

Return type

Parameters

permute_variability_on_top()[source]

permutes hierarchy in a way that the training-model hierarchy is on top

Returns

Parameters with permuted hierarchy

Return type

Parameters

save(filepath: str)[source]

Saves class to given filepath (YAML + Pickle)

Parameters

filepath (str) – file to save data to

property training_on_top

Return whether the training hierarchy is on top

Returns

whether training is on top

Return type

bool

update(dict_like, deep=False, ignore=None, allow_dict_overwrite=True)[source]

Update entries in the Parameters

Parameters
  • dict_like (dict) – Update source

  • deep (bool) – Make deep copies of all references in the source.

  • ignore (Iterable) – Iterable of keys to ignore in update

  • allow_dict_overwrite (bool) – Allow overwriting with dict. Regular dicts only update on the highest level while we recurse and merge Configs. This flag decides whether it is possible to overwrite a ‘regular’ value with a dict/Config at lower levels. See examples for an illustration of the difference

  • Examples

  • ---------

  • following illustrates the update behaviour if (The) –

:param : :type : obj:allow_dict_overwrite is active. If it isn’t, an AttributeError :param would be raised, originating from trying to update “string”::

config1 = Config(config={
    "lvl0": {
        "lvl1": "string",
        "something": "else"
    }
})

config2 = Config(config={
    "lvl0": {
        "lvl1": {
            "lvl2": "string"
        }
    }
})

config1.update(config2, allow_dict_overwrite=True)

>>>config1
{
    "lvl0": {
        "lvl1": {
            "lvl2": "string"
        },
        "something": "else"
    }
}
property variability_on_top

Return whether the variability is on top

Returns

whether variability is on top

Return type

bool