Currently I'm trying to get together a QNN that can be trained to classify the normalized (-1, 1) IRIS Dataset on all 3 classes. For this I am using Qiskit's NeuralNetworkClassifier, and have a specific question regarding the circuit setup.

My current idea for the circuit is that the weights influence the features, which in turn rotate the qubit a certain direction. With the CircuitQNN class, I have to use a feature map as well as an ansatz. Now, this is per se OK, but it doesn't allow me to specifically multiply the weights with the features themselfs - I can only do so by applying the weights in the ansatz.

Is there a possibility for this or am I missing something? Code that currently works and is trainable (albeit results in an accuracy of ~0.5) would be as follows:

feature_map = QuantumCircuit(1)
ansatz = QuantumCircuit(1)
for i in range(len(normalized_features[1])):
    feature_map.ry(Parameter('i_' + str(i)),0)
    ansatz.ry(Parameter('w_' + str(i)),0)

qc = QuantumCircuit(1)
qc.append(feature_map, range(1))
qc.append(ansatz, range(1))

circuit_qnn = CircuitQNN(circuit=qc, 

Yes, I know this is only limited to one qubit, and I am currently only trying to figure out the different ways to construct the circuit. After figuring out the weight problem, I'd measure multiple vs single qubit circuits using it and compare the results.



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.