Quantum Gate uses in Deep Learning

31 Views Asked by At

I am working on a hybrid classical-quantum model in deep learning. I do not understand the use of hadamard gate and CNOT gate in the quantum training layer. The code uses Hadamard Layer, CNOT layer and Rotational encoding.

Here is the code

def H_layer(nqubits):
    """Layer of single-qubit Hadamard gates.
    """
    for idx in range(nqubits):
        qml.Hadamard(wires=idx)

def RY_layer(w):
    """Layer of parametrized qubit rotations around the y axis.
    """
    for idx, element in enumerate(w):
        qml.RY(element, wires=idx)

def entangling_layer(nqubits):
    """Layer of CNOTs followed by another shifted layer of CNOT.
    """
    # In other words it should apply something like :
    #CNOT  CNOT  CNOT  CNOT...  CNOT
    #   CNOT  CNOT  CNOT...  CNOT
    for i in range(0, nqubits - 1, 2): #loop over even indices: i=0,2,...N-2
        qml.CNOT(wires=[i, i + 1])
    for i in range(1, nqubits - 1, 2): #loop over odd indices:  i=1,3,...N-3
        qml.CNOT(wires=[i, i + 1])  

Why is the code using hadamrad gate and CNOT gate?

1

There are 1 best solutions below

0
On

It seems like the model is setting two different sets of entangled qubits into a Bell state by applying the H gate and then all the CNOTs.

The logic behind separating the two sets of entangled qubits by even and odd is not clear to me given the code you shared