Skip to content
This repository was archived by the owner on Aug 21, 2023. It is now read-only.

Commit d3f957e

Browse files
authored
Merge pull request #802 from mrossinek/minor-fixes-p4
Minor fixes - Part 4 of 8
2 parents ff8bfe4 + f28802f commit d3f957e

8 files changed

Lines changed: 68 additions & 38 deletions

File tree

qiskit/advanced/aqua/artificial_intelligence/qgans_for_loading_random_distributions.ipynb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"\n",
3434
"For further details please refer to <a href=\"https://arxiv.org/abs/1904.00043\">Quantum Generative Adversarial Networks for Learning and Loading Random Distributions. Zoufal, Lucchi, Woerner. 2019.</a>\n",
3535
"\n",
36-
"How to use a trained qGAN in an application, i.e., procing of financial derivatives, is illustrated here:\n",
36+
"How to use a trained qGAN in an application, i.e., pricing of financial derivatives, is illustrated here:\n",
3737
"<a href=\"../finance/machine_learning/qgan_option_pricing.ipynb\">qGAN Option Pricing</a>."
3838
]
3939
},
@@ -106,7 +106,7 @@
106106
"source": [
107107
"### Initialize the qGAN\n",
108108
"The qGAN consists of a quantum generator $G_{\\theta}$, a variational quantum circuit, and a classical discriminator $D_{\\phi}$, a neural network. <br/>\n",
109-
"To implement the quantum generator, we choose a depth-$1$ variational form that implements $R_Y$ rotations and $CZ$ gates which takes a uniform distribution as an input state. Notably, for $k>1$ the generator's parameters must be chosen carefully. For example, the circuit depth should $>1$ becaue the higher the circuit depth the because higher circuit depths enable the representation of more complex structures.<br/>\n",
109+
"To implement the quantum generator, we choose a depth-$1$ variational form that implements $R_Y$ rotations and $CZ$ gates which takes a uniform distribution as an input state. Notably, for $k>1$ the generator's parameters must be chosen carefully. For example, the circuit depth should be $>1$ because higher circuit depths enable the representation of more complex structures.<br/>\n",
110110
"The classical discriminator is given by a $3$-layer neural network that applies linear transformations, leaky ReLU functions in the hidden layers and a sigmoid function in the output layer. Notably, the neural network is implemented with PyTorch. Please refer to https://pytorch.org/get-started/locally/ for PyTorch installation instructions.<br/>\n",
111111
"Here, both networks are updated with the ADAM optimization algorithm."
112112
]
@@ -165,7 +165,7 @@
165165
"\t\\frac{1}{m}\\sum\\limits_{l=1}^{m}\\left[\\log D_{\\phi}\\left(x^{l}\\right) + \\log\\left(1-D_{\\phi}\\left(g^{l}\\right)\\right)\\right], $$\n",
166166
"with $m$ denoting the batch size and $g^l$ describing the data samples generated by the quantum generator.\n",
167167
"\n",
168-
"Please not that the training will take a while ($\\sim 20$ min)."
168+
"Please note that the training will take a while ($\\sim 20$ min)."
169169
]
170170
},
171171
{

qiskit/advanced/aqua/artificial_intelligence/qsvm_classification.ipynb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@
2929
"### Introduction\n",
3030
"Classification algorithms and methods for machine learning are essential for pattern recognition and data mining applications. Well known techniques such as support vector machines and neural networks have blossomed over the last two decades as a result of the spectacular advances in classical hardware computational capabilities and speed. This progress in computer power made it possible to apply techniques, that were theoretically developed towards the middle of the 20th century, on classification problems that were becoming increasingly challenging.\n",
3131
"\n",
32-
"A key concept in classification methods is that of a kernel. Data cannot typically be separated by a hyperplane in its original space. A common technique used to find such a hyperplane consists on applying a non-linear transformation function to the data. This function is called a feature map, as it transforms the raw features, or measurable properties, of the phenomenon or subject under study. Classifying in this new feature space -and, as a matter of fact, also in any other space, including the raw original one- is nothing more than seeing how close data points are to each other. This is the same as computing the inner product for each pair of data in the set. So, in fact we do not need to compute the non-linear feature map for each datum, but only the inner product of each pair of data points in the new feature space. This collection of inner products is called the kernel and it is perfectly possible to have feature maps that are hard to compute but whose kernels are not.\n",
32+
"A key concept in classification methods is that of a kernel. Data cannot typically be separated by a hyperplane in its original space. A common technique used to find such a hyperplane consists of applying a non-linear transformation function to the data. This function is called a feature map, as it transforms the raw features, or measurable properties, of the phenomenon or subject under study. Classifying in this new feature space -and, as a matter of fact, also in any other space, including the raw original one- is nothing more than seeing how close data points are to each other. This is the same as computing the inner product for each pair of data points in the set. So, in fact we do not need to compute the non-linear feature map for each datum, but only the inner product of each pair of data points in the new feature space. This collection of inner products is called the kernel and it is perfectly possible to have feature maps that are hard to compute but whose kernels are not.\n",
3333
"\n",
34-
"In this notebook we provide an example of a classification problem that requires a feature map for which computing the kernel is not efficient classically -this means that the required computational resources are expected to scale exponentially with the size of the problem. We show how this can be solved in a quantum processor by a direct estimation of the kernel in the feature space. The method we used falls in the category of what is called supervised learning, consisting of a training phase (where the kernel is calculated and the support vectors obtained) and a test or classification phase (where new unlabelled data is classified according to the solution found in the training phase).\n",
34+
"In this notebook we provide an example of a classification problem that requires a feature map for which computing the kernel is not efficient classically -this means that the required computational resources are expected to scale exponentially with the size of the problem. We show how this can be solved in a quantum processor by a direct estimation of the kernel in the feature space. The method we used falls in the category of what is called supervised learning, consisting of a training phase (where the kernel is calculated and the support vectors obtained) and a test or classification phase (where new unlabeled data is classified according to the solution found in the training phase).\n",
3535
"\n",
3636
"References and additional details:\n",
3737
"\n",
@@ -64,7 +64,7 @@
6464
"metadata": {},
6565
"source": [
6666
"### [Optional] Setup token to run the experiment on a real device\n",
67-
"If you would like to run the experiement on a real device, you need to setup your account first.\n",
67+
"If you would like to run the experiment on a real device, you need to setup your account first.\n",
6868
"\n",
6969
"Note: If you do not store your token yet, use `IBMQ.save_account('MY_API_TOKEN')` to store it first."
7070
]
@@ -83,7 +83,7 @@
8383
"cell_type": "markdown",
8484
"metadata": {},
8585
"source": [
86-
"First we prepare the dataset, which is used for training, testing and the finally prediction.\n",
86+
"First we prepare the dataset, which is used for training, testing and the final prediction.\n",
8787
"\n",
8888
"*Note: You can easily switch to a different dataset, such as the Breast Cancer dataset, by replacing 'ad_hoc_data' to 'Breast_cancer' below.*"
8989
]
@@ -143,7 +143,7 @@
143143
"- the input dictionary (params) \n",
144144
"- the input object containing the dataset info (algo_input).\n",
145145
"\n",
146-
"With everything setup, we can now run the algorithm.\n",
146+
"With everything set up, we can now run the algorithm.\n",
147147
"\n",
148148
"For the testing, the result includes the details and the success ratio.\n",
149149
"\n",

qiskit/advanced/aqua/chemistry/declarative_approach.ipynb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,17 +51,17 @@
5151
"cell_type": "markdown",
5252
"metadata": {},
5353
"source": [
54-
"Next, we create a Python dictionary to specify the problem we want to solve. There are defaults for many additional values that are not shown here for simpicity. Indeed, we take advantage of using sensisble defaults that the Qiskit Chemistry stack provides. As mentioned above, the Qiskit Chemistry GUI wizard allows for automatic extraction of the Python dictionary, reflecting the current configuration. Once the Python dictionary has been extracted, it can be pasted into a Python program or a Jupyter Notebook and, if necessary, edited.\n",
54+
"Next, we create a Python dictionary to specify the problem we want to solve. There are defaults for many additional values that are not shown here for simplicity. Indeed, we take advantage of using sensible defaults that the Qiskit Chemistry stack provides. As mentioned above, the Qiskit Chemistry GUI wizard allows for automatic extraction of the Python dictionary, reflecting the current configuration. Once the Python dictionary has been extracted, it can be pasted into a Python program or a Jupyter Notebook and, if necessary, edited.\n",
5555
"\n",
56-
"The first entry names a chemistry driver. This example uses HDF5 and the next line configures the driver for an `hdf5` file that contains data from a prior computation for an H$_2$ molecule with basis set `sto-3g`. The operator line would be automatically set by default, but we have added it here to show it and to emphasize where the problem input is converted into a quantum qubit form. We then indicate to the `QiskitChemistry` solver that the VQE algorithm should be used in this experiment, using the COBYLA optimizer with a UCCSD variatonal form and initial state of HartreeFock. VQE uses the variational method to find the mimimum eigenvalue of a problem, which in this case is the ground state energy of the molecule."
56+
"The first entry names a chemistry driver. This example uses HDF5 and the next line configures the driver for an `hdf5` file that contains data from a prior computation for an H$_2$ molecule with basis set `sto-3g`. The operator line would be automatically set by default, but we have added it here to show it and to emphasize where the problem input is converted into a quantum qubit form. We then indicate to the `QiskitChemistry` solver that the VQE algorithm should be used in this experiment, using the COBYLA optimizer with a UCCSD variational form and initial state of HartreeFock. VQE uses the variational method to find the minimum eigenvalue of a problem, which in this case is the ground state energy of the molecule."
5757
]
5858
},
5959
{
6060
"cell_type": "markdown",
6161
"metadata": {},
6262
"source": [
6363
"### [Optional] Setup token to run the experiment on a real device\n",
64-
"If you would like to run the experiement on a real device, you need to setup your account first.\n",
64+
"If you would like to run the experiment on a real device, you need to setup your account first.\n",
6565
"\n",
6666
"Note: If you have not stored your token yet, use `IBMQ.save_account('MY_API_TOKEN')` to store it first."
6767
]
@@ -196,7 +196,7 @@
196196
"cell_type": "markdown",
197197
"metadata": {},
198198
"source": [
199-
"This was a very simple example showing how to get started. There are more elaborate notebooks here as well documentation describing the various components and their configurations to help you to experiment with quantum computing and its application to solving chemistry problems."
199+
"This was a very simple example showing how to get started. There are more elaborate notebooks here as well as documentation describing the various components and their configurations to help you to experiment with quantum computing and its application to solving chemistry problems."
200200
]
201201
},
202202
{

qiskit/advanced/aqua/chemistry/dissociation_profile_of_molecule.ipynb

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
"\n",
7878
"### Molecules considered in this notebook and mapping to qubits\n",
7979
"\n",
80-
"We consider in this notebook the optimization of two potential energy surfaces, for the hydrogen and lithium hydride molecules, obtained using the STO-3G basis. The molecular Hamiltonians are computed as a function of their interatomic distance, then mapped to two-(H$_2$) and four-(LiH$_2$) qubit problems, via elimination of core and high-energy orbitals and removal of $Z_2$ symmetries.\n",
80+
"We consider in this notebook the optimization of two potential energy surfaces, for the hydrogen and lithium hydride molecules, obtained using the STO-3G basis. The molecular Hamiltonians are computed as a function of their interatomic distance, then mapped to two-(H$_2$) and four-(LiH) qubit problems, via elimination of core and high-energy orbitals and removal of $Z_2$ symmetries.\n",
8181
"\n",
8282
"### Approximate universal quantum computing for quantum chemistry problems\n",
8383
"\n",
@@ -132,7 +132,7 @@
132132
"metadata": {},
133133
"source": [
134134
"### [Optional] Setup token to run the experiment on a real device\n",
135-
"If you would like to run the experiement on a real device, you need to setup your account first.\n",
135+
"If you would like to run the experiment on a real device, you need to setup your account first.\n",
136136
"\n",
137137
"Note: If you do not store your token yet, use `IBMQ.save_account('MY_API_TOKEN')` to store it first."
138138
]
@@ -155,7 +155,7 @@
155155
"\n",
156156
"In this first part of the notebook, we show the optimization of the H$_2$ Hamiltonian in the `STO-3G` basis at the bond length of 0.735 Angstrom. After mapping it to a four-qubit system with a parity transformation, two spin-parity symmetries are modded out, leading to a two-qubit Hamiltonian. The energy of the mapped Hamiltonian obtained is then minimized using the variational ansatz described in the introduction, and a stochastic perturbation simultaneous approximation (SPSA) gradient descent method. We stored the precomputed one- and two-body integrals and other molecular information in the `hdf5` file.\n",
157157
"\n",
158-
"Here we use the [*declarative approach*](https://github.com/Qiskit/qiskit-tutorials/blob/master/qiskit/chemistry/declarative_approach.ipynb) to run our experiement, but the same is doable in a [fully programmatic way](https://github.com/Qiskit/qiskit-tutorials/blob/master/qiskit/chemistry/programmatic_approach.ipynb), especially for those users who are interested in learning the Qiskit Aqua and Qiskit Chemistry APIs as well as contributing new algorithmic components."
158+
"Here we use the [*declarative approach*](https://github.com/Qiskit/qiskit-tutorials/blob/master/qiskit/chemistry/declarative_approach.ipynb) to run our experiment, but the same is doable in a [fully programmatic way](https://github.com/Qiskit/qiskit-tutorials/blob/master/qiskit/chemistry/programmatic_approach.ipynb), especially for those users who are interested in learning the Qiskit Aqua and Qiskit Chemistry APIs as well as contributing new algorithmic components."
159159
]
160160
},
161161
{
@@ -329,10 +329,40 @@
329329
},
330330
{
331331
"cell_type": "code",
332-
"execution_count": null,
332+
"execution_count": 1,
333333
"metadata": {},
334-
"outputs": [],
335-
"source": []
334+
"outputs": [
335+
{
336+
"data": {
337+
"text/html": [
338+
"<h3>Version Information</h3><table><tr><th>Qiskit Software</th><th>Version</th></tr><tr><td>Qiskit</td><td>0.12.0</td></tr><tr><td>Terra</td><td>0.9.0</td></tr><tr><td>Aer</td><td>0.3.0</td></tr><tr><td>Ignis</td><td>0.2.0</td></tr><tr><td>Aqua</td><td>0.6.0</td></tr><tr><td>IBM Q Provider</td><td>0.3.2</td></tr><tr><th>System information</th></tr><tr><td>Python</td><td>3.7.4 (default, Jul 16 2019, 07:12:58) \n",
339+
"[GCC 9.1.0]</td></tr><tr><td>OS</td><td>Linux</td></tr><tr><td>CPUs</td><td>4</td></tr><tr><td>Memory (Gb)</td><td>15.560554504394531</td></tr><tr><td colspan='2'>Fri Sep 20 18:30:29 2019 CEST</td></tr></table>"
340+
],
341+
"text/plain": [
342+
"<IPython.core.display.HTML object>"
343+
]
344+
},
345+
"metadata": {},
346+
"output_type": "display_data"
347+
},
348+
{
349+
"data": {
350+
"text/html": [
351+
"<div style='width: 100%; background-color:#d5d9e0;padding-left: 10px; padding-bottom: 10px; padding-right: 10px; padding-top: 5px'><h3>This code is a part of Qiskit</h3><p>&copy; Copyright IBM 2017, 2019.</p><p>This code is licensed under the Apache License, Version 2.0. You may<br>obtain a copy of this license in the LICENSE.txt file in the root directory<br> of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.<p>Any modifications or derivative works of this code must retain this<br>copyright notice, and modified files need to carry a notice indicating<br>that they have been altered from the originals.</p></div>"
352+
],
353+
"text/plain": [
354+
"<IPython.core.display.HTML object>"
355+
]
356+
},
357+
"metadata": {},
358+
"output_type": "display_data"
359+
}
360+
],
361+
"source": [
362+
"import qiskit.tools.jupyter\n",
363+
"%qiskit_version_table\n",
364+
"%qiskit_copyright"
365+
]
336366
}
337367
],
338368
"metadata": {

0 commit comments

Comments
 (0)