eleanor.jax.variability#

class eleanor.jax.variability.C2CVar(name, variability)[source]#

Bases: Module

Cycle to cycle variability for eleanor models Apply a percentage of variability to a parameter of the models on evey call

Parameters:
name#

Name of the variability parameter.

Type:

str

variability#

Percentage of variability.

Type:

float

Example

>>> param_var = C2CVar("param", 0.1)
>>> param_with_variability = param_var(param, key=key)
__call__(mu, shape, *, key)[source]#

Apply C2C variability into the input parameter.

Parameters:
  • mu (Array) – Mean value of the parameter to apply the variability.

  • shape (Sequence[int]) – Output shape of the array.

  • key (PRNGKey) – Key to generate random variability

Return type:

Array with coefficient of variation \(\text{variability} = \sigma/\mu\)

class eleanor.jax.variability.D2DVar(name, variability, shape, key)[source]#

Bases: Module

Device to device variability for eleanor models Apply a percentage of variability to a parameter of the models

Parameters:
name#

Name of the variability parameter.

Type:

str

variability#

Percentage of variability.

Type:

float

key#

Random key to generate the variability.

Type:

PRNGKeyArray

Example

>>> param_var = D2DVar("param", 0.1, key)
>>> param_with_variability = param_var(param)
__call__(mu, *, key=None)[source]#

Apply D2D variability into the input parameter. key parameter mantained for compatibility.

Parameters:
  • mu (Array) – Mean value of the parameter to apply the variability.

  • key (Key[Array, ''] | UInt32[Array, '2'] | UInt32[Array, '4'] | None)

Return type:

Array with coefficient of variation \(\text{variability} = \sigma/\mu\)

class eleanor.jax.variability.StaticWrapper(content)[source]#

Bases: Generic[T]

Wrapper for JAX traceable pytrees that are expected to be fixed.

Parameters:

content (T)

content#

PyTree to be fixed.

Type:

T

__call__(*args, **kwargs)[source]#

Call self as a function.

eleanor.jax.variability.find_all_D2D_wrappers(model)[source]#

Find all the StaticWrappers with Device to Device variability.

Parameters:

model (PyTree) – PyTree of the model with the D2D variability.

Return type:

List of all the StaticWrappers with D2D objects.

eleanor.jax.variability.find_all_D2D_wrappers_name(model, name)[source]#

Find all the StaticWrappers with Device to Device variability based on the name name

Parameters:
  • model (PyTree) – PyTree of the model with the D2D variability.

  • name (str) – Name of the D2D parameter.

Return type:

List of all the StaticWrappers with D2D objects with a given name.

eleanor.jax.variability.set_d2d_variability(model, variability)[source]#

Set a new variability value to all the D2D objects of a model

Parameters:
  • model (PyTree) – Model that contains the D2D objects.

  • variability (float | Sequence[float]) – New variability value/s.

Return type:

PyTree

eleanor.jax.variability.set_d2d_variability_name(model, name, variability)[source]#

Set a new variability value to all the D2D objects of a model with a given name

Parameters:
  • model (PyTree) – Model that contains the D2D objects.

  • name (str) – Name of the D2D parameter.

  • variability (float | Sequence[float]) – New variability value/s.

Return type:

PyTree

eleanor.jax.variability.update_d2d_variability(model, key)[source]#

Update the device to device variability of all the D2DVar parameters with a new key.

Parameters:
  • model (PyTree) – PyTree of the model with the parameters that want to update the D2D random key.

  • key (PRNGKeyArray) – New random key for the D2D variables.

Return type:

Model with the update parameters.

eleanor.jax.variability.update_d2d_variability_name(model, name, key)[source]#

Update the device to device variability of all the D2DVar parameters with the same name with a new key.

Parameters:
  • model (Array) – PyTree of the model with the parameters that want to update the D2D random key.

  • name (str) – Name of the parameter to update.

  • key (PRNGKeyArray) – New random key for the D2D variables.

Return type:

Model with the update parameters.