Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
A Practical Guide to Quantum Machine Learning and Quantum Optimization

You're reading from  A Practical Guide to Quantum Machine Learning and Quantum Optimization

Product type Book
Published in Mar 2023
Publisher Packt
ISBN-13 9781804613832
Pages 680 pages
Edition 1st Edition
Languages
Authors (2):
Elías F. Combarro Elías F. Combarro
Profile icon Elías F. Combarro
Samuel González-Castillo Samuel González-Castillo
Profile icon Samuel González-Castillo
View More author details

Table of Contents (27) Chapters

Preface Part I: I, for One, Welcome our New Quantum Overlords
Chapter 1: Foundations of Quantum Computing Chapter 2: The Tools of the Trade in Quantum Computing Part II: When Time is Gold: Tools for Quantum Optimization
Chapter 3: Working with Quadratic Unconstrained Binary Optimization Problems Chapter 4: Adiabatic Quantum Computing and Quantum Annealing Chapter 5: QAOA: Quantum Approximate Optimization Algorithm Chapter 6: GAS: Grover Adaptive Search Chapter 7: VQE: Variational Quantum Eigensolver Part III: A Match Made in Heaven: Quantum Machine Learning
Chapter 8: What Is Quantum Machine Learning? Chapter 9: Quantum Support Vector Machines Chapter 10: Quantum Neural Networks Chapter 11: The Best of Both Worlds: Hybrid Architectures Chapter 12: Quantum Generative Adversarial Networks Part IV: Afterword and Appendices
Chapter 13: Afterword: The Future of Quantum Computing
Assessments Bibliography
Index
Other Books You May Enjoy Appendix A: Complex Numbers
Appendix B: Basic Linear Algebra Appendix C: Computational Complexity Appendix D: Installing the Tools Appendix E: Production Notes

Chapter 8
What Is Quantum Machine Learning?

Tell me and I forget. Teach me and I remember. Involve me and I learn.
— Benjamin Franklin

We now begin our journey through Quantum Machine Learning (QML). In this chapter, we will set the foundation for the remainder of this part of the book. We will begin by reviewing some general notions from classical machine learning, and then we will introduce the basic ideas that underlie QML as a whole.

We’ll cover the following topics in this chapter:

  • The basics of machine learning

  • Do you wanna train a model?

  • Quantum-classical models

In this chapter, you will learn the basic principles behind general machine learning, and you will understand how to construct, train, and assess some simple classical models using industry-standard frameworks and tools. We will also present a general picture of the world of QML.

8.1 The basics of machine learning

Before discussing quantum machine learning, it may be a good idea to review some basic notions of Machine Learning (ML), in general. If you are familiar with the subject, feel free to skip this section. Please, keep in mind that the world of machine learning is extraordinarily vast; so much so that sometimes it is difficult to make general statements that can do justice to the overwhelming diversity of this field. For this reason, we will highlight those elements that will be more relevant for our purposes, while other aspects of machine learning — which are also of significant importance on their own — will be barely covered.

In addition to this, please keep in mind that this will be a very condensed and hands-on introduction to machine learning. If you’d like to dive deeper into this field, we can recommend some very good books, such as the one by Abu-Mostafa, Magdon-Ismail, and Lin [1], or the one by Aurélien Géron...

8.2 Do you wanna train a model?

TensorFlow is a machine learning framework developed at Google, and it is very widely used. You should refer to Appendix D, Installing the Tools, for installation instructions. Keep in mind that we will be using version 2.9.1. We will use TensorFlow in some of our quantum machine learning models, so it is a good idea to become familiar with it early on.

To keep things simple, we will tackle an artificial problem. We are going to prepare a dataset of elements belonging to one of two possible categories, and we will try to use machine learning to construct a classifier that can distinguish to which category any given input belongs.

Before we do anything, let us quickly import NumPy and set a seed:

import numpy as np 
 
seed = 128 
 
np.random.seed(seed)

We will later use this same seed with TensorFlow. And now, let’s generate the data!

Instead of generating a dataset by hand, we will use a function provided by the Python scikit-learn package (sklearn...

8.3 Quantum-classical models

In general terms, quantum machine learning refers to the application of machine learning techniques — only that quantum computing is involved at same stage of the process. Maybe you use a quantum computer in some part a model that you wish to train. Maybe you wish to use data generated by some quantum process. Maybe you use a quantum computer to process quantum-generated data. As you can imagine, the subject of quantum machine learning, as a whole, is broad enough to accommodate for a wide range of ideas and applications.

In an attempt to categorize it all a little bit, we can follow the useful classification shown in Schuld’s and Petruccione’s book [106] and divide quantum machine learning into four different flavors, which are depicted in Figure 8.6, according to the classical or quantum nature of the data and processing devices that are used:

  • We could consider part of quantum machine learning all the quantum-inspired classical machine...

Summary

In this chapter, we have explored some basic concepts and ideas that lie at the foundation of machine learning. And we haven’t just explored them from a theoretical point of view: we have also seen them come to life.

We have learned what machine learning is all about, and we have discussed some of the most common approaches used to make it a reality. In particular, we have learned that many machine learning problems can be reduced to the minimization of a loss function through some optimization algorithm on a suitable model.

We have also studied in some depth classical neural networks, and we have used an industry-standard machine learning framework (TensorFlow) to train one.

Lastly, we have wrapped up this chapter by introducing what quantum machine learning is all about and having a sneak peek into the rest of the chapters of this part of the book.

lock icon The rest of the chapter is locked
You have been reading a chapter from
A Practical Guide to Quantum Machine Learning and Quantum Optimization
Published in: Mar 2023 Publisher: Packt ISBN-13: 9781804613832
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}