mm.math.parameters.Variable

class mrmustard.math.parameters.Variable(value, name, bounds=(None, None), update_fn=<function update_euclidean>)[source]

Bases: object

A parameter whose value can change.

my_var = Variable(1, "my_var")
Parameters:
  • value (any) – The value of this variable.

  • name (str) – The name of this variable.

  • bounds (Tuple[Optional[float], Optional[float]]) – The numerical bounds of this variable.

  • update_fn (Callable) – The function used to update this variable during training.

bounds

The numerical bounds of this variable.

name

The name of this constant.

update_fn

The function used to update this variable during training.

value

The value of this variable.

bounds

The numerical bounds of this variable.

name

The name of this constant.

update_fn

The function used to update this variable during training.

value

The value of this variable.

orthogonal(value, name[, bounds, N])

Initializes a variable with update_fn for orthogonal optimization.

symplectic(value, name[, bounds, N])

Initializes a variable with update_fn for simplectic optimization.

unitary(value, name[, bounds, N])

Initializes a variable with update_fn for unitary optimization.

static orthogonal(value, name, bounds=(None, None), N=1)[source]

Initializes a variable with update_fn for orthogonal optimization.

Parameters:
  • value (Optional[any]) – The value of the returned variable. If None, a random orthogonal matrix of dimension N is initialized.

  • name (str) – The name of the returned variable.

  • bounds (Tuple[Optional[float], Optional[float]]) – The numerical bounds of the returned variable.

  • N (int) – The dimension of the random orthogonal matrix. This value is ignored if value is not None.

Returns:

A variable with update_fn for orthogonal optimization.

static symplectic(value, name, bounds=(None, None), N=1)[source]

Initializes a variable with update_fn for simplectic optimization.

Parameters:
  • value (any) – The value of the returned variable. If None, a random symplectic matrix of dimension N is initialized.

  • name (str) – The name of the returned variable.

  • bounds (Tuple[Optional[float], Optional[float]]) – The numerical bounds of the returned variable.

  • N (int) – The dimension of the random symplectic matrix. This value is ignored if value is not None.

Returns:

A variable with update_fn for simplectic optimization.

static unitary(value, name, bounds=(None, None), N=1)[source]

Initializes a variable with update_fn for unitary optimization.

Parameters:
  • value (any) – The value of the returned variable. If None, a random unitary matrix of dimension N is initialized.

  • name (str) – The name of the returned variable.

  • bounds (Tuple[Optional[float], Optional[float]]) – The numerical bounds of the returned variable.

  • N (int) – The dimension of the random unitary matrix. This value is ignored if value is not None.

Returns:

A variable with update_fn for unitary optimization.