sf.apps.train.Exp

class Exp(dim)[source]

Bases: strawberryfields.apps.train.embed.ExpFeatures

Simple exponential embedding.

Weights of the \(W\) matrix in the \(WAW\) parametrization are expressed as an exponential of the trainable parameters: \(w_i = \exp(-\theta_i)\). The Jacobian, which encapsulates the derivatives of the weights with respect to the parameters can be computed straightforwardly as: \(\frac{d w_i}{d\theta_k} = -w_i\delta_{i,k}\).

Example usage:

>>> dim = 3
>>> embedding = Exp(dim)
>>> parameters = np.array([0.1, 0.2, 0.3])
>>> embedding(parameters)
[0.90483742 0.81873075 0.74081822]
Parameters

dim (int) – Dimension of the vector of parameters, which is equal to the number of modes in the GBS distribution

jacobian(params)

Computes the Jacobian matrix of weights with respect to input parameters \(J_{ ij} = \frac{\partial w_i}{\partial \theta_j}\).

weights(params)

Computes weights as a function of input parameters.

jacobian(params)

Computes the Jacobian matrix of weights with respect to input parameters \(J_{ ij} = \frac{\partial w_i}{\partial \theta_j}\).

Parameters

params (np.array) – trainable parameters

Returns

Jacobian matrix of weights with respect to parameters

Return type

np.array

weights(params)

Computes weights as a function of input parameters.

Parameters

params (np.array) – trainable parameters

Returns

weights

Return type

np.array