NumPy-style histograms in PyTorch
Project description
NumPy-style histograms in PyTorch
The torchist
package implements NumPy's histogram
and histogramdd
functions in PyTorch with CUDA support. The package also features implementations of ravel_multi_index
, unravel_index
and some useful functionals like entropy
or kl_divergence
.
Installation
The torchist
package is available on PyPI, which means it is installable with pip
.
pip install torchist
Alternatively, if you need the latest features, you can install it from the repository.
pip install git+https://github.com/francois-rozet/torchist
Getting Started
import torch
import torchist
x = torch.rand(100, 3).cuda()
hist = torchist.histogramdd(x, bins=10, low=0.0, upp=1.0)
print(hist.shape) # (10, 10, 10)
Benchmark
The implementations of torchist
are on par or faster than those of numpy
on CPU and benefit greately from CUDA capabilities.
$ python torchist/__init__.py
CPU
---
np.histogram : 1.2559 s
np.histogramdd : 20.7816 s
np.histogram (non-uniform) : 5.4878 s
np.histogramdd (non-uniform) : 17.3757 s
torchist.histogram : 1.3975 s
torchist.histogramdd : 9.6160 s
torchist.histogram (non-uniform) : 5.0883 s
torchist.histogramdd (non-uniform) : 17.2743 s
CUDA
----
torchist.histogram : 0.1363 s
torchist.histogramdd : 0.3754 s
torchist.histogram (non-uniform) : 0.1355 s
torchist.histogramdd (non-uniform) : 0.5137 s
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
File details
Details for the file torchist-0.2.1.tar.gz
.
File metadata
- Download URL: torchist-0.2.1.tar.gz
- Upload date:
- Size: 8.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 632af3e07e605312f429c35bb0f665f2a8d1ff11ac6fdf0ab02dadeddbef0cfb |
|
MD5 | d1a99dfa136fa30ba09b988f89f73488 |
|
BLAKE2b-256 | c262e044d67ef660a4150baea461b92e1e0498cea16497ba62a93eb128726f39 |
File details
Details for the file torchist-0.2.1-py3-none-any.whl
.
File metadata
- Download URL: torchist-0.2.1-py3-none-any.whl
- Upload date:
- Size: 7.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ecd83a5f7b13a6d5d3ea06b5fdf6aad6a4dc1306d8faf0fd563544b386ca9cb9 |
|
MD5 | d528e4d1b783f293d3677bc2bbfa33db |
|
BLAKE2b-256 | 791d3dfc5dacb1ae2e727d77d9ce1157fffe1dcbf3a9ae6bbefda6d37e4773f2 |