leaspy.models.utils.attributes.abstract_attributes

Classes

AbstractAttributes

Abstract base class for attributes of models.

Module Contents

class AbstractAttributes(name, dimension, source_dimension)[source]

Bases: abc.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)
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_possibilitiesset[str] (default empty)

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

Raises:
LeaspyModelInputError

if any inconsistent parameter.

Parameters:
  • name (str)

  • dimension (int)

  • source_dimension (int)

name
dimension
univariate
source_dimension
has_sources
update_possibilities: set[ParamType]
abstractmethod get_attributes()[source]

Returns the attributes of the model, which is a tuple of three torch tensors.

For the precise definitions of those attributes please refer to the exact attributes class associated to your model.

Returns:
positions: torch.Tensor
velocities: torch.Tensor
mixing_matrix: torch.Tensor
Return type:

tuple[torch.FloatTensor, torch.FloatTensor, torch.FloatTensor]

abstractmethod update(names_of_changed_values, values)[source]

Update model group average parameter(s).

Parameters:
names_of_changed_valuesset[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.

Parameters:
Return type:

None

move_to_device(device)[source]

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

Parameters:
devicetorch.device
Parameters:

device (device)