leaspy.models.utils.attributes.abstract_attributes
.AbstractAttributes
- class AbstractAttributes(name: str, dimension: int, source_dimension: int)
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_possibilitiesset[str] (default empty)
Contains the available parameters to update. Different models have different parameters.
Methods
Returns the attributes of the model, which is a tuple of three torch tensors.
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, FloatTensor, FloatTensor]
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
- 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: Set[str], values: Dict[str, Tensor]) None
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.