Last active
February 15, 2020 13:40
-
-
Save kareem1925/3908906a364b45273a621fcab40c51c8 to your computer and use it in GitHub Desktop.
simple implementation of circuit-centeric quantum classifier using qiskit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister | |
from qiskit import * | |
import numpy as np | |
qc = QuantumCircuit(3,1) | |
weights = np.random.rand(18) | |
# First layer | |
qc.u3(weights[0],weights[1],weights[2],0) | |
qc.u3(weights[3],weights[4],weights[5],1) | |
qc.u3(weights[6],weights[7],weights[8],2) | |
qc.cnot(0,1) | |
qc.cnot(1,2) | |
qc.cnot(2,0) | |
# Second Layer | |
qc.u3(weights[9],weights[10],weights[11],0) | |
qc.u3(weights[15],weights[16],weights[17],1) | |
qc.u3(weights[12],weights[13],weights[14],2) | |
qc.cnot(0,1) | |
qc.cnot(1,2) | |
qc.cnot(2,0) | |
# Z measurement | |
qc.measure(0,0) | |
# Drawing | |
qc.draw(output='mpl') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment