R1
R1(angle, matrix)
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
R3(angles)
angles
R3 rotation $R_3(\Phi, \Theta, \Omega) = R_Z(\Omega) R_Y(\Theta) R_Z(\Phi)$
angles: list / array of length 3 phi = angles[0], theta = angles[1], omega = angles[2]
CZ
CZ(width, c=None, t=None)
width
c
None
t
Controlled Z gate between two qubits
width (int): number of qubits of circuit c (int): control qubit t (int): target qubit
Measurements
Measurements(width, device='cpu')
device
'cpu'
Projective measurements as they are used in the reuploading paper
Measurement_Z
Measurement_Z(width, device='cpu')
Z measurement of the 0-th qubit
flatten_grad
flatten_grad(grad)
grad
Flattens the gradient tensor to a rank 1 tensor
find_hessian
find_hessian(loss, params, x=None)
loss
params
x
calculate the Hessian of a given loss with respect to given parameters.
loss: some pytorch loss params: circuit parameters
find_heigenvalues
find_heigenvalues(loss, params)
Find the eigenvalues of the Hessian of a given loss and given parameters.
loss_function
loss_function(circ, params, x, init, target)
circ
init
target
Custom loss function for VQC
batch_loss_function_sigmoid
batch_loss_function_sigmoid(circ, params, x_train, y_train, init, measurements=None)
x_train
y_train
measurements
Loss for batch with sigmoid activation
batch_loss_function
batch_loss_function(circ, params, x_train, y_train, init, measurements=None)
Loss for batch without sigmoid activation
class
Toy_Model
Toy_Model(params, width=2, layers=2, device='cpu')
2
layers
Toy model for state rotation
General_Model
General_Model(params, width=2, layers=2, device='cpu')
General Model for state rotation
Model_Z_measure
Model_Z_measure(params, width=2, layers=2, device='cpu')
Data Reuploading circuit