Skip to main content

A small library for quick fitting of multiple Gaussian Mixture Models in parallel on the GPU.

Project description

gmm_gpu

Documentation

A small library for quick fitting of multiple instances of Gaussian Mixture Models in parallel on the GPU.

This may be useful if you have a large number of independent small problems and you want to fit a GMM on each one. You can create a single large 3D tensor (three dimensional matrix) with the data for all your instances (i.e. a batch) and then send the tensor to the GPU and process the whole batch in parallel. This would work best if all the instances have roughly the same number of points.

If you have a single big problem (one GMM instance with many points) that you want to fit using the GPU, maybe Pomegranate would be a better option.

Installation

$ pip install gmm-gpu

Example usage:

Import pytorch and the GMM class

>>> from gmm_gpu.gmm import GMM
>>> import pytorch

Generate some test data: We create a batch of 1000 instances, each with 200 random points. Half of the points are sampled from distribution centered at the origin (0, 0) and the other half from a distribution centered at (1.5, 1.5).

>>> X1 = torch.randn(1000, 100, 2)
>>> X2 = torch.randn(1000, 100, 2) + torch.tensor([1.5, 1.5])
>>> X = torch.cat([X1, X2], dim=1)

Fit the model:

>>> gmm = GMM(n_components=2, device='cuda')
>>> gmm.fit(X)

Predict the components: This will return a matrix with shape (1000, 200) where each value is the predicted component for the point.

>>> gmm.predict(X)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gmm_gpu-0.1.13.tar.gz (7.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gmm_gpu-0.1.13-py3-none-any.whl (8.1 kB view details)

Uploaded Python 3

File details

Details for the file gmm_gpu-0.1.13.tar.gz.

File metadata

  • Download URL: gmm_gpu-0.1.13.tar.gz
  • Upload date:
  • Size: 7.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.9.20 Linux/5.15.133.1-microsoft-standard-WSL2

File hashes

Hashes for gmm_gpu-0.1.13.tar.gz
Algorithm Hash digest
SHA256 98dd40c31f63a6f3ec0e1aa9aa48d47d90f199fbbba8a1d2252bf73d9a228a86
MD5 4b2551c24fa5a432bfb8361d731f2c55
BLAKE2b-256 f1f2b40ec92bf327ce3e8e1a43983acd13e2bd5d1ce5bb69b4dcf45482759509

See more details on using hashes here.

File details

Details for the file gmm_gpu-0.1.13-py3-none-any.whl.

File metadata

  • Download URL: gmm_gpu-0.1.13-py3-none-any.whl
  • Upload date:
  • Size: 8.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.9.20 Linux/5.15.133.1-microsoft-standard-WSL2

File hashes

Hashes for gmm_gpu-0.1.13-py3-none-any.whl
Algorithm Hash digest
SHA256 6e452bb0ef305a2eb580e3140df2e1be80db5b1a245cc103d4ab47fea6d9e75f
MD5 0e6c0f1d5042b14114252398b95738c4
BLAKE2b-256 76742dacd6d405e8d5a71954cc37f301d23f0e9ec686841f53142c60137c4692

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page