How to start studying Quantum Machine Learning
This is my second post about Quantum Machine Learning (QML), this is the first one, on why you should start studying QML.
Starting to study quantum machine learning was hard because I didn’t know how much I needed to know about quantum mechanics and computing. I had quantum mechanics 101 on college in 2008 so I couldn’t remember much (I remember the basics ideas and concepts) and quantum computing was complete foreign to me.
Then I asked a friend who was studying about quantum computing and his answer was: it all depends on which is your goal. If you want to learn how to develop a quantum hardware you must learn about quantum mechanics, but if you want to focus on algorithms linear algebra is enough!
Now I think he was partially right, even though it is really helpful to learn quantum mechanics. Linear algebra and statistics are the most important concepts that you need to start learning quantum machine learning specifically. The next step on my journey was how to start learning the basic concepts of quantum computing to later head on QML? This was a tough part because I didn’t want to start learning with very theoretical articles, I wanted to start learning in a simple way. Papers tend to be too much theoretical (and they should be) and too heavy on notations, which is harsh for someone who isn’t used to quantum mechanics notation.
So I started learning by reading the Qiskit and Pennylane tutorials, which are two of the most known Python libraries to simulate quantum devices. But sometimes the tutorials were too much on how to write the code and less based on the concepts, so I still wasn’t feeling that I was totally on the right path. Also, some tutorials were too focused on building quantum circuits, which is important, but I still had questions on how much should I be an expert on building quantum circuits before heading to QML.
I also tried to read QML posts on Medium, which was also very helpful. I highly recommend Frank Zieckert blog and his books, which were a really nice introduction to the basic concepts of quantum computing and QML. The Qiskit community on Medium has some nice posts with interesting projects. Towards Data Science is not specific about QML, but sometimes they post something nice content about the subject.
Finally, after some months studying about QML, my suggested learning path is:
- Read Frank Zieckert books: they are a nice introduction to QML. They explain the basic concepts of quantum computing in a very didatic way, not rushing on concepts explanation and not being too reliant on mathematical notations. Also, there is a lo of codes of circuit designs and simulations on Qiskit, which is really nice. Personally, I really enjoyed the Variational Quantum Eigensolver (VQE) and Quantum Approximate Optimization Algorithm.
- Practice a lot. Design quantum circuits and simulate them. You can use Qiskit, Pennylane or other libraries. This is very important to fully understand how quantum superposition and entanglement works in practice and how quantum gates operate. A Controlled-Not (CNOT) is not so simple as its name suggests! Here I confess I should be practicing more.
- Read from other blogs in Medium, understand how other people are trying to use QML, because we are still trying to understand how powerful this tool is (some nice posts here and here). Try to find subjects that you already like in Data Science to understand what people are approaching in QML. And you can also read my blog, comment or criticise my mistakes (I really encourage you, I’m here to learn).
- Try to solve simple optimization and classification problems using quantum and classical computing combined.
And now I hope I can help you talking about my own journey.
What tools I should use
Obviously it is not practical to start learning with a real quantum computer, but this is not a problem for starters, there are some Python libraries that simulate quantum devices. I didn’t look for libraries in other languages since I already work with Python and I found plenty material in this language.
I ran into two of them that I analyzed: Pennylane and Qiskit.
Even though Qiskit is more known I started with Pennylane because I saw that it was focused on QML, so I started studying its documentation. Instead of making a long text, I will make a list of pros and cons.
Pennylane:
Advantages:
- good documentation and tutorials
- it is easy to install and make the tutorial’s code work in your machine (at least for me)
- flexibility to run optimization problems
Disadvantages:
- I didn’t find very intuitive to make something outside the context of the tutorials (maybe that’s on me!)
- it was easier to design quantum circuits on Qiskit and that was the main reason I switched to Qiskit
When I had to design a more complex circuit I had some troubles trying in Pennylane and then I had the impression that was easier to design it in Qiskit. Pennylane has a nice Qiskit plugin and then I designed the circuit in Qiskit and imported to Pennylane. But then I struggled with other matters in the problem and then I thought: maybe I should design everything on Qiskit. Well, Pennylane is a very nice library and maybe I had these difficulties due to my inability.
About Qiskit:
Advantages:
- good documentation and tutorials
- flexibility to run optimization problems
- easy to design quantum circuits
- easy to deploy simple QML models
- has a big number of modules, including ML
Disadvantages:
- Qiskit had some deprecated modules and I had some problems running codes from Medium posts that used functions from these deprecated libraries
But the fact is: I really like Qiskit and that is my choice (sorry Pennylane!).
But there is something you need in the beginning: patience! These are quantum devices simulators, so they really calculate using classical computing using the logic of quantum computing, which is something costly, so working with QML models in your computer requires patience, because it takes time to train a model for a relatively small data set and we won’t be able to develop models in large datasets!