# Binary classification using a very simple Neural Net with Qiskit and Pennylane

I implemented a simple Neural Net with Pennylane and Qiskit for classifying two half moons: notebook for two half moons (GitHub). It works somehow (not overwhelmingly by any means):

I tried running the program on a public quantum device (IBM) and found very quickly that it would take months, not days, to complete the training. For this reason I built a much simpler net (my hope is that one qubit is enough), which is supposed to solve the classification task: notebook for linear classification (GitHub). It should divide the classes using a straight line:

While the full notebook (a very small one) can be found on the above linked GitHub page, the following snipped is relevant:

# Convert quantum layer to keras
n_layers = 4
weight_shapes = {"weights": (n_layers, n_qubits)}
qlayer = qml.qnn.KerasLayer(qnode, weight_shapes, output_dim=n_qubits)

# Define classical layers
clayer_1 = tf.keras.layers.Dense(1)
clayer_2 = tf.keras.layers.Dense(1, activation="sigmoid")

model = tf.keras.models.Sequential([clayer_1, qlayer, clayer_2])
model.compile(optimizer=opt, loss="binary_crossentropy", metrics=["accuracy"])
fitting = model.fit(x, y_hot, epochs=4, batch_size=5, validation_split=0.25, verbose=2)


Possibly it is a very simple error, which causes the net is recognizing all input as one and the same class:

I would be very grateful for any hint that pushes me towards the proper direction.