# Parameter Initializations¶

Module name: pennylane.init

This module contains methods to create arrays of parameters that can be used as initial parameters of trainable templates.

The methods return lists of numpy arrays, and the arrays have the correct shape to be fed in as the first positional arguments in the templates.

Note

For the use of PennyLane in combination with PyTorch or TensorFlow, the numpy arrays have to be converted to trainable tensors.

## Qubit architectures¶

### Strongly entangling circuit¶

 strong_ent_layers_uniform(n_layers, n_wires) Creates a list of a single parameter array for StronglyEntanglingLayers(), drawn from a uniform distribution. strong_ent_layers_normal(n_layers, n_wires) Creates a list of a single parameter array for StronglyEntanglingLayers(), drawn from a normal distribution. strong_ent_layer_uniform(n_wires[, low, …]) Creates a list of a single parameter array for StronglyEntanglingLayer(), drawn from a uniform distribution. strong_ent_layer_normal(n_wires[, mean, …]) Creates a list of a single parameter array for StronglyEntanglingLayer(), drawn from a normal distribution.

### Random circuit¶

 random_layers_uniform(n_layers, n_wires[, …]) Creates a list of a single parameter array for RandomLayers(), drawn from a uniform distribution. random_layers_normal(n_layers, n_wires[, …]) Creates a list of a single parameter array for RandomLayers(), drawn from a normal distribution. random_layer_uniform(n_wires[, n_rots, low, …]) Creates a list of a single parameter array for RandomLayer(), drawn from a uniform distribution. random_layer_normal(n_wires[, n_rots, mean, …]) Creates a list of a single parameter array for RandomLayer(), drawn from a normal distribution.

## Continuous-variable architectures¶

### Continuous-variable quantum neural network¶

 cvqnn_layers_uniform(n_layers, n_wires[, …]) Creates a list of eleven parameter arrays for CVNeuralNetLayers(), where non-active gate parameters are drawn from a uniform distribution and active parameters from a normal distribution. cvqnn_layers_normal(n_layers, n_wires[, …]) Creates a list of eleven parameter arrays for CVNeuralNetLayers(), where both active and non-active gate parameters are drawn from normal distributions. cvqnn_layer_uniform(n_wires[, low, high, …]) Creates a list of eleven parameter arrays for CVNeuralNetLayer(), where non-active gate parameters are drawn from a uniform distribution and active parameters from a normal distribution. cvqnn_layer_normal(n_wires[, mean, std, …]) Creates a list of eleven parameter arrays for CVNeuralNetLayer(), where both active and non-active gate parameters are drawn from normal distributions.

### Interferometer¶

 interferometer_uniform(n_wires[, low, high, …]) Returns a list of three parameter arrays of the form [theta, phi, varphi], where: interferometer_normal(n_wires[, mean, std, seed]) Returns a list of three parameter arrays of the form [theta, phi, varphi], where:

#### Code details¶

strong_ent_layers_uniform(n_layers, n_wires, low=0, high=6.283185307179586, seed=None)[source]

Creates a list of a single parameter array for StronglyEntanglingLayers(), drawn from a uniform distribution.

The shape of the parameter array is (n_layers, n_wires, 3) and each parameter is drawn uniformly at random from between low and high. The parameters define the three rotation angles applied in each layer.

Parameters: Keyword Arguments: n_layers (int) – number of layers n_wires (int) – number of qubits low (float) – minimum value of non-angle gate parameters high (float) – maximum value of non-angle gate parameters seed (int) – seed used in sampling the parameters, makes function call deterministic list of parameter array
strong_ent_layers_normal(n_layers, n_wires, mean=0, std=0.1, seed=None)[source]

Creates a list of a single parameter array for StronglyEntanglingLayers(), drawn from a normal distribution.

The shape of the parameter array is (n_layers, n_wires, 3) and each parameter is drawn from a normal distribution with mean mean and standard deviation std. The parameters define the three rotation angles applied in each layer.

Parameters: Keyword Arguments: n_layers (int) – number of layers n_wires (int) – number of qubits mean (float) – mean of parameters std (float) – standard deviation of parameters seed (int) – seed used in sampling the parameters, makes function call deterministic list of parameter array
strong_ent_layer_uniform(n_wires, low=0, high=6.283185307179586, seed=None)[source]

Creates a list of a single parameter array for StronglyEntanglingLayer(), drawn from a uniform distribution.

The shape of the parameter array is (n_wires, 3) and each parameter is drawn uniformly at random from between low and high. The parameters define the three rotation angles applied to each layer.

Parameters: Keyword Arguments: n_wires (int) – number of qubits low (float) – minimum value of non-angle gate parameters high (float) – maximum value of non-angle gate parameters seed (int) – seed used in sampling the parameters, makes function call deterministic list of parameter array
strong_ent_layer_normal(n_wires, mean=0, std=0.1, seed=None)[source]

Creates a list of a single parameter array for StronglyEntanglingLayer(), drawn from a normal distribution.

The shape of the parameter array is (n_wires, 3) and each parameter is drawn from a normal distribution with mean mean and standard deviation std. The parameters define the three rotation angles applied to each layer.

Parameters: Keyword Arguments: n_wires (int) – number of qubits mean (float) – mean of parameters std (float) – standard deviation of parameters seed (int) – seed used in sampling the parameters, makes function call deterministic list of parameter array
random_layers_uniform(n_layers, n_wires, n_rots=None, low=0, high=6.283185307179586, seed=None)[source]

Creates a list of a single parameter array for RandomLayers(), drawn from a uniform distribution.

The shape of the parameter array is (n_layers, n_rots) and each parameter is drawn uniformly at random from between low and high. The parameters define the rotation angles of the randomly positioned rotations applied in each layer.

Parameters: Keyword Arguments: n_layers (int) – number of layers n_wires (int) – number of qubits n_rots (int) – number of rotations, if None, n_rots=n_wires low (float) – minimum value of non-angle gate parameters high (float) – maximum value of non-angle gate parameters seed (int) – seed used in sampling the parameters, makes function call deterministic list of parameter array
random_layers_normal(n_layers, n_wires, n_rots=None, mean=0, std=0.1, seed=None)[source]

Creates a list of a single parameter array for RandomLayers(), drawn from a normal distribution.

The shape of the parameter array is (n_layers, n_rots) and each parameter is drawn from a normal distribution with mean mean and standard deviation std. The parameters define the rotation angles of the randomly positioned rotations applied in each layer.

Parameters: Keyword Arguments: n_layers (int) – number of layers n_wires (int) – number of qubits n_rots (int) – number of rotations, if None, n_rots=n_wires mean (float) – mean of parameters std (float) – standard deviation of parameters seed (int) – seed used in sampling the parameters, makes function call deterministic list of parameter array
random_layer_uniform(n_wires, n_rots=None, low=0, high=6.283185307179586, seed=None)[source]

Creates a list of a single parameter array for RandomLayer(), drawn from a uniform distribution.

The number of parameter array is (n_rots,) and each parameter is drawn uniformly at random from between low and high. The parameters define the rotation angles of the randomly positioned rotations applied in each layer.

Parameters: Keyword Arguments: n_wires (int) – number of qubits n_rots (int) – number of rotations, if None, n_rots=n_wires low (float) – minimum value of rotation angles high (float) – maximum value of rotation angles seed (int) – seed used in sampling the parameters, makes function call deterministic list of parameter array
random_layer_normal(n_wires, n_rots=None, mean=0, std=0.1, seed=None)[source]

Creates a list of a single parameter array for RandomLayer(), drawn from a normal distribution.

The number of parameter array is (n_rots,) and each parameter is drawn from a normal distribution with mean mean and standard deviation std. The parameters define the rotation angles of the randomly positioned rotations applied in each layer.

Parameters: Keyword Arguments: n_wires (int) – number of qubits n_rots (int) – number of rotations, if None, n_rots=n_wires mean (float) – mean of parameters std (float) – standard deviation of parameters seed (int) – seed used in sampling the parameters, makes function call deterministic list of parameter array
cvqnn_layers_uniform(n_layers, n_wires, low=0, high=6.283185307179586, mean_active=0, std_active=0.1, seed=None)[source]

Creates a list of eleven parameter arrays for CVNeuralNetLayers(), where non-active gate parameters are drawn from a uniform distribution and active parameters from a normal distribution.

The shape of the arrays is (n_layers, n_wires*(n_wires-1)/2) for the parameters used in an interferometer, and (n_layers, n_wires) else.

All gate parameters are drawn uniformly from the interval [low, high], except from the three types of ‘active gate parameters’: the displacement amplitude, squeezing amplitude and kerr parameter. These active gate parameters are sampled from a normal distribution with mean mean_active and standard deviation std_active. Since they influence the mean photon number (or energy) of the quantum system, one typically wants to initialize them with values close to zero.

Parameters: Keyword Arguments: n_layers (int) – number of layers of the CV Neural Net n_wires (int) – number of modes of the CV Neural Net low (float) – minimum value of uniformly drawn rotation angles high (float) – maximum value of uniformly drawn rotation angles mean_active (float) – mean of active gate parameters std_active (float) – standard deviation of active gate parameters seed (int) – seed used in sampling the parameters, makes function call deterministic list of parameter arrays
cvqnn_layers_normal(n_layers, n_wires, mean=0, std=1, mean_active=0, std_active=0.1, seed=None)[source]

Creates a list of eleven parameter arrays for CVNeuralNetLayers(), where both active and non-active gate parameters are drawn from normal distributions.

The shape of the arrays is (n_layers, n_wires*(n_wires-1)/2) for the parameters used in an interferometer, and (n_layers, n_wires) else.

All gate parameters are drawn from a normal distribution with mean mean and standard deviation std, except from the three types of ‘active gate parameters’: the displacement amplitude, squeezing amplitude and kerr parameter. These active gate parameters are sampled from a normal distribution with mean mean_active and standard deviation std_active. Since they influence the mean photon number (or energy) of the quantum system, one typically wants to initialize them with values close to zero.

Parameters: Keyword Arguments: n_layers (int) – number of layers of the CV Neural Net n_wires (int) – number of modes of the CV Neural Net mean (float) – mean of non-active parameters std (float) – standard deviation of non-active parameters mean_active (float) – mean of active gate parameters std_active (float) – standard deviation of active gate parameters seed (int) – seed used in sampling the parameters, makes function call deterministic list of parameter arrays
cvqnn_layer_uniform(n_wires, low=0, high=6.283185307179586, mean_active=0, std_active=0.1, seed=None)[source]

Creates a list of eleven parameter arrays for CVNeuralNetLayer(), where non-active gate parameters are drawn from a uniform distribution and active parameters from a normal distribution.

The shape of the arrays is (n_wires*(n_wires-1)/2) for the parameters used in an interferometer, and (n_wires) else.

All gate parameters are drawn uniformly from the interval [low, high], except from the three types of ‘active gate parameters’: the displacement amplitude, squeezing amplitude and kerr parameter. These active gate parameters are sampled from a normal distribution with mean mean_active and standard deviation std_active. Since they influence the mean photon number (or energy) of the quantum system, one typically wants to initialize them with values close to zero.

Parameters: Keyword Arguments: n_wires (int) – number of modes of the CV Neural Net low (float) – minimum value of uniformly drawn non-active gate parameters high (float) – maximum value of uniformly drawn non-active gate parameters mean_active (float) – mean of active gate parameters std_active (float) – standard deviation of active gate parameters seed (int) – seed used in sampling the parameters, makes function call deterministic list of parameter arrays
cvqnn_layer_normal(n_wires, mean=0, std=1, mean_active=0, std_active=0.1, seed=None)[source]

Creates a list of eleven parameter arrays for CVNeuralNetLayer(), where both active and non-active gate parameters are drawn from normal distributions.

The shape of the arrays is (n_wires*(n_wires-1)/2) for the parameters used in an interferometer, and (n_wires) else.

All gate parameters are drawn from a normal distribution with mean mean and standard deviation std, except from the three types of ‘active gate parameters’: the displacement amplitude, squeezing amplitude and kerr parameter. These active gate parameters are sampled from a normal distribution with mean mean_active and standard deviation std_active. Since they influence the mean photon number (or energy) of the quantum system, one typically wants to initialize them with values close to zero.

Parameters: Keyword Arguments: n_wires (int) – number of modes of the CV Neural Net mean (float) – mean of non-active parameters std (float) – standard deviation of non-active parameters mean_active (float) – mean of active gate parameters std_active (float) – standard deviation of active gate parameters seed (int) – seed used in sampling the parameters, makes function call deterministic list of parameter arrays
interferometer_uniform(n_wires, low=0, high=6.283185307179586, seed=None)[source]

Returns a list of three parameter arrays of the form [theta, phi, varphi], where:

• theta is the array of beamsplitter transmittivity angles, of size (n_wires*(n_wires-1)/2, )
• phi is the array of beamsplitter phases, of size (n_wires*(n_wires-1)/2, )
• varphi is the array of local angles for the final rotation gates, of size (n_wires, )

All parameters are initialized uniformly from the interval [low, high].

Parameters: Keyword Arguments: n_wires (int) – number of modes that the interferometer acts on low (float) – minimum value of uniformly drawn rotation angles high (float) – maximum value of uniformly drawn rotation angles seed (int) – seed used in sampling the parameters, makes function call deterministic list of parameter arrays
interferometer_normal(n_wires, mean=0, std=0.1, seed=None)[source]

Returns a list of three parameter arrays of the form [theta, phi, varphi], where:

• theta is the array of beamsplitter transmittivity angles, of size (n_wires*(n_wires-1)/2, )
• phi is the array of beamsplitter phases, of size (n_wires*(n_wires-1)/2, )
• varphi is the array of local angles for the final rotation gates, of size (n_wires, )

All parameters are drawn from a normal distribution with mean mean and standard deviation std.

Parameters: Keyword Arguments: n_wires (int) – number of modes that the interferometer acts on mean (float) – mean of parameters std (float) – standard deviation of parameters seed (int) – seed used in sampling the parameters, makes function call deterministic list of parameter arrays