The Power Spherical distribution
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, such as sigstore and slsa.
Overview
This library contains a Pytorch implementation of the Power Spherical distribution, as presented in [1](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 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
pip install power-spherical
Structure
- distributions: Pytorch implementation of the Power Spherical and hyperspherical Uniform distributions. Both inherit from
torch.distributions.Distribution. - examples: Example code for using the library within a PyTorch project.
Usage
Please have a look into the examples. We adapted our implementation to follow the structure of the Pytorch probability distributions.
Here a minimal example that demonstrate differentiable sampling:
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:
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 and will generate something similar to these figures below.
Please cite [1] in your work when using this library in your experiments.
Feedback
For questions and comments, feel free to contact Nicola De Cao. For questions according to the package / setup / fork, feel free to contact Andreas Fehlner
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}
}
Metadata
Release files for power-spherical 0.8.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| power_spherical-0.8.1.tar.gz | 7.6 kB | Without provenance | Details for power_spherical-0.8.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| power_spherical-0.8.1-py3-none-any.whl | Python 3 | none | any | Details for power_spherical-0.8.1-py3-none-any.whl |
Total release size: 17.0 kB
Release files / power_spherical-0.8.1.tar.gz
| Download URL | power_spherical-0.8.1.tar.gz |
|---|---|
| Size | 7.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
72dbe2a8436b5a693b4f6fdd0f60e37f9509218531f623bd57ea9fec155cf4ae
|
|
BLAKE2b-256 checksum How to use checksums |
b6442fe941d76e8b13ff96122fc2e529e2ca93690a0b34f991989743ed269628
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/5.0.0 CPython/3.12.3
|
Release files / power_spherical-0.8.1-py3-none-any.whl
| Download URL | power_spherical-0.8.1-py3-none-any.whl |
|---|---|
| Size | 9.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ebd793c0213babe2acc11d8971b314e51c1f14c1c2f84902cf1c9d60080023b6
|
|
BLAKE2b-256 checksum How to use checksums |
d6eebd0e02b9fc8a8a2b5afef00c257f7235ecc11e0003caab11fde13df2fcfc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/5.0.0 CPython/3.12.3
|
Security for power-spherical 0.8.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.