leaspy.models.utils.attributes.abstract_attributes module

class AbstractAttributes(name: str, dimension: Optional[int] = None, source_dimension: Optional[int] = None)

Bases: ABC

Abstract base class for attributes of models.

Contains the common attributes & methods of the different attributes classes. Such classes are used to update the models’ attributes.

Parameters
namestr
dimensionint (default None)
source_dimensionint (default None)
Raises
LeaspyModelInputError

if any inconsistent parameter.

Attributes
namestr

Name of the associated leaspy model.

dimensionint

Number of features of the model

source_dimensionint

Number of sources of the model TODO? move to AbstractManifoldModelAttributes?

univariatebool

Whether model is univariate or not (i.e. dimension == 1)

has_sourcesbool

Whether model has sources or not (not univariate and source_dimension >= 1) TODO? move to AbstractManifoldModelAttributes?

update_possibilitiestuple[str] (default empty)

Contains the available parameters to update. Different models have different parameters.

Methods

get_attributes()

Returns the essential attributes of a given model.

move_to_device(device)

Move the tensor attributes of this class to the specified device.

update(names_of_changed_values, values)

Update model group average parameter(s).

abstract get_attributes() Tuple[FloatTensor, ...]

Returns the essential attributes of a given model.

Returns
Depends on the subclass, please refer to each specific class.
move_to_device(device: device)

Move the tensor attributes of this class to the specified device.

Parameters
devicetorch.device
abstract update(names_of_changed_values: Tuple[str, ...], values: Dict[str, FloatTensor]) None

Update model group average parameter(s).

Parameters
names_of_changed_valueslist [str]

Values to be updated

valuesdict [str, torch.Tensor]

New values used to update the model’s group average parameters

Raises
LeaspyModelInputError

If names_of_changed_values contains unknown values to update.