torchist


Nametorchist JSON
Version 0.1.5 PyPI version JSON
download
home_pagehttps://github.com/francois-rozet/torchist
SummaryNumPy-style histograms in PyTorch
upload_time2021-05-04 18:55:08
maintainer
docs_urlNone
authorFrançois Rozet
requires_python>=3.6
license
keywords pytorch histogram
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # NumPy-style histograms in PyTorch

The `torchist` package implements NumPy's [`histogram`](https://numpy.org/doc/stable/reference/generated/numpy.histogram.html) and [`histogramdd`](https://numpy.org/doc/stable/reference/generated/numpy.histogramdd.html) functions in PyTorch with support for non-uniform binning. The package also features implementations of [`ravel_multi_index`](https://numpy.org/doc/stable/reference/generated/numpy.ravel_multi_index.html), [`unravel_index`](https://numpy.org/doc/stable/reference/generated/numpy.unravel_index.html) and some useful functionals (e.g. KL divergence).

## Installation

The `torchist` package is available on [PyPI](https://pypi.org/project/torchist/), which means it is installable with `pip`:

```bash
pip install torchist
```

Alternatively, if you need the latest features, you can install it using

```bash
pip install git+https://github.com/francois-rozet/torchist
```

or copy the package directly to your project, with

```bash
git clone https://github.com/francois-rozet/torchist
cp -R torchist/torchist <path/to/project>/torchist
```

## Getting Started

```python
import torch
import torchist

x = torch.rand(100, 3).cuda()

hist = torchist.histogramdd(x, bins=10, low=0., upp=1.)

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.

```cmd
$ 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
```



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/francois-rozet/torchist",
    "name": "torchist",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": "",
    "keywords": "pytorch histogram",
    "author": "Fran\u00e7ois Rozet",
    "author_email": "francois.rozet@outlook.com",
    "download_url": "https://files.pythonhosted.org/packages/23/a1/20ee0618441e068a010df50d36fc4e475876e0f1e2c3665e67089d72206e/torchist-0.1.5.tar.gz",
    "platform": "",
    "description": "# NumPy-style histograms in PyTorch\n\nThe `torchist` package implements NumPy's [`histogram`](https://numpy.org/doc/stable/reference/generated/numpy.histogram.html) and [`histogramdd`](https://numpy.org/doc/stable/reference/generated/numpy.histogramdd.html) functions in PyTorch with support for non-uniform binning. The package also features implementations of [`ravel_multi_index`](https://numpy.org/doc/stable/reference/generated/numpy.ravel_multi_index.html), [`unravel_index`](https://numpy.org/doc/stable/reference/generated/numpy.unravel_index.html) and some useful functionals (e.g. KL divergence).\n\n## Installation\n\nThe `torchist` package is available on [PyPI](https://pypi.org/project/torchist/), which means it is installable with `pip`:\n\n```bash\npip install torchist\n```\n\nAlternatively, if you need the latest features, you can install it using\n\n```bash\npip install git+https://github.com/francois-rozet/torchist\n```\n\nor copy the package directly to your project, with\n\n```bash\ngit clone https://github.com/francois-rozet/torchist\ncp -R torchist/torchist <path/to/project>/torchist\n```\n\n## Getting Started\n\n```python\nimport torch\nimport torchist\n\nx = torch.rand(100, 3).cuda()\n\nhist = torchist.histogramdd(x, bins=10, low=0., upp=1.)\n\nprint(hist.shape)  # (10, 10, 10)\n```\n\n## Benchmark\n\nThe implementations of `torchist` are on par or faster than those of `numpy` on CPU and benefit greately from CUDA capabilities.\n\n```cmd\n$ python torchist/__init__.py\nCPU\n---\nnp.histogram : 1.2559 s\nnp.histogramdd : 20.7816 s\nnp.histogram (non-uniform) : 5.4878 s\nnp.histogramdd (non-uniform) : 17.3757 s\ntorchist.histogram : 1.3975 s\ntorchist.histogramdd : 9.6160 s\ntorchist.histogram (non-uniform) : 5.0883 s\ntorchist.histogramdd (non-uniform) : 17.2743 s\n\nCUDA\n----\ntorchist.histogram : 0.1363 s\ntorchist.histogramdd : 0.3754 s\ntorchist.histogram (non-uniform) : 0.1355 s\ntorchist.histogramdd (non-uniform) : 0.5137 s\n```\n\n\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "NumPy-style histograms in PyTorch",
    "version": "0.1.5",
    "split_keywords": [
        "pytorch",
        "histogram"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "af3cfb1d65b57d6f3a223d94e685f4b1",
                "sha256": "0a25410e2aad5d33ef8a7028a69b8b77a66abbc373d6886548fd42a2d07b5ea6"
            },
            "downloads": -1,
            "filename": "torchist-0.1.5-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "af3cfb1d65b57d6f3a223d94e685f4b1",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 7971,
            "upload_time": "2021-05-04T18:55:06",
            "upload_time_iso_8601": "2021-05-04T18:55:06.431803Z",
            "url": "https://files.pythonhosted.org/packages/f6/2a/2d8174acfcc12d4660d855f9f90acd25a26860631b1142a92bccd8c212aa/torchist-0.1.5-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "md5": "670d500cf26a31891591415e0d90d846",
                "sha256": "d57bec6302f1a5c2da741a184b097ea3769e4dd2baf4b8036ef9cd602ff4c1dc"
            },
            "downloads": -1,
            "filename": "torchist-0.1.5.tar.gz",
            "has_sig": false,
            "md5_digest": "670d500cf26a31891591415e0d90d846",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 7338,
            "upload_time": "2021-05-04T18:55:08",
            "upload_time_iso_8601": "2021-05-04T18:55:08.523179Z",
            "url": "https://files.pythonhosted.org/packages/23/a1/20ee0618441e068a010df50d36fc4e475876e0f1e2c3665e67089d72206e/torchist-0.1.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2021-05-04 18:55:08",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": null,
    "github_project": "francois-rozet",
    "error": "Could not fetch GitHub repository",
    "lcname": "torchist"
}
        
Elapsed time: 0.23537s