Quantum Machine Learning using Qibo
Project description
Qiboml
👋 Welcome to Qiboml, the quantum machine learning package of the Qibo ecosystem!
🎯 Our goal is to integrate Qibo within the most commonly used machine learning frameworks, allowing the definition and usage of quantum or hybrid classical-quantum models keeping the same high-level language proposed by the most used libraries (Pytorch, Tensorflow).
Documentation
📖 The Qiboml documentation can be found in our organization webpage.
Minimum working example
You can quickly build a QML model using one of the currently supported interfaces. For instance, to train a VQE to find the ground state of an Hamiltonian $H=\sum_i Z_i$:
from qiboml.models.ansatze import hardware_efficient
from qiboml.models.decoding import Expectation
nqubits = 2
circuit = hardware_efficient(nqubits)
# By default Expectation sets Z_0 + Z_1 + ... + Z_n as observable,
# any Hamiltonian can be used though
decoding = Expectation(nqubits)
# using pytorch
import torch
import qiboml.interfaces.pytorch as pt
pt_model = pt.QuantumModel(circuit_structure=[circuit,], decoding=decoding)
optimizer = torch.optim.Adam(pt_model.parameters(), lr=0.05)
for iteration in range(100):
optimizer.zero_grad()
cost = pt_model()
cost.backward()
optimizer.step()
# using keras
import keras
import tensorflow as tf
import qiboml.interfaces.keras as ks
tf.keras.backend.set_floatx('float64') # set the dtype to float64, which is qibo's default
ks_model = ks.QuantumModel(circuit_structure=[circuit,], decoding=decoding)
optimizer = keras.optimizers.Adam(learning_rate=0.05)
for iteration in range(100):
with tf.GradientTape() as tape:
cost = ks_model()
gradients = tape.gradient(
cost, ks_model.trainable_variables
)
optimizer.apply_gradients(zip(gradients, ks_model.trainable_variables))
Citation policy
If you use the package please refer to the documentation for citation instructions.
Contacts
To get in touch with the community and the developers, consider joining the Qibo workspace on Matrix:
If you have a question about the project, please contact us with 📫.
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 qiboml-0.1.1.tar.gz.
File metadata
- Download URL: qiboml-0.1.1.tar.gz
- Upload date:
- Size: 48.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a5f9e14dbc675b315430675ce62e89c2b75c218523a2e13921d82d757fda530e
|
|
| MD5 |
3ba62acbc099c6401f62be052962904c
|
|
| BLAKE2b-256 |
75b06b24e27b67f7eeb516fb002c6148e3bc3d43f1b56cdf304f4f71b92e82ca
|
File details
Details for the file qiboml-0.1.1-py3-none-any.whl.
File metadata
- Download URL: qiboml-0.1.1-py3-none-any.whl
- Upload date:
- Size: 63.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a43452c20352639bad73308e146a6e32951de2380b2107d5936daa596b5b8936
|
|
| MD5 |
0c5082bfa83fe2ea52e9cd5cf091706a
|
|
| BLAKE2b-256 |
cbf183e8f6302352c9bdce7c2cc8363d62e579e956be80c0e41d613ee0aa7415
|