leaspy.models.utils.attributes¶
Submodules¶
- leaspy.models.utils.attributes.abstract_attributes
- leaspy.models.utils.attributes.abstract_manifold_model_attributes
- leaspy.models.utils.attributes.attributes_factory
- leaspy.models.utils.attributes.linear_attributes
- leaspy.models.utils.attributes.logistic_attributes
- leaspy.models.utils.attributes.logistic_parallel_attributes
Classes¶
Attributes of leaspy linear models. |
|
Attributes of leaspy logistic models. |
|
Attributes of leaspy logistic parallel models. |
|
Return an Attributes class object based on the given parameters. |
Package Contents¶
- class LinearAttributes(name, dimension, source_dimension)[source]¶
Bases:
leaspy.models.utils.attributes.abstract_manifold_model_attributes.AbstractManifoldModelAttributesAttributes of leaspy linear models.
Contains the common attributes & methods to update the linear model’s attributes.
- Parameters:
- namestr
- dimensionint
- source_dimensionint
- Attributes:
- namestr (default ‘linear’)
Name of the associated leaspy model.
- dimensionint
- source_dimensionint
- 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)
- update_possibilitiesset[str] (default {‘all’, ‘g’, ‘v0’, ‘betas’} )
Contains the available parameters to update. Different models have different parameters.
- positions
torch.Tensor[dimension] (default None) positions = realizations[‘g’] such that “p0” = positions
- velocities
torch.Tensor[dimension] (default None) Always positive: exp(realizations[‘v0’])
- orthonormal_basis
torch.Tensor[dimension, dimension - 1] (default None) - betas
torch.Tensor[dimension - 1, source_dimension] (default None) - mixing_matrix
torch.Tensor[dimension, source_dimension] (default None) Matrix A such that w_i = A * s_i.
See also
UnivariateModelMultivariateModel
- update(names_of_changed_values, values)[source]¶
Update model group average parameter(s).
- Parameters:
- names_of_changed_valuesset[str]
- Elements of set must be either:
all(update everything)gcorrespond to the attributepositions.v0(only for multivariate models) correspond to the attributevelocities. When we are sure that the v0 change is only a scalar multiplication (in particular, when we reparametrize log(v0) <- log(v0) + mean(xi)), we may update velocities usingv0_collinear, otherwise we always assume v0 is NOT collinear to previous value (no need to perform the verification it is - would not be really efficient)betascorrespond to the linear combination of columns from the orthonormal basis so to derive themixing_matrix.
- valuesdict [str, torch.Tensor]
New values used to update the model’s group average parameters
- Raises:
LeaspyModelInputErrorIf names_of_changed_values contains unknown parameters.
- class LogisticAttributes(name, dimension, source_dimension)[source]¶
Bases:
leaspy.models.utils.attributes.abstract_manifold_model_attributes.AbstractManifoldModelAttributesAttributes of leaspy logistic models.
Contains the common attributes & methods to update the logistic model’s attributes.
- Parameters:
- namestr
- dimensionint
- source_dimensionint
- Attributes:
- namestr (default ‘logistic’)
Name of the associated leaspy model.
- dimensionint
- source_dimensionint
- 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)
- update_possibilitiesset[str] (default {‘all’, ‘g’, ‘v0’, ‘betas’} )
Contains the available parameters to update. Different models have different parameters.
- positions
torch.Tensor[dimension] (default None) positions = exp(realizations[‘g’]) such that “p0” = 1 / (1 + positions)
- velocities
torch.Tensor[dimension] (default None) Always positive: exp(realizations[‘v0’])
- orthonormal_basis
torch.Tensor[dimension, dimension - 1] (default None) - betas
torch.Tensor[dimension - 1, source_dimension] (default None) - mixing_matrix
torch.Tensor[dimension, source_dimension] (default None) Matrix A such that w_i = A * s_i.
See also
UnivariateModelMultivariateModel
- update(names_of_changed_values, values)[source]¶
Update model group average parameter(s).
- Parameters:
- names_of_changed_valuesset[str]
- Elements of set must be either:
all(update everything)gcorrespond to the attributepositions.v0(only for multivariate models) correspond to the attributevelocities. When we are sure that the v0 change is only a scalar multiplication (in particular, when we reparametrize log(v0) <- log(v0) + mean(xi)), we may update velocities usingv0_collinear, otherwise we always assume v0 is NOT collinear to previous value (no need to perform the verification it is - would not be really efficient)betascorrespond to the linear combination of columns from the orthonormal basis so to derive themixing_matrix.
- valuesdict [str, torch.Tensor]
New values used to update the model’s group average parameters
- Raises:
LeaspyModelInputErrorIf names_of_changed_values contains unknown parameters.
- class LogisticParallelAttributes(name, dimension, source_dimension)[source]¶
Bases:
leaspy.models.utils.attributes.abstract_manifold_model_attributes.AbstractManifoldModelAttributesAttributes of leaspy logistic parallel models.
Contains the common attributes & methods of the logistic parallel models’ attributes.
- Parameters:
- namestr
- dimensionint
- source_dimensionint
- Attributes:
- namestr (default ‘logistic_parallel’)
Name of the associated leaspy model.
- dimensionint
- source_dimensionint
- has_sourcesbool
Whether model has sources or not (source_dimension >= 1)
- update_possibilitiesset[str] (default {‘all’, ‘g’, ‘deltas’, ‘betas’} )
Contains the available parameters to update. Different models have different parameters.
- positions
torch.Tensor(scalar) (default None) positions = exp(realizations[‘g’]) such that “p0” = 1 / (1 + positions * exp(-deltas))
- deltas
torch.Tensor[dimension] (default None) deltas = [0, delta_2_realization, …, delta_n_realization]
- orthonormal_basis
torch.Tensor[dimension, dimension - 1] (default None) - betas
torch.Tensor[dimension - 1, source_dimension] (default None) - mixing_matrix
torch.Tensor[dimension, source_dimension] (default None) Matrix A such that w_i = A * s_i.
- Raises:
LeaspyModelInputErrorif any inconsistent parameters for the model.
See also
MultivariateParallelModel
- deltas: torch.FloatTensor = None¶
- update_possibilities¶
- get_attributes()[source]¶
Returns the following attributes:
positions,deltas&mixing_matrix.- Returns:
- positions: torch.Tensor
- deltas: torch.Tensor
- mixing_matrix: torch.Tensor
- update(names_of_changed_values, values)[source]¶
Update model group average parameter(s).
- Parameters:
- names_of_changed_valuesset[str]
- Elements of set must be either:
all(update everything)gcorrespond to the attributepositions.deltascorrespond to the attributedeltas.betascorrespond to the linear combination of columns from the orthonormal basis so to derive themixing_matrix.
- valuesdict [str, torch.Tensor]
New values used to update the model’s group average parameters
- Raises:
LeaspyModelInputErrorIf names_of_changed_values contains unknown parameters.
- class AttributesFactory[source]¶
Return an Attributes class object based on the given parameters.
- classmethod attributes(name, dimension, source_dimension=None)[source]¶
Class method to build correct model attributes depending on model name.
- Parameters:
- namestr
- dimensionint
- source_dimensionint, optional (default None)
- Returns:
- Raises:
LeaspyModelInputErrorif any inconsistent parameter.
- Parameters:
- Return type: