leaspy.models.utils.attributes ============================== .. py:module:: leaspy.models.utils.attributes Submodules ---------- .. toctree:: :maxdepth: 1 /reference/api/leaspy/models/utils/attributes/abstract_attributes/index /reference/api/leaspy/models/utils/attributes/abstract_manifold_model_attributes/index /reference/api/leaspy/models/utils/attributes/attributes_factory/index /reference/api/leaspy/models/utils/attributes/linear_attributes/index /reference/api/leaspy/models/utils/attributes/logistic_attributes/index /reference/api/leaspy/models/utils/attributes/logistic_parallel_attributes/index Classes ------- .. autoapisummary:: leaspy.models.utils.attributes.LinearAttributes leaspy.models.utils.attributes.LogisticAttributes leaspy.models.utils.attributes.LogisticParallelAttributes leaspy.models.utils.attributes.AttributesFactory Package Contents ---------------- .. py:class:: LinearAttributes(name, dimension, source_dimension) Bases: :py:obj:`leaspy.models.utils.attributes.abstract_manifold_model_attributes.AbstractManifoldModelAttributes` Attributes of leaspy linear models. Contains the common attributes & methods to update the linear model's attributes. :Parameters: **name** : str .. **dimension** : int .. **source_dimension** : int .. :Attributes: **name** : str (default 'linear') Name of the associated leaspy model. **dimension** : int .. **source_dimension** : int .. **univariate** : bool Whether model is univariate or not (i.e. dimension == 1) **has_sources** : bool Whether model has sources or not (not univariate and source_dimension >= 1) **update_possibilities** : set[str] (default {'all', 'g', 'v0', 'betas'} ) Contains the available parameters to update. Different models have different parameters. **positions** : :class:`torch.Tensor` [dimension] (default None) positions = realizations['g'] such that "p0" = positions **velocities** : :class:`torch.Tensor` [dimension] (default None) Always positive: exp(realizations['v0']) **orthonormal_basis** : :class:`torch.Tensor` [dimension, dimension - 1] (default None) .. **betas** : :class:`torch.Tensor` [dimension - 1, source_dimension] (default None) .. **mixing_matrix** : :class:`torch.Tensor` [dimension, source_dimension] (default None) Matrix A such that w_i = A * s_i. .. seealso:: :class:`~leaspy.models.univariate_model.UnivariateModel` .. :class:`~leaspy.models.multivariate_model.MultivariateModel` .. .. !! processed by numpydoc !! .. py:method:: update(names_of_changed_values, values) Update model group average parameter(s). :Parameters: **names_of_changed_values** : set[str] Elements of set must be either: * ``all`` (update everything) * ``g`` correspond to the attribute :attr:`positions`. * ``v0`` (only for multivariate models) correspond to the attribute :attr:`velocities`. 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 using ``v0_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) * ``betas`` correspond to the linear combination of columns from the orthonormal basis so to derive the :attr:`mixing_matrix`. **values** : dict [str, `torch.Tensor`] New values used to update the model's group average parameters :Raises: :exc:`.LeaspyModelInputError` If `names_of_changed_values` contains unknown parameters. .. !! processed by numpydoc !! .. py:class:: LogisticAttributes(name, dimension, source_dimension) Bases: :py:obj:`leaspy.models.utils.attributes.abstract_manifold_model_attributes.AbstractManifoldModelAttributes` Attributes of leaspy logistic models. Contains the common attributes & methods to update the logistic model's attributes. :Parameters: **name** : str .. **dimension** : int .. **source_dimension** : int .. :Attributes: **name** : str (default 'logistic') Name of the associated leaspy model. **dimension** : int .. **source_dimension** : int .. **univariate** : bool Whether model is univariate or not (i.e. dimension == 1) **has_sources** : bool Whether model has sources or not (not univariate and source_dimension >= 1) **update_possibilities** : set[str] (default {'all', 'g', 'v0', 'betas'} ) Contains the available parameters to update. Different models have different parameters. **positions** : :class:`torch.Tensor` [dimension] (default None) positions = exp(realizations['g']) such that "p0" = 1 / (1 + positions) **velocities** : :class:`torch.Tensor` [dimension] (default None) Always positive: exp(realizations['v0']) **orthonormal_basis** : :class:`torch.Tensor` [dimension, dimension - 1] (default None) .. **betas** : :class:`torch.Tensor` [dimension - 1, source_dimension] (default None) .. **mixing_matrix** : :class:`torch.Tensor` [dimension, source_dimension] (default None) Matrix A such that w_i = A * s_i. .. seealso:: :class:`~leaspy.models.univariate_model.UnivariateModel` .. :class:`~leaspy.models.multivariate_model.MultivariateModel` .. .. !! processed by numpydoc !! .. py:method:: update(names_of_changed_values, values) Update model group average parameter(s). :Parameters: **names_of_changed_values** : set[str] Elements of set must be either: * ``all`` (update everything) * ``g`` correspond to the attribute :attr:`positions`. * ``v0`` (only for multivariate models) correspond to the attribute :attr:`velocities`. 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 using ``v0_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) * ``betas`` correspond to the linear combination of columns from the orthonormal basis so to derive the :attr:`mixing_matrix`. **values** : dict [str, `torch.Tensor`] New values used to update the model's group average parameters :Raises: :exc:`.LeaspyModelInputError` If `names_of_changed_values` contains unknown parameters. .. !! processed by numpydoc !! .. py:class:: LogisticParallelAttributes(name, dimension, source_dimension) Bases: :py:obj:`leaspy.models.utils.attributes.abstract_manifold_model_attributes.AbstractManifoldModelAttributes` Attributes of leaspy logistic parallel models. Contains the common attributes & methods of the logistic parallel models' attributes. :Parameters: **name** : str .. **dimension** : int .. **source_dimension** : int .. :Attributes: **name** : str (default 'logistic_parallel') Name of the associated leaspy model. **dimension** : int .. **source_dimension** : int .. **has_sources** : bool Whether model has sources or not (source_dimension >= 1) **update_possibilities** : set[str] (default {'all', 'g', 'deltas', 'betas'} ) Contains the available parameters to update. Different models have different parameters. **positions** : :class:`torch.Tensor` (scalar) (default None) positions = exp(realizations['g']) such that "p0" = 1 / (1 + positions * exp(-deltas)) **deltas** : :class:`torch.Tensor` [dimension] (default None) deltas = [0, delta_2_realization, ..., delta_n_realization] **orthonormal_basis** : :class:`torch.Tensor` [dimension, dimension - 1] (default None) .. **betas** : :class:`torch.Tensor` [dimension - 1, source_dimension] (default None) .. **mixing_matrix** : :class:`torch.Tensor` [dimension, source_dimension] (default None) Matrix A such that w_i = A * s_i. :Raises: :exc:`.LeaspyModelInputError` if any inconsistent parameters for the model. .. seealso:: :class:`~leaspy.models.multivariate_parallel_model.MultivariateParallelModel` .. .. !! processed by numpydoc !! .. py:attribute:: deltas :type: torch.FloatTensor :value: None .. py:attribute:: update_possibilities .. py:method:: get_attributes() Returns the following attributes: ``positions``, ``deltas`` & ``mixing_matrix``. :Returns: positions: `torch.Tensor` .. deltas: `torch.Tensor` .. mixing_matrix: `torch.Tensor` .. .. !! processed by numpydoc !! .. py:method:: update(names_of_changed_values, values) Update model group average parameter(s). :Parameters: **names_of_changed_values** : set[str] Elements of set must be either: * ``all`` (update everything) * ``g`` correspond to the attribute :attr:`positions`. * ``deltas`` correspond to the attribute :attr:`deltas`. * ``betas`` correspond to the linear combination of columns from the orthonormal basis so to derive the :attr:`mixing_matrix`. **values** : dict [str, `torch.Tensor`] New values used to update the model's group average parameters :Raises: :exc:`.LeaspyModelInputError` If `names_of_changed_values` contains unknown parameters. .. !! processed by numpydoc !! .. py:class:: AttributesFactory Return an `Attributes` class object based on the given parameters. .. !! processed by numpydoc !! .. py:method:: attributes(name, dimension, source_dimension = None) :classmethod: Class method to build correct model attributes depending on model `name`. :Parameters: **name** : str .. **dimension** : int .. **source_dimension** : int, optional (default None) .. :Returns: :class:`.AbstractAttributes` .. :Raises: :exc:`.LeaspyModelInputError` if any inconsistent parameter. .. !! processed by numpydoc !!