power-spherical


Namepower-spherical JSON
Version 0.8.1 PyPI version JSON
download
home_pagehttps://github.com/andife/power_spherical
SummaryPytorch implementation of the Power Spherical distribution
upload_time2024-05-18 07:40:37
maintainerAndreas Fehlner
docs_urlNone
authorNicola De Cao
requires_python<4.0,>=3.9
licenseMIT
keywords pytorch machine-learning deep-learning manifold-learning
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <!--
SPDX-FileCopyrightText: 2020-2023 Nicola De Cao
SPDX-FileCopyrightText: 2024 Andreas Fehlner

SPDX-License-Identifier: MIT
-->

# The Power Spherical distribution

[![REUSE status](https://api.reuse.software/badge/github.com/andife/power_spherical/)](https://api.reuse.software/info/github.com/andife/power_spherical/)
[![SLSA 3](https://slsa.dev/images/gh-badge-level3.svg)](https://slsa.dev)

## Fork
*This fork was made to create a wheel for pypi (in the context of which the setup was also changed/updated to pyproject.toml and poetry) and to introduce good practices in [supply chain security](https://github.com/andife/power_spherical/blob/master/artifact-authenticity.md), such as sigstore and slsa.*

## Overview
This library contains a Pytorch implementation of the Power Spherical distribution, as presented in [[1]](#citation)(https://arxiv.org/abs/2006.04437).

## Dependencies

* **python>=3.9**
* **pytorch>=2.0**: https://pytorch.org

*Notice that older version could work but they were not tested.*

Optional dependency for [examples](https://github.com/andife/power_spherical/blob/master/example.ipynb) needed for plotting and numerical checks (again older version could work but they were not tested):
* **numpy>=1.18.1**: https://numpy.org
* **matplotlib>=3.1.1**: https://matplotlib.org
* **quadpy>=0.14.11**: https://pypi.org/project/quadpy

## Installation

To install, run

```bash
pip install power-spherical
```

## Structure
* [distributions](https://github.com/andife/power_spherical/blob/master/power_spherical/distributions.py): Pytorch implementation of the Power Spherical and hyperspherical Uniform distributions. Both inherit from `torch.distributions.Distribution`.
* [examples](https://github.com/andife/power_spherical/blob/master/example.ipynb): Example code for using the library within a PyTorch project.

## Usage
Please have a look into the [examples](https://github.com/andife/power_spherical/blob/master/example.ipynb). We adapted our implementation to follow the structure of the [Pytorch probability distributions](https://pytorch.org/docs/stable/distributions.html).

Here a minimal example that demonstrate differentiable sampling:
```python
import torch
from power_spherical import PowerSpherical
p = PowerSpherical(
      loc=torch.tensor([0., 1.], requires_grad=True),
      scale=torch.tensor(4., requires_grad=True),
    )
p.rsample()
```




    tensor([-0.3820,  0.9242], grad_fn=<SubBackward0>)
    
and computing KL divergence with the uniform distribution:
```python
from power_spherical import HypersphericalUniform
q = HypersphericalUniform(dim=2)
torch.distributions.kl_divergence(p, q)
```




    tensor(1.2486, grad_fn=<AddBackward0>)

Examples of 2D and 3D plots are show in [examples](https://github.com/nicola-decao/power_spherical/blob/master/example.ipynb) and will generate something similar to these figures below.
<p align="center">
  <img class="paper_logo" src="https://i.imgur.com/4iITHS5.png" width=40%>
  <img class="paper_logo" src="https://i.imgur.com/zXZWr9H.png" width=40%>
</p>

Please cite [[1](#citation)] in your work when using this library in your experiments.

## Feedback
For questions and comments, feel free to contact [Nicola De Cao](mailto:nicola.decao@gmail.com).
For questions according to the package / setup / fork, feel free to contact [Andreas Fehlner](mailto:fehlner@arcor.de)

## License
MIT

## Citation
```
[1] De Cao, N., Aziz, W. (2020). 
The Power Spherical distrbution.
In Proceedings of the 37th International 
Conference on Machine Learning, INNF+.
```

BibTeX format:
```
@article{decao2020power,
  title={The Power Spherical distrbution},
  author={
    De Cao, Nicola and
    Aziz, Wilker},
  journal={Proceedings of the 37th International Conference on Machine Learning, INNF+},
  year={2020}
}
```



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/andife/power_spherical",
    "name": "power-spherical",
    "maintainer": "Andreas Fehlner",
    "docs_url": null,
    "requires_python": "<4.0,>=3.9",
    "maintainer_email": "fehlner@arcor.de",
    "keywords": "pytorch, machine-learning, deep-learning, manifold-learning",
    "author": "Nicola De Cao",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/b6/44/2fe941d76e8b13ff96122fc2e529e2ca93690a0b34f991989743ed269628/power_spherical-0.8.1.tar.gz",
    "platform": null,
    "description": "<!--\nSPDX-FileCopyrightText: 2020-2023 Nicola De Cao\nSPDX-FileCopyrightText: 2024 Andreas Fehlner\n\nSPDX-License-Identifier: MIT\n-->\n\n# The Power Spherical distribution\n\n[![REUSE status](https://api.reuse.software/badge/github.com/andife/power_spherical/)](https://api.reuse.software/info/github.com/andife/power_spherical/)\n[![SLSA 3](https://slsa.dev/images/gh-badge-level3.svg)](https://slsa.dev)\n\n## Fork\n*This fork was made to create a wheel for pypi (in the context of which the setup was also changed/updated to pyproject.toml and poetry) and to introduce good practices in [supply chain security](https://github.com/andife/power_spherical/blob/master/artifact-authenticity.md), such as sigstore and slsa.*\n\n## Overview\nThis library contains a Pytorch implementation of the Power Spherical distribution, as presented in [[1]](#citation)(https://arxiv.org/abs/2006.04437).\n\n## Dependencies\n\n* **python>=3.9**\n* **pytorch>=2.0**: https://pytorch.org\n\n*Notice that older version could work but they were not tested.*\n\nOptional dependency for [examples](https://github.com/andife/power_spherical/blob/master/example.ipynb) needed for plotting and numerical checks (again older version could work but they were not tested):\n* **numpy>=1.18.1**: https://numpy.org\n* **matplotlib>=3.1.1**: https://matplotlib.org\n* **quadpy>=0.14.11**: https://pypi.org/project/quadpy\n\n## Installation\n\nTo install, run\n\n```bash\npip install power-spherical\n```\n\n## Structure\n* [distributions](https://github.com/andife/power_spherical/blob/master/power_spherical/distributions.py): Pytorch implementation of the Power Spherical and hyperspherical Uniform distributions. Both inherit from `torch.distributions.Distribution`.\n* [examples](https://github.com/andife/power_spherical/blob/master/example.ipynb): Example code for using the library within a PyTorch project.\n\n## Usage\nPlease have a look into the [examples](https://github.com/andife/power_spherical/blob/master/example.ipynb). We adapted our implementation to follow the structure of the [Pytorch probability distributions](https://pytorch.org/docs/stable/distributions.html).\n\nHere a minimal example that demonstrate differentiable sampling:\n```python\nimport torch\nfrom power_spherical import PowerSpherical\np = PowerSpherical(\n      loc=torch.tensor([0., 1.], requires_grad=True),\n      scale=torch.tensor(4., requires_grad=True),\n    )\np.rsample()\n```\n\n\n\n\n    tensor([-0.3820,  0.9242], grad_fn=<SubBackward0>)\n    \nand computing KL divergence with the uniform distribution:\n```python\nfrom power_spherical import HypersphericalUniform\nq = HypersphericalUniform(dim=2)\ntorch.distributions.kl_divergence(p, q)\n```\n\n\n\n\n    tensor(1.2486, grad_fn=<AddBackward0>)\n\nExamples of 2D and 3D plots are show in [examples](https://github.com/nicola-decao/power_spherical/blob/master/example.ipynb) and will generate something similar to these figures below.\n<p align=\"center\">\n  <img class=\"paper_logo\" src=\"https://i.imgur.com/4iITHS5.png\" width=40%>\n  <img class=\"paper_logo\" src=\"https://i.imgur.com/zXZWr9H.png\" width=40%>\n</p>\n\nPlease cite [[1](#citation)] in your work when using this library in your experiments.\n\n## Feedback\nFor questions and comments, feel free to contact [Nicola De Cao](mailto:nicola.decao@gmail.com).\nFor questions according to the package / setup / fork, feel free to contact [Andreas Fehlner](mailto:fehlner@arcor.de)\n\n## License\nMIT\n\n## Citation\n```\n[1] De Cao, N., Aziz, W. (2020). \nThe Power Spherical distrbution.\nIn Proceedings of the 37th International \nConference on Machine Learning, INNF+.\n```\n\nBibTeX format:\n```\n@article{decao2020power,\n  title={The Power Spherical distrbution},\n  author={\n    De Cao, Nicola and\n    Aziz, Wilker},\n  journal={Proceedings of the 37th International Conference on Machine Learning, INNF+},\n  year={2020}\n}\n```\n\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Pytorch implementation of the Power Spherical distribution",
    "version": "0.8.1",
    "project_urls": {
        "Homepage": "https://github.com/andife/power_spherical",
        "Repository": "https://github.com/andife/power_spherical"
    },
    "split_keywords": [
        "pytorch",
        " machine-learning",
        " deep-learning",
        " manifold-learning"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d6eebd0e02b9fc8a8a2b5afef00c257f7235ecc11e0003caab11fde13df2fcfc",
                "md5": "3e99958dd10d3661b38680bbe63413bb",
                "sha256": "ebd793c0213babe2acc11d8971b314e51c1f14c1c2f84902cf1c9d60080023b6"
            },
            "downloads": -1,
            "filename": "power_spherical-0.8.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "3e99958dd10d3661b38680bbe63413bb",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.9",
            "size": 9414,
            "upload_time": "2024-05-18T07:40:36",
            "upload_time_iso_8601": "2024-05-18T07:40:36.016011Z",
            "url": "https://files.pythonhosted.org/packages/d6/ee/bd0e02b9fc8a8a2b5afef00c257f7235ecc11e0003caab11fde13df2fcfc/power_spherical-0.8.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b6442fe941d76e8b13ff96122fc2e529e2ca93690a0b34f991989743ed269628",
                "md5": "15386290f1f5ecd207e9b26e99ad2664",
                "sha256": "72dbe2a8436b5a693b4f6fdd0f60e37f9509218531f623bd57ea9fec155cf4ae"
            },
            "downloads": -1,
            "filename": "power_spherical-0.8.1.tar.gz",
            "has_sig": false,
            "md5_digest": "15386290f1f5ecd207e9b26e99ad2664",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.9",
            "size": 7627,
            "upload_time": "2024-05-18T07:40:37",
            "upload_time_iso_8601": "2024-05-18T07:40:37.610334Z",
            "url": "https://files.pythonhosted.org/packages/b6/44/2fe941d76e8b13ff96122fc2e529e2ca93690a0b34f991989743ed269628/power_spherical-0.8.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-05-18 07:40:37",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "andife",
    "github_project": "power_spherical",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "power-spherical"
}
        
Elapsed time: 0.24450s