R1[source]

R1(angle, matrix)

Rotation Gate around axis defined by matrix $M$ and angle $\Theta$

Parameters:

angle (float): rotation angle

matrix (array): rotation axis defined by 2x2 matrix

R3[source]

R3(angles)

R3 rotation $R_3(\Phi, \Theta, \Omega) = R_Z(\Omega) R_Y(\Theta) R_Z(\Phi)$

Parameters:

angles: list / array of length 3

phi = angles[0], theta = angles[1], omega = angles[2]

CZ[source]

CZ(width, c=None, t=None)

Controlled Z gate between two qubits

Parameters:

width (int): number of qubits of circuit

c (int): control qubit

t (int): target qubit

Measurements[source]

Measurements(width, device='cpu')

Projective measurements as they are used in the reuploading paper

Measurement_Z[source]

Measurement_Z(width, device='cpu')

Z measurement of the 0-th qubit

flatten_grad[source]

flatten_grad(grad)

Flattens the gradient tensor to a rank 1 tensor

find_hessian[source]

find_hessian(loss, params, x=None)

calculate the Hessian of a given loss with respect to given parameters.

Parameters:

loss: some pytorch loss

params: circuit parameters

find_heigenvalues[source]

find_heigenvalues(loss, params)

Find the eigenvalues of the Hessian of a given loss and given parameters.

loss_function[source]

loss_function(circ, params, x, init, target)

Custom loss function for VQC

batch_loss_function_sigmoid[source]

batch_loss_function_sigmoid(circ, params, x_train, y_train, init, measurements=None)

Loss for batch with sigmoid activation

batch_loss_function[source]

batch_loss_function(circ, params, x_train, y_train, init, measurements=None)

Loss for batch without sigmoid activation

class Toy_Model[source]

Toy_Model(params, width=2, layers=2, device='cpu')

Toy model for state rotation

class General_Model[source]

General_Model(params, width=2, layers=2, device='cpu')

General Model for state rotation

class Model_Z_measure[source]

Model_Z_measure(params, width=2, layers=2, device='cpu')

Data Reuploading circuit