# [qW-Map: Weight Re-Mapping for Variational Quantum Circuits](https://arxiv.org/abs/2212.14807)
A PyTorch implementation of Quantum Weight Re-Mapping
<img src="figures/structure.png" alt="structure" width="300" align="right"/>
In recent years, quantum machine learning has seen a substantial increase in the use of variational quantum circuits (VQCs). VQCs are inspired by artificial neural networks, which achieve extraordinary performance in a wide range of AI tasks as massively parameterized function approximators. VQCs have already demonstrated promising results, for example, in generalization and the requirement for fewer parameters to train, by utilizing the more robust algorithmic toolbox available in quantum computing. A VQCs' trainable parameters or weights are usually used as angles in rotational gates and current gradient-based training methods do not account for that. We introduce weight re-mapping for VQCs, to unambiguously map the weights to an interval of length $2\pi$, drawing inspiration from traditional ML, where data rescaling, or normalization techniques have demonstrated tremendous benefits in many circumstances. We employ a set of five functions and evaluate them on the Iris and Wine datasets using variational classifiers as an example. Our experiments show that weight re-mapping can improve convergence in all tested settings. Additionally, we were able to demonstrate that weight re-mapping increased test accuracy for the Wine dataset by $10\%$ over using unmodified weights.
[Link to Arxiv Paper](https://arxiv.org/abs/2212.14807)
## Implemented Functions
![Implemented Functions](./figures/functions.png)
## Install
```
$ pip install qw-map
```
## Example:
```python
import pennylane as qml
from qw_map import tanh
from torch import Tensor
def circuit(ws: Tensor, x: Tensor):
qml.AngleEmbedding(x, rotation='X', wires=range(num_qubits))
qml.StronglyEntanglingLayers(tanh(ws), wires=range(num_qubits))
```
## Citation
TODO
Raw data
{
"_id": null,
"home_page": "https://github.com/michaelkoelle/quantum-weight-remapping",
"name": "qW-Map",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "quantum artificial intelligence,pytorch,quantum machine learning,weight re-mapping,quantum supervised learning,quantum variational circuit,quantum variational classifier,pennylane",
"author": "Michael K\u00f6lle",
"author_email": "michael.koelle@ifi.lmu.de",
"download_url": "https://files.pythonhosted.org/packages/86/41/19d39f63f04f1836917873b4a25d09fe97807b04ba920840b06656432a5e/qW-Map-0.1.2.tar.gz",
"platform": null,
"description": "# [qW-Map: Weight Re-Mapping for Variational Quantum Circuits](https://arxiv.org/abs/2212.14807)\n\nA PyTorch implementation of Quantum Weight Re-Mapping\n\n<img src=\"figures/structure.png\" alt=\"structure\" width=\"300\" align=\"right\"/>\n\nIn recent years, quantum machine learning has seen a substantial increase in the use of variational quantum circuits (VQCs). VQCs are inspired by artificial neural networks, which achieve extraordinary performance in a wide range of AI tasks as massively parameterized function approximators. VQCs have already demonstrated promising results, for example, in generalization and the requirement for fewer parameters to train, by utilizing the more robust algorithmic toolbox available in quantum computing. A VQCs' trainable parameters or weights are usually used as angles in rotational gates and current gradient-based training methods do not account for that. We introduce weight re-mapping for VQCs, to unambiguously map the weights to an interval of length $2\\pi$, drawing inspiration from traditional ML, where data rescaling, or normalization techniques have demonstrated tremendous benefits in many circumstances. We employ a set of five functions and evaluate them on the Iris and Wine datasets using variational classifiers as an example. Our experiments show that weight re-mapping can improve convergence in all tested settings. Additionally, we were able to demonstrate that weight re-mapping increased test accuracy for the Wine dataset by $10\\%$ over using unmodified weights.\n\n[Link to Arxiv Paper](https://arxiv.org/abs/2212.14807)\n\n## Implemented Functions\n\n![Implemented Functions](./figures/functions.png)\n\n## Install\n\n```\n$ pip install qw-map\n```\n\n## Example:\n\n```python\nimport pennylane as qml\nfrom qw_map import tanh\nfrom torch import Tensor\n\ndef circuit(ws: Tensor, x: Tensor):\n\tqml.AngleEmbedding(x, rotation='X', wires=range(num_qubits))\n qml.StronglyEntanglingLayers(tanh(ws), wires=range(num_qubits))\n```\n\n## Citation\n\nTODO\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "A PyTorch implementation of Quantum Weight Re-Mapping",
"version": "0.1.2",
"split_keywords": [
"quantum artificial intelligence",
"pytorch",
"quantum machine learning",
"weight re-mapping",
"quantum supervised learning",
"quantum variational circuit",
"quantum variational classifier",
"pennylane"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "406a90bf71c8f2e8a14702a2890d2e535bd990f0801b8e70171e30aca235b07b",
"md5": "96ec3a9950d8ef52bfb65e412b9654ca",
"sha256": "06da406a99c448b93d261303b08029758288e61a4b9c85359211a8253235a5dc"
},
"downloads": -1,
"filename": "qW_Map-0.1.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "96ec3a9950d8ef52bfb65e412b9654ca",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 3807,
"upload_time": "2023-02-07T20:26:55",
"upload_time_iso_8601": "2023-02-07T20:26:55.344223Z",
"url": "https://files.pythonhosted.org/packages/40/6a/90bf71c8f2e8a14702a2890d2e535bd990f0801b8e70171e30aca235b07b/qW_Map-0.1.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "864119d39f63f04f1836917873b4a25d09fe97807b04ba920840b06656432a5e",
"md5": "ba467696f21d3e220ad6209b2549e7fd",
"sha256": "54aca84be8d32ff659d10b5cf382e4d80cc426a1c16d53379a763bc25a1b73f1"
},
"downloads": -1,
"filename": "qW-Map-0.1.2.tar.gz",
"has_sig": false,
"md5_digest": "ba467696f21d3e220ad6209b2549e7fd",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 3804,
"upload_time": "2023-02-07T20:26:57",
"upload_time_iso_8601": "2023-02-07T20:26:57.075967Z",
"url": "https://files.pythonhosted.org/packages/86/41/19d39f63f04f1836917873b4a25d09fe97807b04ba920840b06656432a5e/qW-Map-0.1.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-02-07 20:26:57",
"github": true,
"gitlab": false,
"bitbucket": false,
"github_user": "michaelkoelle",
"github_project": "quantum-weight-remapping",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "qw-map"
}