A Practical Guide to Quantum Machine Learning and Quantum Optimization: Hands-on Approach to Modern Quantum Algorithms

This document was uploaded by one of our users. The uploader already confirmed that they had the permission to publish it. If you are author/publisher or own the copyright of this documents, please report to us by using this DMCA report form.

Simply click on the Download Book button.

Yes, Book downloads on Ebookily are 100% Free.

Sometimes the book is free on Amazon As well, so go ahead and hit "Search on Amazon"

Work with fully explained algorithms and ready-to-use examples that can be run on quantum simulators and actual quantum computers with this comprehensive guide Key Features Get a solid grasp of the principles behind quantum algorithms and optimization with minimal mathematical prerequisites Learn the process of implementing the algorithms on simulators and actual quantum computers Solve real-world problems using practical examples of methods Book Description This book provides deep coverage of modern quantum algorithms that can be used to solve real-world problems. You'll be introduced to quantum computing using a hands-on approach with minimal prerequisites. You'll discover many algorithms, tools, and methods to model optimization problems with the QUBO and Ising formalisms, and you will find out how to solve optimization problems with quantum annealing, QAOA, Grover Adaptive Search (GAS), and VQE. This book also shows you how to train quantum machine learning models, such as quantum support vector machines, quantum neural networks, and quantum generative adversarial networks. The book takes a straightforward path to help you learn about quantum algorithms, illustrating them with code that's ready to be run on quantum simulators and actual quantum computers. You'll also learn how to utilize programming frameworks such as IBM's Qiskit, Xanadu's PennyLane, and D-Wave's Leap. Through reading this book, you will not only build a solid foundation of the fundamentals of quantum computing, but you will also become familiar with a wide variety of modern quantum algorithms. Moreover, this book will give you the programming skills that will enable you to start applying quantum methods to solve practical problems right away. What you will learn Review the basics of quantum computing Gain a solid understanding of modern quantum algorithms Understand how to formulate optimization problems with QUBO Solve optimization problems with quantum annealing, QAOA, GAS, and VQE Find out how to create quantum machine learning models Explore how quantum support vector machines and quantum neural networks work using Qiskit and PennyLane Discover how to implement hybrid architectures using Qiskit and PennyLane and its PyTorch interface Who this book is for This book is for professionals from a wide variety of backgrounds, including computer scientists and programmers, engineers, physicists, chemists, and mathematicians. Basic knowledge of linear algebra and some programming skills (for instance, in Python) are assumed, although all mathematical prerequisites will be covered in the appendices.

Author(s): Elías F. Combarro,Samuel González-Castillo
Publisher: Packt Publishing
Year: 2023

Language: English
Pages: 680

Cover
Title Page
Copyright and Credits
Foreword
Acknowledgements
Table of Contents
Preface
Part 1: I, for One, Welcome our New Quantum Overlords
Chapter 1: Foundations of Quantum Computing
Quantum computing: the big picture
The basics of the quantum circuit model
Working with one qubit and the Bloch sphere
What is a qubit?
Dirac notation and inner products
One-qubit quantum gates
The Bloch sphere and rotations
Hello, quantum world!
Working with two qubits and entanglement
Two-qubit states
Two-qubit gates: tensor products
The CNOT gate
Entanglement
The no-cloning theorem
Controlled gates
Hello, entangled world!
Working with multiple qubits and universality
Multi-qubit systems
Multi-qubit gates
Universal gates in quantum computing
Summary
Chapter 2: The Tools of the Trade in Quantum Computing
Tools for quantum computing: a non-exhaustive overview
A non-exhaustive survey of frameworks and platforms
Qiskit, PennyLane, and Ocean
Working with Qiskit
An overview of the Qiskit framework
Using Qiskit Terra to build quantum circuits
Initializing circuits
Quantum gates
Measurements
Using Qiskit Aer to simulate quantum circuits
Let's get real: using IBM Quantum
Working with PennyLane
Circuit engineering 101
PennyLane's interoperability
Love is in the Aer
Connecting to IBMQ
Summary
Part 2: When Time is Gold: Tools for Quantum Optimization
Chapter 3: Working with Quadratic Unconstrained Binary Optimization Problems
The Max-Cut problem and the Ising model
Graphs and cuts
Formulating the problem
The Ising model
Enter quantum: formulating optimization problems the quantum way
From classical variables to qubits
Computing expectation values with Qiskit
Moving from Ising to QUBO and back
Combinatorial optimization problems with the QUBO model
Binary linear programming
The Knapsack problem
Graph coloring
The Traveling Salesperson Problem
Other problems and other formulations
Summary
Chapter 4: Adiabatic Quantum Computing and Quantum Annealing
Adiabatic quantum computing
Quantum annealing
Using Ocean to formulate and transform optimization problems
Constrained quadratic models in Ocean
Solving constrained quadratic models with dimod
Running constrained problems on quantum annealers
Solving optimization problems on quantum annealers with Leap
The Leap annealers
Embeddings and annealer topologies
Controlling annealing parameters
The importance of coupling strengths
Classical and hybrid samplers
Classical solvers
Hybrid solvers
Summary
Chapter 5: QAOA: Quantum Approximate Optimization Algorithm
From adiabatic computing to QAOA
Discretizing adiabatic quantum computing
QAOA: The algorithm
Circuits for QAOA
Estimating the energy
QUBO and HOBO
Using QAOA with Qiskit
Using QAOA with Hamiltonians
Solving QUBO problems with QAOA in Qiskit
Using QAOA with PennyLane
Summary
Chapter 6: GAS: Grover Adaptive Search
Grover's algorithm
Quantum oracles
Grover's circuits
Probability of finding a marked element
Finding minima with Grover's algorithm
Quantum oracles for combinatorial optimization
The quantum Fourier transform
Encoding and adding integer numbers
Computing the whole polynomial
Constructing the oracle
Using GAS with Qiskit
Summary
Chapter 7: VQE: Variational Quantum Eigensolver
Hamiltonians, observables, and their expectation values
Observables
Estimating the expectation values of observables
Introducing VQE
Getting excited with VQE
Using VQE with Qiskit
Defining a molecular problem in Qiskit
Using VQE with Hamiltonians
Finding excited states with Qiskit
Using VQE with molecular problems
Simulations with noise
Running VQE on quantum computers
The shape of things to come: the future of Qiskit
Using VQE with PennyLane
Defining a molecular problem in PennyLane
Implementing and running VQE
Running VQE on real quantum devices
Summary
Part 3: A Match Made in Heaven: Quantum Machine Learning
Chapter 8: What Is Quantum Machine Learning?
The basics of machine learning
The ingredients for machine learning
Types of machine learning
Do you wanna train a model?
Picking a model
Understanding loss functions
Gradient descent
Getting in the (Tensor)Flow
Training the model
Binary classifier performance
Quantum-classical models
Summary
Chapter 9: Quantum Support Vector Machines
Support vector machines
The simplest classifier you could think of
How to train support vector machines: the hard-margin case
Soft-margin training
The kernel trick
Going quantum
The general idea behind quantum support vector machines
Feature maps
Quantum support vector machines in PennyLane
Setting the scene for training a QSVM
PennyLane and scikit-learn go on their first date
Reducing the dimensionality of a dataset
Implementing and using custom feature maps
Quantum support vector machines in Qiskit
QSVMs on Qiskit Aer
QSVMs on IBM quantum computers
Summary
Chapter 10: Quantum Neural Networks
Building and training a quantum neural network
A journey from classical neural networks to quantum neural networks
Variational forms
A word about measurements
Gradient computation and the parameter shift rule
Practical usage of quantum neural networks
Quantum neural networks in PennyLane
Preparing data for a QNN
Building the network
Using TensorFlow with PennyLane
Gradient computation in PennyLane
Quantum neural networks in Qiskit: a commentary
Summary
Chapter 11: The Best of Both Worlds: Hybrid Architectures
The what and why of hybrid architectures
Hybrid architectures in PennyLane
Setting things up
A binary classification problem
Training models in the real world
A multi-class classification problem
A general perspective on multi-class classification tasks
Implementing a QNN for a ternary classification problem
Hybrid architectures in Qiskit
Nice to meet you, PyTorch!
Setting up a model in PyTorch
Training a model in PyTorch
Building a hybrid binary classifier with Qiskit
Training Qiskit QNNs with Runtime
A glimpse into the future
Summary
Chapter 12: Quantum Generative Adversarial Networks
GANs and their quantum counterparts
A seemingly unrelated story about money
What actually is a GAN?
Some technicalities about GANs
Quantum GANs
Quantum GANs in PennyLane
Preparing a QGAN model
The training process
Quantum GANs in Qiskit
Summary
Afterword and Appendices
Chapter 13: Afterword: The Future of Quantum Computing
Appendix A: Complex Numbers
Appendix B: Basic Linear Algebra
Vector spaces
Bases and coordinates
Linear maps and eigenstuff
Inner products and adjoint operators
Matrix exponentiation
A crash course in modular arithmetic
Appendix C: Computational Complexity
A few words on Turing machines
Measuring computational time
Asymptotic complexity
P and NP
Hardness, completeness, and reductions
A very brief introduction to quantum computational complexity
Appendix D: Installing the Tools
Getting Python
Installing the libraries
Accessing IBM's quantum computers
Accessing D-Wave quantum annealers
Using GPUs to accelerate simulations in Google Colab
Appendix E: Production Notes
Assessments
Chapter 1, Foundations of Quantum Computing
Chapter 2, The Tools of the Trade in Quantum Computing
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 Adaptative Search
Chapter 7, VQE: Variational Quantum Eigensolver
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
Bibliography
Index
Other Books You Might Enjoy