Final Report Womanium Quantum+AI 2024 Bootcamp Project
Final Report Womanium Quantum+AI 2024 Bootcamp Project
Final Report Womanium Quantum+AI 2024 Bootcamp Project
Name Country
Martyna Anna Czuba Poland
Hussein Shiri Lebanon
QML Womanium Quantum+AI Project Submission
The project focuses on conspicuity detection in production, which makes it possible to identify improvement
measures for individual work steps or sub-processes at an early stage and thus optimize the production
process. To do this, we analyze process data such as image data or time series to uncover deviations and weak
points in production. Classical methods for analyzing such data are very time-consuming.
2.3 Summary
Summarizing both sections, in this task we deepened our under-
standing of variational quantum circuits. We trained both cir-
cuits for different problems, generated plots, and calculated met-
rics. We also ensured that our code is clean and well-managed,
making it easy to use and open to changes in the future.
Additionally, based on the article Circuit-centric quantum
classifiers [4], we implemented a circuit called circuit-centric
quantum classifiers. However, we did not have time to conduct
experiments with this code. We plan to extend this task in the
future.
3 Task Three
This comparison shows a 5-10% increase in the validation
3.1 Classic convolution accuracy using a 4x4 kernel compared to a 2x2. This encourages
trying different kernel sizes to find the one that gives the highest
Convolution layers are part of a neural network that accuracy after classification.
works on images to perform certain task like classifica-
tion, encoding, ... These layers use a kernel to per-
form feature extraction and reduce the image dimensions. Our solution uses the following dataset and parameters:
4
• Dataset:
Training: 100 images
Testing: 20 images
MNIST Dataset
• Other parameters:
Epochs: 100
Classes: 10
Batch size: 4
4 Task Four
The task was to develop a model to learn the sine function on Fig 10: Cost Function Convergence During Training.
the interval [0, 2π]. We discretized the interval with a suitable
number of points and used the sine values at these points as la-
bels. The goal was to implement a Quantum Machine Learning
model that reproduces the sine function values. Our solutions are Fig 10 shows the convergence of the MSE cost function during
based on several key articles,including Schuld, Maria et.al ”The 30 epochs of training. The maximum cost value is 1.0195960 at
effect of data encoding on the expressive power of variational epoch 0, and the minimum cost value achieved is 0.00000650 at
quantum machine learning models” [6] and Patrick Holzer,Ivica epoch 30, indicating successful fitting of the sine function to the
Turkalj ”Spectral Invariance and Maximality Properties of the training data.
Frequency Spectrum of Quantum Neural Networks” [2].These
articles have been invaluable, providing us with a wealth of in-
formation and serving as significant resources for our research
and development..
We identified three sections in this task:
• Quantum Model 1
• Quantum Model 2
• Classical Model
Fig 12: Analysis of Training and Test Costs vs. Number of Fig 14:The general the Quantum Model. Source: [6].
Data Points
We used a (univariate) quantum model fθ (x) and follow the
The parameters tend to converge to similar values as the assumption that overall quantum circuit has the form:
number of data points increases, indicating stable model train- U (x) = W (L+1) S(x)W (L) ...W (2) S(x)W (1)
ing. As for the cost function behavior, an increase in the number
of data points results in a slight increase in the cost function, sug- We can see that our model is splitted into ‘data encoding
gesting a trade-off between model complexity and the volume of (circuit) block1‘ S(x) and ‘trainable (circuit) block‘ W . We
training data. It is experimentally observed that with the given use popular strategy of encoding an input single-qubit rotations.
training parameters, the model requires only 4 data points to Our variational circuit is of the form
effectively learn the sine function For cases with 3, 2, and 1 data fθ (x) = ⟨0|U † (x, θ)M U (x, θ)|0⟩
points, despite achieving a final cost of zero during training, the
,where |0⟩ is a single qubit, M = σz , and
test cost remains significantly high, indicating overfitting and
poor generalization performance U (x, θ) = W (2) Rx (x)W (1)
This analysis underscores the importance of selecting an ap- .
propriate number of data points for training quantum models.
While fewer data points can lead to overfitting, an optimal num-
ber can achieve effective learning and good generalization.
i·3x
+ (0.05 + 0.05j) e + (0.05 + 0.05j) ei·4x + (0.05 + 0.05j) ei·5x For the quantum models, Circuit 1 achieved a final cost of
0.0000065 using just 2 parameters over 30 epochs, while Circuit
Our variational circuit is of the form
2 reached a final cost of 0.0000042 with the same number of pa-
fθ (x) = ⟨0|U † (x, θ)M U (x, θ)|0⟩ rameters and epochs. These results demonstrate the efficiency of
quantum models in attaining lower costs with significantly fewer
,where |0⟩ is a single qubit, M = σz , and. parameters compared to the classical neural network, particu-
(L+1) (L) (2) (1)
larly for this specific task.
U (x, θ) = Wθ SL (x)Wθ · · · Wθ S1 (x)Wθ However, it is important to emphasize that this analysis does
not account for several critical factors. Comprehensive evalua-
| {z } | {z }
Layer L Layer 1
tion should consider aspects such as computational complexity,
,where L = 5, S(x) = e−ixH = Rx (ϕ), Wθ = scalability, and the robustness of each approach to draw more
RZ(ω)RY (θ)RZ(ϕ). definitive conclusions. Further exploration in these areas is nec-
The circuit is visualized in Fig. 16. essary to fully understand the comparative advantages and lim-
itations of classical and quantum solutions.
• Original images:
Train set Test set Validation set Loss epochs Validation acc Test acc
7971,8028 1006,995 1023,977 exponential 200 88.41% 87%
7971,8028 1006,995 1023,977 cross entropy 100 83.41% 83.3%
7971,8028 1006,995 1023,977 FL, gamma=1 100 85.71% 84.85%
7971,8028 1006,995 1023,977 FL, gamma=2 100 87.46% 86.65%
Table 1: table showing the results for circuit with 4 qubits.(Binary Classification)
• Focal loss:
• Build the decoder part We suggest that using the autoencoder with exponential loss
could lead to improved accuracy. Additionally, we observed a
• Compile and fit the model
slight difference between the MERA architecture described in
• Predict the encoded dataset(train, validation and test) this paper [1] and the version implemented in PennyLane.
The autoencoder was trained using the mean squared error
loss combined with Adam optimizer using keras.
6 Challenges and future scope
6.1 Challenges
We encountered several challenges while working on the project::
• Implementing research papers:
Given the high dimensionality of our images, approxi-
mately 800x800 pixels, significant additional effort was
required to apply the techniques discussed in this project.
Most existing studies typically focus on lower-dimensional
datasets, such as 28x28 pixel images, and often utilize
simplified datasets like MNIST. In contrast, our data is
more complex, originating from real-world sources rather
than standardized datasets, which necessitated the de-
velopment of more sophisticated methods to effectively
process and analyze these images.
• Training time:
Fig 22: The architecture of the used autoencoder. As the complexity of the problem (image) increases, our
We can see that for the second time the exponential loss model expands in both width and depth. This growth also
function was the one that gave the best validation and test ac- translates to an increase in the training time required. In
curacy’s. We had to use less training images since we have a the context of quantum machine learning, this means that
bigger circuit of 8 qubits. Using a bigger training set will in- as the image complexity rises, the quantum circuits must
crease the training time a lot. become more intricate, with more qubits and deeper lay-
We show another time the plotted confusion matrix to see ers of gates, leading to longer training times and greater
how good the model was at predicting each individual class de- computational demands.
fective vs non-defective. • Challenges and Learning Experiences: A significant chal-
lenge was the time constraint. The project involved nu-
merous aspects that we had to familiarize ourselves with,
which proved to be both educational and broadening for
our perspectives.
11