Thinking Quantum Machine Learning, code of the book Quantum Machine Learning
Project description
ThQML: Thinking Quantum Machine learning
Code for the book Quantum Machine Learning, https://doi.org/10.1007/978-3-031-44226-1
Being free of any licensing fees, ThQML is ideal for exploring quantum machine learning for students and researchers.
Created by following https://packaging.python.org/en/latest/tutorials/packaging-projects/
Requirements
graphviz https://graphviz.gitlab.io/download for plot_model to work
Installation
Local installation.
The use may eventually use a conda or similar environment.
In the downloaded folder from github
python3 -m pip install .
Note the dot at the end
To install an editable version
python3 -m pip install -e .
Note the dot after editable
Citing ThQML
If you use ThQML in your research, please cite the book
See the references in thqml.bib
Last test with code versions (september 2023)
- tensorflow 2.11.0
- matplotlib 3.7.2
- numpy 1.24.3
Tree
.
├── CODE_OF_CONDUCT.md
├── jupyternotebooks
│ ├── bosonsampling
│ │ ├── BosonSamplingExample1.ipynb
│ │ ├── BosonSamplingExample2.ipynb
│ │ ├── BosonSamplingExample3.ipynb
│ │ ├── BosonSamplingExample4b.ipynb
│ │ ├── BosonSamplingExample4.ipynb
│ │ ├── BosonSamplingExample5.ipynb
│ │ ├── BosonSamplingExample6.ipynb
│ │ ├── BosonSamplingExample7.ipynb
│ │ ├── BosonSamplingExample8.ipynb
│ │ └── BosonSamplingExample9.ipynb
│ ├── logo_circular.png
│ ├── phasespace
│ │ ├── beamsplitter.ipynb
│ │ ├── BellBS.ipynb
│ │ ├── coherentcomplex.ipynb
│ │ ├── coherentcomplextrainingCOV.ipynb
│ │ ├── coherentcomplextrainingDER.ipynb
│ │ ├── coherentcomplextraining.ipynb
│ │ ├── coherent.ipynb
│ │ ├── differentiallayer.ipynb
│ │ ├── phasemodulator.ipynb
│ │ ├── photoncountinglayer.ipynb
│ │ ├── singlemodesqueezerBS.ipynb
│ │ ├── singlemodesqueezer.ipynb
│ │ ├── symplectic.ipynb
│ │ ├── testGaussianLayer.ipynb
│ │ ├── twolayersreservoir.ipynb
│ │ ├── twomodesqueezer.ipynb
│ │ └── uncertainty.ipynb
│ ├── quantumfeaturemap
│ │ ├── coherentstate.ipynb
│ │ ├── kernelexample.ipynb
│ │ ├── QAOATwoQubitTransverseFieldIsing.ipynb
│ │ ├── QuantumKernelMachineQubits.ipynb
│ │ ├── QuantumNeuralStateTwoQubitTransverseFieldIsing.ipynb
│ │ ├── QubitsDensityMatrix.ipynb
│ │ ├── QubitsGym.ipynb
│ │ ├── QubitsMap.ipynb
│ │ ├── SingleQubitTransverseFieldIsing.ipynb
│ │ ├── squeezedvacuum.ipynb
│ │ ├── TensorsAndVectors.ipynb
│ │ └── TwoQubitTransverseFieldIsing.ipynb
│ └── soliton
│ ├── BoseHubbardNNT.ipynb
│ ├── BoseHubbardTwinNNT.ipynb
│ ├── BoseHubbardTwinNNTVersusN.ipynb
│ ├── modelSingleSoliton.png
│ └── modelTwin.png
├── LICENSE.txt
├── mathematica
│ ├── noncommutative.nb
│ ├── SingleQubitTransverseIsing.nb
│ ├── SingleQubitTransverseIsing.pdf
│ ├── tensorgaussian.nb
│ ├── TwoQubitTransverseIsing.nb
│ └── TwoQubitTransverseIsing.pdf
├── matlabsymbolic
│ ├── beamsplitter.m
│ ├── entanglementBS.m
│ ├── plot_entanglement_BS.m
│ ├── RqRpJ.m
│ ├── squeezedoperator.m
│ ├── test_RqRp.m
│ └── twomodesqueezedoperator.m
├── pyproject.toml
├── README.md
├── thqml
│ ├── EntangledFeatureMap.py
│ ├── __init__.py
│ ├── phasespace.py
│ ├── quantummap.py
│ ├── quantumsolitons.py
│ └── utilities.py
└── thqml.bib
Documentation
See the book Quantum Machine Learning
Code per chapter
Chapter 1
jupyternotebooks/quantumfeaturemap/kernelexample.ipynbPage 13 Example of generation of dataset and withscikit-lean
Chapter 2
jupyternotebooks/quantumfeaturemap/coherentstate.ipynbPage 33 Feature mapping by coherent statejupyternotebooks/quantumfeaturemap/squeezedvacuum.ipynbpage 38 feature mapping by squeezed state
Chapter 3
jupyternotebooks/quantumfeaturemap/QubitsMap.ipynbpage 52 defining Qubits in TensorFlowjupyternotebooks/quantumfeaturemap/TensorsAndVectors.ipynbpage 56 defining and manipulating tensors and vectorsthqml/quantummap.pypage 61 main library with qubit functionsjupyternotebooks/quantumfeaturemap/QubitsMap.ipynbpage 61 (continue) qubits feature mappingjupyternotebooks/quantumfeaturemap/QubitsGym.ipynbpage 64 more on qubits and tensorsthqml/quantummap.pypage 68 (continue) main library with qubit functionsjupyternotebooks/quantumfeaturemap/QubitsMap.ipynbpage 74 (continue) qubits feature mappingjupyternotebooks/quantumfeaturemap/QuantumKernelMachineQubits.ipynbpage 79 quantum kernel machine with qubits
Chapter 4
jupyternotebooks/quantumfeaturemap/SingleQubitTransverseFieldIsing.ipynbpage 89 Transverse Field Ising Model with a Single Qubitmathematica/SingleQubitTransverseIsing.nbMATHEMATICA page 90 Analytical results on the single qubit transverse field Ising modeljupyternotebooks/quantumfeaturemap/SingleQubitTransverseFieldIsing.ipynbpage 92 (continue) Transverse Field Ising Model with a Single Qubitjupyternotebooks/quantumfeaturemap/SingleQubitTransverseFieldIsing.ipynbpage 99 (continue) Transverse Field Ising Model with a Single Qubit
Chapter 5
mathematica/TwoQubitTransverseIsing.nbMATHEMATICA page 104 Analytical results on the two-qubit transverse field Ising modelmathematica/TwoQubitTransverseIsing.nbMATHEMATICA page 105 (continue) Analytical results on the two-qubit transverse field Ising modeljupyternotebooks/quantumfeaturemap/QubitsDensityMatrix.ipynbpage 114 Computing the density matrix with qubitsjupyternotebooks/quantumfeaturemap/QubitsDensityMatrix.ipynbpage 118 (continue) Computing the density matrix with qubitsjupyternotebooks/quantumfeaturemap/QubitsDensityMatrix.ipynbpage 132 (continue) Computing the density matrix with qubitsmathematica/TwoQubitTransverseIsing.nbMATHEMATICA page 133 (continue) Analytical results on the two-qubit transverse field Ising model
Chapter 6
jupyternotebooks/quantumfeaturemap/TwoQubitTransverseFieldIsing.ipynbpage 139 Transverse Field Ising Model with Two Qubitjupyternotebooks/quantumfeaturemap/QAOATwoQubitTransverseFieldIsing.ipynbpage 152 Transverse Field Ising Model with Two Qubit with Quantum Approximation Optimization Algorithmjupyternotebooks/quantumfeaturemap/QuantumNeuralStateTwoQubitTransverseFieldIsing.ipynbpage 157 Transverse Field Ising Model with Two Qubit with Quantum Neural State
Chapter 7
matlabsymbolic/test_Rqpm.mMATLAB page 188 Symbolic relations of projection matricesjupyternotebooks/phasespace/symplectic.ipynbpage 189 Test of projection matrices in jupyterthqml/phasespace.pypage 190 main library with phasespace functionsthqml/phasespace.pypage 191 (continue) main library with phasespace functions
Chapter 8
thqml/phasespace.pypage 196 (continue) main library with phasespace functionsthqml/phasespace.pypage 199 (continue) main library with phasespace functionsjupyternotebooks/phasespace/testGaussianLayer.ipynbpage 199 Test of the Gaussian layerjupyternotebooks/phasespace/testGaussianLayer.ipynbpage 200 (continue) Test of the Gaussian layerthqml/phasespace.pypage 205 (continue) main library with phasespace functionsjupyternotebooks/phasespace/coherent.ipynbpage 209 Neural network representation of a coherent statethqml/phasespace.pypage 210 (continue) main library with phasespace functions
Chapter 9
jupyternotebooks/phasespace/coherent.ipynbpage 216 (continue) Neural network representation of a coherent statejupyternotebooks/phasespace/coherentcomplex.ipynbpage 217 Coherent state in a complex mediumjupyternotebooks/phasespace/coherentcomplex.ipynbpage 219 (continue) Coherent state in a complex mediumjupyternotebooks/phasespace/coherentcomplextraining.ipynbpage 219 Coherent state in a complex medium with trainingjupyternotebooks/phasespace/coherentcomplextraining.ipynbpage 221 (continue) Coherent state in a complex medium with trainingjupyternotebooks/phasespace/coherentcomplextraining.ipynbpage 222 (continue) Coherent state in a complex medium with trainingjupyternotebooks/phasespace/coherentcomplextrainingDER.ipynbpage 225 Coherent state in a complex medium with training with derivativesthqml/phasespace.pypage 226 (continue) main library with phasespace functionsjupyternotebooks/phasespace/coherentcomplextrainingCOV.ipynbpage 227 Coherent state in a complex medium with training with covariancejupyternotebooks/phasespace/twolayersreservoir.ipynbpage 230 Two trainable interferometer and a reservoirthqml/phasespace.pypage 231 (continue) Main library with phasespace functionsjupyternotebooks/phasespace/phasemodulator.ipynbpage 232 Phase modulator model
Chapter 10
matlabsymbolic/squeezeoperator.mMATLAB page 237 Matrix representation of the squeeze operator in MATLABjupyternotebooks/phasespace/singlemodesquezer.ipynbpage 237 Single-mode squeezer modelthqml/phasespace.pypage 238 (continue) Main library with phasespace functionsjupyternotebooks/phasespace/singlemodesquezer.ipynbpage 240 (continue) Single-mode squeezer modeljupyternotebooks/phasespace/singlemodesquezer.ipynbpage 243 (continue) Single-mode squeezer modelmatlabsymbolic/squeezeoperator.mMATLAB page 244 Matrix representation of the two-mode squeeze operator in MATLABthqml/phasespace.pypage 245 (continue) Main library with phasespace functionsjupyternotebooks/phasespace/twomodesquezer.ipynbpage 247 Two-mode squeezer modelmatlabsymbolic/beamsplitter.mMATLAB page 248 Matrix representation of the beam splitter operator in MATLABthqml/phasespace.pypage 248 (continue) Main library with phasespace functionsjupyternotebooks/phasespace/beamsplitter.ipynbpage 251 Beam splitter modelthqml/phasespace.pypage 251 (continue) Main library with phasespace functionsjupyternotebooks/phasespace/photoncountinglayer.ipynbpage 252 Example 1 with a photon counting layerjupyternotebooks/phasespace/BellBS.ipynbpage 254 Example 2 with a photon counting layerjupyternotebooks/phasespace/photoncounting.ipynbpage 254 Example 3 with a photon counting layerjupyternotebooks/phasespace/BellBS.ipynbpage 255 (continue) Example 4 with a photon counting layer and beam splitter
Chapter 11
thqml/phasespace.pypage 263 (continue) Main library with phasespace functionsjupyternotebooks/phasespace/uncertainty.ipynbpage 264 Example in using Laplacian layer for computing uncertaintythqml/phasespace.pypage 265 (continue) Main library with phasespace functionsjupyternotebooks/phasespace/uncertainty.ipynbpage 267 (continue) Example in using Laplacian layer for computing uncertaintythqml/phasespace.pypage 267 (continue) Main library with phasespace functionsjupyternotebooks/phasespace/uncertainty.ipynbpage 269 (continue) Example in using Laplacian layer for computing uncertaintyjupyternotebooks/phasespace/uncertainty.ipynbpage 272 (continue) Example in using Laplacian layer for computing uncertaintymathematica/noncommutative.nbMATHEMATICA page 275 Mathematica example on non commutative operatorsmathematica/tensorgaussian.nbMATHEMATICA page 276 Mathematica example on tensors for Gaussian statesthqml/phasespace.pypage 279 (continue) Main library with phasespace functionsjupyternotebooks/phasespace/differentiallayer.ipynbpage 282 Example of use of differential layer in computing uncertaintyjupyternotebooks/phasespace/BellBS.ipynbpage 284 (continue) Example 4 with a photon counting layer and beam splitterjupyternotebooks/phasespace/singlemodesqueezerBS.ipynbpage 287 Model with single mode squeezer and beam splitter with entanglementthqml/phasespace.pypage 287 (continue) Main library with phasespace functions
Chapter 12
jupyternotebooks/bosonsamplingexample/BosonSamplingExample1.ipynbpage 305 Example 1 with boson samplingthqml/phasespace.pypage 309 (continue) Main library with phasespace functionsjupyternotebooks/bosonsamplingexample/BosonSamplingExample1.ipynbpage 310 Example 1 with boson sampling, GBS on single model coherent statejupyternotebooks/bosonsamplingexample/BosonSamplingExample2.ipynbpage 312 Example 2 with boson sampling, GBS on single mode squeezed statejupyternotebooks/bosonsamplingexample/BosonSamplingExample3.ipynbpage 314 Example 3 with boson sampling, GBS on multi-mode (two modes) coherent statesjupyternotebooks/bosonsamplingexample/BosonSamplingExample4.ipynbpage 316 Example 4 with boson sampling, GBS on multi-mode (two modes) squezed and coherent states with transform layerjupyternotebooks/bosonsamplingexample/BosonSamplingExample4b.ipynbpage 316 Example 4b with boson sampling, GBS on multi-mode (two modes) squezed and coherent states with random layerjupyternotebooks/bosonsamplingexample/BosonSamplingExample5.ipynbpage 318 Example 5 with boson sampling, GBS Haar interferometer and multimode squeezed vacuumthqml/phasespace.pypage 319 (continue) Main library with phasespace functionsjupyternotebooks/bosonsamplingexample/BosonSamplingExample6.ipynbpage 321 Example 6 with boson sampling, GBS Haar interferometer and multimode squeezed vacuum- Generates the following figures
- BosonSamplingExample6.pdf
- modelHaar.pdf
- BosonSamplingExample6ALL.pdf
- Generates the following figures
jupyternotebooks/bosonsamplingexample/BosonSamplingExample6.ipynbpage 324 (continue) Example 6 with boson sampling, GBS Haar interferometer and multimode squeezed vacuumjupyternotebooks/bosonsamplingexample/BosonSamplingExample6.ipynbpage 324 (continue) Example 6 with boson sampling, GBS Haar interferometer and multimode squeezed vacuumjupyternotebooks/bosonsamplingexample/BosonSamplingExample7.ipynbpage 329 Example 7 with boson sampling, GBS Haar and squeezer with training particle number- Generates the following figures
- modelBS7.png
- modelBS7.pdf
- BS7pairsnotraining.pdf
- BS7quaternotraining.pdf
- BS7ALLnotraining.pdf
- BS7traininghistory.pdf
- BS7pairstrained.pdf
- BS7quatertrained.pdf
- BS7ALLtrained.pdf
- Generates the following figures
jupyternotebooks/bosonsamplingexample/BosonSamplingExample8.ipynbpage 336 Example 8 with boson sampling, GBS Haar and squeezing training particle number and squeezing parametersjupyternotebooks/bosonsamplingexample/BosonSamplingExample9.ipynbpage 336 Example 9 with boson sampling, GBS Haar and squeezing training on differential particle number
Chapter 13
thqml/quantumsolitons.pypage 348 Library with functions for quantum manybody and solitonsthqml/quantumsolitons.pypage 354 (continue) Library with functions for quantum manybody and solitonsjupyternotebooks/soliton/BoseHubbardNNT.ipynbpage 356 Model for the ground state of the Bose-Hubbard Hamiltonianthqml/quantumsolitons.pypage 361 (continue) Library with functions for quantum manybody and solitonsjupyternotebooks/soliton/BoseHubbardTwinNNT.ipynbpage 362 Model Bose-Hubbard Hamiltonian with two solitonsjupyternotebooks/soliton/BoseHubbardTwinNNTVersusN.ipynbpage 362 Model Bose-Hubbard Hamiltonian with two solitons versus N
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file thqml-1.0.0.tar.gz.
File metadata
- Download URL: thqml-1.0.0.tar.gz
- Upload date:
- Size: 7.8 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7cbe1e72e0388b6f1baf1679e54f8eea7399e8a8d45d040e9550676702b0c90a
|
|
| MD5 |
46d85b591d99e928b593ddd70bf0c1bf
|
|
| BLAKE2b-256 |
9b3e7b2600d3f334760d5cb6c6cc20f4cc7e84ffc4201e7bcc9aa07ad93fab25
|
File details
Details for the file thqml-1.0.0-py3-none-any.whl.
File metadata
- Download URL: thqml-1.0.0-py3-none-any.whl
- Upload date:
- Size: 37.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4056165fd8e7fef11b4cddcee0d0ec5ac50fefb1a1ea394123a3f4878f42fabc
|
|
| MD5 |
550cfaca4d74b19551a0c91fddd14895
|
|
| BLAKE2b-256 |
7f8f5c2cd93286db66286e13f5dfc1b87b3a62977d475684cc7a209616e911cf
|