|
12 | 12 |
|
13 | 13 | ## What is Qiskit Machine Learning?
|
14 | 14 |
|
15 |
| -Qiskit Machine Learning introduces fundamental computational building blocks, such as Quantum Kernels |
16 |
| -and Quantum Neural Networks, used in different applications, including classification and regression. |
17 |
| -On the one hand, this design is very easy to use and allows users to rapidly prototype a first model |
18 |
| -without deep quantum computing knowledge. On the other hand, Qiskit Machine Learning is very flexible, |
19 |
| -and users can easily extend it to support cutting-edge quantum machine learning research. |
| 15 | +Qiskit Machine Learning introduces fundamental computational building blocks, such as Quantum |
| 16 | +Kernels and Quantum Neural Networks, used in various applications including classification |
| 17 | +and regression. |
| 18 | + |
| 19 | +This library is part of the Qiskit Community ecosystem, a collection of high-level codes that are based |
| 20 | +on the Qiskit software development kit. As of version `0.7.0`, Qiskit Machine Learning is co-maintained |
| 21 | +by IBM and the Hartree Center, part of the UK Science and Technologies Facilities Council (STFC). |
| 22 | + |
| 23 | +The Qiskit Machine Learning framework aims to be: |
| 24 | + |
| 25 | +* **User-friendly**, allowing users to quickly and easily prototype quantum machine learning models without |
| 26 | + the need of extensive quantum computing knowledge. |
| 27 | +* **Flexible**, providing tools and functionalities to conduct proof-of-concepts and innovative research |
| 28 | + in quantum machine learning for both beginners and experts. |
| 29 | +* **Extensible**, facilitating the integration of new cutting-edge features leveraging Qiskit's |
| 30 | + architectures, patterns and related services. |
| 31 | + |
20 | 32 |
|
21 | 33 | ## What are the main features of Qiskit Machine Learning?
|
22 | 34 |
|
23 |
| -Qiskit Machine Learning provides the |
24 |
| -[FidelityQuantumKernel](https://qiskit-community.github.io/qiskit-machine-learning/stubs/qiskit_machine_learning.kernels.QuantumKernel.html#qiskit_machine_learning.kernels.FidelityQuantumKernel) |
25 |
| -class that makes use of the [Fidelity](https://qiskit-community.github.io/qiskit-algorithms/stubs/qiskit_algorithms.state_fidelities.BaseStateFidelity.html) algorithm introduced in Qiskit Algorithms and can be easily used |
26 |
| -to directly compute kernel matrices for given datasets or can be passed to a Quantum Support Vector Classifier |
27 |
| -[QSVC](https://qiskit-community.github.io/qiskit-machine-learning/stubs/qiskit_machine_learning.algorithms.QSVC.html#qiskit_machine_learning.algorithms.QSVC) or |
28 |
| -Quantum Support Vector Regressor |
29 |
| -[QSVR](https://qiskit-community.github.io/qiskit-machine-learning/stubs/qiskit_machine_learning.algorithms.QSVR.html#qiskit_machine_learning.algorithms.QSVR) |
30 |
| -to quickly start solving classification or regression problems. |
31 |
| -It also can be used with many other existing kernel-based machine learning algorithms from established |
32 |
| -classical frameworks. |
33 |
| - |
34 |
| -Qiskit Machine Learning defines a generic interface for neural networks that is implemented by different |
35 |
| -quantum neural networks. Two core implementations are readily provided, such as the |
36 |
| -[EstimatorQNN](https://qiskit-community.github.io/qiskit-machine-learning/stubs/qiskit_machine_learning.neural_networks.EstimatorQNN.html), |
37 |
| -and the [SamplerQNN](https://qiskit-community.github.io/qiskit-machine-learning/stubs/qiskit_machine_learning.neural_networks.SamplerQNN.html). |
38 |
| -The [EstimatorQNN](https://qiskit-community.github.io/qiskit-machine-learning/stubs/qiskit_machine_learning.neural_networks.EstimatorQNN.html) |
39 |
| -leverages the [Estimator](https://docs.quantum.ibm.com/api/qiskit/qiskit.primitives.BaseEstimator) primitive from Qiskit and |
40 |
| -allows users to combine parametrized quantum circuits with quantum mechanical observables. The circuits can be constructed using, for example, building blocks |
41 |
| -from Qiskit’s circuit library, and the QNN’s output is given by the expected value of the observable. |
42 |
| -The [SamplerQNN](https://qiskit-community.github.io/qiskit-machine-learning/stubs/qiskit_machine_learning.neural_networks.SamplerQNN.html) |
43 |
| -leverages another primitive introduced in Qiskit, the [Sampler](https://docs.quantum.ibm.com/api/qiskit/qiskit.primitives.BaseSampler) primitive. |
44 |
| -This neural network translates quasi-probabilities of bitstrings estimated by the primitive into a desired output. This |
45 |
| -translation step can be used to interpret a given bitstring in a particular context, e.g. translating it into a set of classes. |
46 |
| - |
47 |
| -The neural networks include the functionality to evaluate them for a given input as well as to compute the |
48 |
| -corresponding gradients, which is important for efficient training. To train and use neural networks, |
49 |
| -Qiskit Machine Learning provides a variety of learning algorithms such as the |
50 |
| -[NeuralNetworkClassifier](https://qiskit-community.github.io/qiskit-machine-learning/stubs/qiskit_machine_learning.algorithms.NeuralNetworkClassifier.html#qiskit_machine_learning.algorithms.NeuralNetworkClassifier) |
51 |
| -and |
52 |
| -[NeuralNetworkRegressor](https://qiskit-community.github.io/qiskit-machine-learning/stubs/qiskit_machine_learning.algorithms.NeuralNetworkRegressor.html#qiskit_machine_learning.algorithms.NeuralNetworkRegressor). |
53 |
| -Both take a QNN as input and then use it in a classification or regression context. |
54 |
| -To allow an easy start, two convenience implementations are provided - the Variational Quantum Classifier |
55 |
| -[VQC](https://qiskit-community.github.io/qiskit-machine-learning/stubs/qiskit_machine_learning.algorithms.VQC.html#qiskit_machine_learning.algorithms.VQC) |
56 |
| -as well as the Variational Quantum Regressor |
57 |
| -[VQR](https://qiskit-community.github.io/qiskit-machine-learning/stubs/qiskit_machine_learning.algorithms.VQR.html#qiskit_machine_learning.algorithms.VQR). |
58 |
| -Both take just a feature map and an ansatz and construct the underlying QNN automatically. |
59 |
| - |
60 |
| -In addition to the models provided directly in Qiskit Machine Learning, it has the |
61 |
| -[TorchConnector](https://qiskit-community.github.io/qiskit-machine-learning/stubs/qiskit_machine_learning.connectors.TorchConnector.html#qiskit_machine_learning.connectors.TorchConnector), |
62 |
| -which allows users to integrate all of our quantum neural networks directly into the |
63 |
| -[PyTorch](https://pytorch.org) |
64 |
| -open source machine learning library. Thanks to Qiskit’s gradient algorithms, this includes automatic |
65 |
| -differentiation - the overall gradients computed by [PyTorch](https://pytorch.org) |
66 |
| -during the backpropagation take into |
67 |
| -account quantum neural networks, too. The flexible design also allows the building of connectors |
68 |
| -to other packages in the future. |
69 |
| - |
70 |
| -## Installation |
71 |
| - |
72 |
| -We encourage installing Qiskit Machine Learning via the pip tool (a python package manager). |
| 35 | +### Kernel-based methods |
| 36 | + |
| 37 | +The [`FidelityQuantumKernel`](https://qiskit-community.github.io/qiskit-machine-learning/stubs/qiskit_machine_learning.kernels.QuantumKernel.html#qiskit_machine_learning.kernels.FidelityQuantumKernel) |
| 38 | +class uses the [`Fidelity`](https://qiskit-community.github.io/qiskit-machine-learning/stubs/qiskit_machine_learning.state_fidelities.BaseStateFidelity.html)) |
| 39 | +algorithm. It computes kernel matrices for datasets and can be combined with a Quantum Support Vector Classifier ([`QSVC`](https://qiskit-community.github.io/qiskit-machine-learning/stubs/qiskit_machine_learning.algorithms.QSVC.html#qiskit_machine_learning.algorithms.QSVC)) |
| 40 | +or a Quantum Support Vector Regressor ([`QSVR`](https://qiskit-community.github.io/qiskit-machine-learning/stubs/qiskit_machine_learning.algorithms.QSVR.html#qiskit_machine_learning.algorithms.QSVR)) |
| 41 | +to solve classification or regression problems respectively. It is also compatible with classical kernel-based machine learning algorithms. |
| 42 | + |
| 43 | + |
| 44 | +### Quantum Neural Networks (QNNs) |
| 45 | + |
| 46 | +Qiskit Machine Learning defines a generic interface for neural networks, implemented by two core (derived) primitives: |
| 47 | + |
| 48 | +- **[`EstimatorQNN`](https://qiskit-community.github.io/qiskit-machine-learning/stubs/qiskit_machine_learning.neural_networks.EstimatorQNN.html):** Leverages the [`Estimator`](https://docs.quantum.ibm.com/api/qiskit/qiskit.primitives.BaseEstimator) primitive, combining parametrized quantum circuits with quantum mechanical observables. The output is the expected value of the observable. |
| 49 | + |
| 50 | +- **[`SamplerQNN`](https://qiskit-community.github.io/qiskit-machine-learning/stubs/qiskit_machine_learning.neural_networks.SamplerQNN.html):** Leverages the [`Sampler`](https://docs.quantum.ibm.com/api/qiskit/qiskit.primitives.BaseSampler) primitive, translating bit-string counts into the desired outputs. |
| 51 | + |
| 52 | +To train and use neural networks, Qiskit Machine Learning provides learning algorithms such as the [`NeuralNetworkClassifier`](https://qiskit-community.github.io/qiskit-machine-learning/stubs/qiskit_machine_learning.algorithms.NeuralNetworkClassifier.html#qiskit_machine_learning.algorithms.NeuralNetworkClassifier) |
| 53 | +and [`NeuralNetworkRegressor`](https://qiskit-community.github.io/qiskit-machine-learning/stubs/qiskit_machine_learning.algorithms.NeuralNetworkRegressor.html#qiskit_machine_learning.algorithms.NeuralNetworkRegressor). |
| 54 | +Finally, built on these, the Variational Quantum Classifier ([`VQC`](https://qiskit-community.github.io/qiskit-machine-learning/stubs/qiskit_machine_learning.algorithms.VQC.html#qiskit_machine_learning.algorithms.VQC)) |
| 55 | +and the Variational Quantum Regressor ([`VQR`](https://qiskit-community.github.io/qiskit-machine-learning/stubs/qiskit_machine_learning.algorithms.VQR.html#qiskit_machine_learning.algorithms.VQR)) |
| 56 | +take a _feature map_ and an _ansatz_ to construct the underlying QNN automatically using high-level syntax. |
| 57 | + |
| 58 | +### Integration with PyTorch |
| 59 | + |
| 60 | +The [`TorchConnector`](https://qiskit-community.github.io/qiskit-machine-learning/stubs/qiskit_machine_learning.connectors.TorchConnector.html#qiskit_machine_learning.connectors.TorchConnector) |
| 61 | +integrates QNNs with [PyTorch](https://pytorch.org). |
| 62 | +Thanks to the gradient algorithms in Qiskit Machine Learning, this includes automatic differentiation. |
| 63 | +The overall gradients computed by PyTorch during the backpropagation take into account quantum neural |
| 64 | +networks, too. The flexible design also allows the building of connectors to other packages in the future. |
| 65 | + |
| 66 | +## Installation and documentation |
| 67 | + |
| 68 | +We encourage installing Qiskit Machine Learning via the `pip` tool, a `Python` package manager. |
73 | 69 |
|
74 | 70 | ```bash
|
75 | 71 | pip install qiskit-machine-learning
|
76 | 72 | ```
|
77 | 73 |
|
78 |
| -**pip** will handle all dependencies automatically and you will always install the latest |
79 |
| -(and well-tested) version. |
| 74 | +`pip` will install all dependencies automatically, so that you will always have the most recent |
| 75 | +stable version. |
80 | 76 |
|
81 |
| -If you want to work on the very latest work-in-progress versions, either to try features ahead of |
82 |
| -their official release or if you want to contribute to Machine Learning, then you can install from source. |
83 |
| -To do this follow the instructions in the |
| 77 | +If you want to work instead on the very latest _work-in-progress_ versions of Qiskit Machine Learning, |
| 78 | +either to try features ahead of |
| 79 | +their official release or if you want to contribute to the library, then you can install from source. |
| 80 | +For more details on how to do so and much more, follow the instructions in the |
84 | 81 | [documentation](https://qiskit-community.github.io/qiskit-machine-learning/getting_started.html#installation).
|
85 | 82 |
|
86 | 83 | ### Optional Installs
|
87 | 84 |
|
88 |
| -* **PyTorch**, may be installed either using command `pip install 'qiskit-machine-learning[torch]'` to install the |
| 85 | +* **PyTorch** may be installed either using command `pip install 'qiskit-machine-learning[torch]'` to install the |
89 | 86 | package or refer to PyTorch [getting started](https://pytorch.org/get-started/locally/). When PyTorch
|
90 | 87 | is installed, the `TorchConnector` facilitates its use of quantum computed networks.
|
91 | 88 |
|
92 |
| -* **Sparse**, may be installed using command `pip install 'qiskit-machine-learning[sparse]'` to install the |
93 |
| - package. Sparse being installed will enable the usage of sparse arrays/tensors. |
| 89 | +* **Sparse** may be installed using command `pip install 'qiskit-machine-learning[sparse]'` to install the |
| 90 | + package. Sparse being installed will enable the usage of sparse arrays and tensors. |
| 91 | + |
| 92 | +* **NLopt** is required for the global optimizers. [`NLopt`](https://nlopt.readthedocs.io/en/latest/) |
| 93 | + can be installed manually with `pip install nlopt` on Windows and Linux platforms, or with `brew |
| 94 | + install nlopt` on MacOS using the Homebrew package manager. For more information, |
| 95 | + refer to the [installation guide](https://nlopt.readthedocs.io/en/latest/NLopt_Installation/). |
94 | 96 |
|
95 | 97 | ## Migration to Qiskit 1.x
|
96 | 98 | > [!NOTE]
|
97 |
| -> Qiskit Machine Learning learning depends on Qiskit, which will be automatically installed as a |
98 |
| -> dependency when you install Qiskit Machine Learning. If you have a pre-`1.0` version of Qiskit |
99 |
| -> installed in your environment (however it was installed), and wish to upgrade to `1.0`, you |
100 |
| -> should take note of the |
| 99 | +> Qiskit Machine Learning depends on Qiskit, which will be automatically installed as a |
| 100 | +> dependency when you install Qiskit Machine Learning. From version `0.8.0` of Qiskit Machine |
| 101 | +> Learning, Qiskit `1.0` or above will be required. If you have a pre-`1.0` version of Qiskit |
| 102 | +> installed in your environment (however it was installed), you should upgrade to `1.x` to |
| 103 | +> continue using the latest features. You may refer to the |
101 | 104 | > official [Qiskit 1.0 Migration Guide](https://docs.quantum.ibm.com/api/migration-guides/qiskit-1.0)
|
102 |
| -> for detailed instructions and examples on how to upgrade. |
| 105 | +> for detailed instructions and examples on how to upgrade Qiskit. |
103 | 106 |
|
104 | 107 | ----------------------------------------------------------------------------------------------------
|
105 | 108 |
|
106 | 109 | ### Creating Your First Machine Learning Programming Experiment in Qiskit
|
107 | 110 |
|
108 |
| -Now that Qiskit Machine Learning is installed, it's time to begin working with the Machine Learning module. |
109 |
| -Let's try an experiment using VQC (Variational Quantum Classifier) algorithm to |
110 |
| -train and test samples from a data set to see how accurately the test set can |
111 |
| -be classified. |
| 111 | +Now that Qiskit Machine Learning is installed, it's time to begin working with the Machine |
| 112 | +Learning module. Let's try an experiment using VQC (Variational Quantum Classifier) algorithm to |
| 113 | +train and test samples from a data set to see how accurately the test set can be classified. |
112 | 114 |
|
113 | 115 | ```python
|
114 | 116 | from qiskit.circuit.library import TwoLocal, ZZFeatureMap
|
@@ -177,9 +179,11 @@ For questions that are more suited for a forum, we use the **Qiskit** tag in [St
|
177 | 179 |
|
178 | 180 | ## Humans behind Qiskit Machine Learning
|
179 | 181 |
|
180 |
| -Qiskit Machine Learning was inspired, authored and brought about by the collective work of a team of researchers |
181 |
| -and software engineers. This library continues to grow with the help and work of |
182 |
| -[many people](https://github.com/qiskit-community/qiskit-machine-learning/graphs/contributors), who contribute to the project at different levels. |
| 182 | +Qiskit Machine Learning was inspired, authored and brought about by the collective work of a |
| 183 | +team of researchers and software engineers. This library continues to grow with the help and |
| 184 | +work of |
| 185 | +[many people](https://github.com/qiskit-community/qiskit-machine-learning/graphs/contributors), |
| 186 | +who contribute to the project at different levels. |
183 | 187 |
|
184 | 188 | ## How can I cite Qiskit Machine Learning?
|
185 | 189 | If you use Qiskit, please cite as per the provided
|
|
0 commit comments