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/
graphviz
https://graphviz.gitlab.io/download for plot_model to work
Installation by pip and Python Package Index (https://pypi.org/project/thqml/1.0.0/)
pip install thqml
The user 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
If you use ThQML in your research, please cite the book.
See the references in thqml.bib
- python 3.10.12
- tensorflow 2.11.0
- matplotlib 3.7.2
- numpy 1.24.3
.
├── 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
See the book Quantum Machine Learning
jupyternotebooks/quantumfeaturemap/kernelexample.ipynb
Page 13 Example of generation of dataset and withscikit-lean
jupyternotebooks/quantumfeaturemap/coherentstate.ipynb
Page 33 Feature mapping by coherent statejupyternotebooks/quantumfeaturemap/squeezedvacuum.ipynb
page 38 feature mapping by squeezed state
jupyternotebooks/quantumfeaturemap/QubitsMap.ipynb
page 52 defining Qubits in TensorFlowjupyternotebooks/quantumfeaturemap/TensorsAndVectors.ipynb
page 56 defining and manipulating tensors and vectorsthqml/quantummap.py
page 61 main library with qubit functionsjupyternotebooks/quantumfeaturemap/QubitsMap.ipynb
page 61 (continue) qubits feature mappingjupyternotebooks/quantumfeaturemap/QubitsGym.ipynb
page 64 more on qubits and tensorsthqml/quantummap.py
page 68 (continue) main library with qubit functionsjupyternotebooks/quantumfeaturemap/QubitsMap.ipynb
page 74 (continue) qubits feature mappingjupyternotebooks/quantumfeaturemap/QuantumKernelMachineQubits.ipynb
page 79 quantum kernel machine with qubits
jupyternotebooks/quantumfeaturemap/SingleQubitTransverseFieldIsing.ipynb
page 89 Transverse Field Ising Model with a Single Qubitmathematica/SingleQubitTransverseIsing.nb
MATHEMATICA page 90 Analytical results on the single qubit transverse field Ising modeljupyternotebooks/quantumfeaturemap/SingleQubitTransverseFieldIsing.ipynb
page 92 (continue) Transverse Field Ising Model with a Single Qubitjupyternotebooks/quantumfeaturemap/SingleQubitTransverseFieldIsing.ipynb
page 99 (continue) Transverse Field Ising Model with a Single Qubit
mathematica/TwoQubitTransverseIsing.nb
MATHEMATICA page 104 Analytical results on the two-qubit transverse field Ising modelmathematica/TwoQubitTransverseIsing.nb
MATHEMATICA page 105 (continue) Analytical results on the two-qubit transverse field Ising modeljupyternotebooks/quantumfeaturemap/QubitsDensityMatrix.ipynb
page 114 Computing the density matrix with qubitsjupyternotebooks/quantumfeaturemap/QubitsDensityMatrix.ipynb
page 118 (continue) Computing the density matrix with qubitsjupyternotebooks/quantumfeaturemap/QubitsDensityMatrix.ipynb
page 132 (continue) Computing the density matrix with qubitsmathematica/TwoQubitTransverseIsing.nb
MATHEMATICA page 133 (continue) Analytical results on the two-qubit transverse field Ising model
jupyternotebooks/quantumfeaturemap/TwoQubitTransverseFieldIsing.ipynb
page 139 Transverse Field Ising Model with Two Qubitjupyternotebooks/quantumfeaturemap/QAOATwoQubitTransverseFieldIsing.ipynb
page 152 Transverse Field Ising Model with Two Qubit with Quantum Approximation Optimization Algorithmjupyternotebooks/quantumfeaturemap/QuantumNeuralStateTwoQubitTransverseFieldIsing.ipynb
page 157 Transverse Field Ising Model with Two Qubit with Quantum Neural State
matlabsymbolic/test_Rqpm.m
MATLAB page 188 Symbolic relations of projection matricesjupyternotebooks/phasespace/symplectic.ipynb
page 189 Test of projection matrices in jupyterthqml/phasespace.py
page 190 main library with phasespace functionsthqml/phasespace.py
page 191 (continue) main library with phasespace functions
thqml/phasespace.py
page 196 (continue) main library with phasespace functionsthqml/phasespace.py
page 199 (continue) main library with phasespace functionsjupyternotebooks/phasespace/testGaussianLayer.ipynb
page 199 Test of the Gaussian layerjupyternotebooks/phasespace/testGaussianLayer.ipynb
page 200 (continue) Test of the Gaussian layerthqml/phasespace.py
page 205 (continue) main library with phasespace functionsjupyternotebooks/phasespace/coherent.ipynb
page 209 Neural network representation of a coherent statethqml/phasespace.py
page 210 (continue) main library with phasespace functions
jupyternotebooks/phasespace/coherent.ipynb
page 216 (continue) Neural network representation of a coherent statejupyternotebooks/phasespace/coherentcomplex.ipynb
page 217 Coherent state in a complex mediumjupyternotebooks/phasespace/coherentcomplex.ipynb
page 219 (continue) Coherent state in a complex mediumjupyternotebooks/phasespace/coherentcomplextraining.ipynb
page 219 Coherent state in a complex medium with trainingjupyternotebooks/phasespace/coherentcomplextraining.ipynb
page 221 (continue) Coherent state in a complex medium with trainingjupyternotebooks/phasespace/coherentcomplextraining.ipynb
page 222 (continue) Coherent state in a complex medium with trainingjupyternotebooks/phasespace/coherentcomplextrainingDER.ipynb
page 225 Coherent state in a complex medium with training with derivativesthqml/phasespace.py
page 226 (continue) main library with phasespace functionsjupyternotebooks/phasespace/coherentcomplextrainingCOV.ipynb
page 227 Coherent state in a complex medium with training with covariancejupyternotebooks/phasespace/twolayersreservoir.ipynb
page 230 Two trainable interferometer and a reservoirthqml/phasespace.py
page 231 (continue) Main library with phasespace functionsjupyternotebooks/phasespace/phasemodulator.ipynb
page 232 Phase modulator model
matlabsymbolic/squeezeoperator.m
MATLAB page 237 Matrix representation of the squeeze operator in MATLABjupyternotebooks/phasespace/singlemodesquezer.ipynb
page 237 Single-mode squeezer modelthqml/phasespace.py
page 238 (continue) Main library with phasespace functionsjupyternotebooks/phasespace/singlemodesquezer.ipynb
page 240 (continue) Single-mode squeezer modeljupyternotebooks/phasespace/singlemodesquezer.ipynb
page 243 (continue) Single-mode squeezer modelmatlabsymbolic/squeezeoperator.m
MATLAB page 244 Matrix representation of the two-mode squeeze operator in MATLABthqml/phasespace.py
page 245 (continue) Main library with phasespace functionsjupyternotebooks/phasespace/twomodesquezer.ipynb
page 247 Two-mode squeezer modelmatlabsymbolic/beamsplitter.m
MATLAB page 248 Matrix representation of the beam splitter operator in MATLABthqml/phasespace.py
page 248 (continue) Main library with phasespace functionsjupyternotebooks/phasespace/beamsplitter.ipynb
page 251 Beam splitter modelthqml/phasespace.py
page 251 (continue) Main library with phasespace functionsjupyternotebooks/phasespace/photoncountinglayer.ipynb
page 252 Example 1 with a photon counting layerjupyternotebooks/phasespace/BellBS.ipynb
page 254 Example 2 with a photon counting layerjupyternotebooks/phasespace/photoncounting.ipynb
page 254 Example 3 with a photon counting layerjupyternotebooks/phasespace/BellBS.ipynb
page 255 (continue) Example 4 with a photon counting layer and beam splitter
thqml/phasespace.py
page 263 (continue) Main library with phasespace functionsjupyternotebooks/phasespace/uncertainty.ipynb
page 264 Example in using Laplacian layer for computing uncertaintythqml/phasespace.py
page 265 (continue) Main library with phasespace functionsjupyternotebooks/phasespace/uncertainty.ipynb
page 267 (continue) Example in using Laplacian layer for computing uncertaintythqml/phasespace.py
page 267 (continue) Main library with phasespace functionsjupyternotebooks/phasespace/uncertainty.ipynb
page 269 (continue) Example in using Laplacian layer for computing uncertaintyjupyternotebooks/phasespace/uncertainty.ipynb
page 272 (continue) Example in using Laplacian layer for computing uncertaintymathematica/noncommutative.nb
MATHEMATICA page 275 Mathematica example on non commutative operatorsmathematica/tensorgaussian.nb
MATHEMATICA page 276 Mathematica example on tensors for Gaussian statesthqml/phasespace.py
page 279 (continue) Main library with phasespace functionsjupyternotebooks/phasespace/differentiallayer.ipynb
page 282 Example of use of differential layer in computing uncertaintyjupyternotebooks/phasespace/BellBS.ipynb
page 284 (continue) Example 4 with a photon counting layer and beam splitterjupyternotebooks/phasespace/singlemodesqueezerBS.ipynb
page 287 Model with single mode squeezer and beam splitter with entanglementthqml/phasespace.py
page 287 (continue) Main library with phasespace functions
jupyternotebooks/bosonsamplingexample/BosonSamplingExample1.ipynb
page 305 Example 1 with boson samplingthqml/phasespace.py
page 309 (continue) Main library with phasespace functionsjupyternotebooks/bosonsamplingexample/BosonSamplingExample1.ipynb
page 310 Example 1 with boson sampling, GBS on single model coherent statejupyternotebooks/bosonsamplingexample/BosonSamplingExample2.ipynb
page 312 Example 2 with boson sampling, GBS on single mode squeezed statejupyternotebooks/bosonsamplingexample/BosonSamplingExample3.ipynb
page 314 Example 3 with boson sampling, GBS on multi-mode (two modes) coherent statesjupyternotebooks/bosonsamplingexample/BosonSamplingExample4.ipynb
page 316 Example 4 with boson sampling, GBS on multi-mode (two modes) squezed and coherent states with transform layerjupyternotebooks/bosonsamplingexample/BosonSamplingExample4b.ipynb
page 316 Example 4b with boson sampling, GBS on multi-mode (two modes) squezed and coherent states with random layerjupyternotebooks/bosonsamplingexample/BosonSamplingExample5.ipynb
page 318 Example 5 with boson sampling, GBS Haar interferometer and multimode squeezed vacuumthqml/phasespace.py
page 319 (continue) Main library with phasespace functionsjupyternotebooks/bosonsamplingexample/BosonSamplingExample6.ipynb
page 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.ipynb
page 324 (continue) Example 6 with boson sampling, GBS Haar interferometer and multimode squeezed vacuumjupyternotebooks/bosonsamplingexample/BosonSamplingExample6.ipynb
page 324 (continue) Example 6 with boson sampling, GBS Haar interferometer and multimode squeezed vacuumjupyternotebooks/bosonsamplingexample/BosonSamplingExample7.ipynb
page 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.ipynb
page 336 Example 8 with boson sampling, GBS Haar and squeezing training particle number and squeezing parametersjupyternotebooks/bosonsamplingexample/BosonSamplingExample9.ipynb
page 336 Example 9 with boson sampling, GBS Haar and squeezing training on differential particle number
thqml/quantumsolitons.py
page 348 Library with functions for quantum manybody and solitonsthqml/quantumsolitons.py
page 354 (continue) Library with functions for quantum manybody and solitonsjupyternotebooks/soliton/BoseHubbardNNT.ipynb
page 356 Model for the ground state of the Bose-Hubbard Hamiltonianthqml/quantumsolitons.py
page 361 (continue) Library with functions for quantum manybody and solitonsjupyternotebooks/soliton/BoseHubbardTwinNNT.ipynb
page 362 Model Bose-Hubbard Hamiltonian with two solitonsjupyternotebooks/soliton/BoseHubbardTwinNNTVersusN.ipynb
page 362 Model Bose-Hubbard Hamiltonian with two solitons versus N