11.2 Hybrid architectures in PennyLane
In this section, we are going to use PennyLane to implement and train a couple of hybrid QNNs in order to solve some classification problems. Firstly, we will tackle a binary classification problem, just to better understand how hybrid QNNs work in a familiar setting. Then, we will take one step further and do the same for a multi-class classification problem.
Before we get to the problems, though, let us set things up.
11.2.1 Setting things up
As on previous occasions, we shall begin by importing NumPy and TensorFlow and setting a seed for both packages — all to ensure the reproducibility of our results:
import numpy as np import tensorflow as tf seed = 1234 np.random.seed(seed) tf.random.set_seed(seed)
Now we can also import some useful functions from scikit-learn. We’ve already used them extensively — they need no introduction!
from sklearn.metrics import accuracy_score from sklearn.model_selection...