fast_pytorch_kmeans

This is a pytorch implementation of k-means clustering algorithm

MIT License

Downloads
25.8K
Stars
280
Committers
5

Fast Pytorch Kmeans

this is a pytorch implementation of K-means clustering algorithm

Installation

pip install fast-pytorch-kmeans

Quick Start

from fast_pytorch_kmeans import KMeans
import torch

kmeans = KMeans(n_clusters=8, mode='euclidean', verbose=1)
x = torch.randn(100000, 64, device='cuda')
labels = kmeans.fit_predict(x)

Speed Comparison

1. n_samples=100,000, n_features=256, time spent for 100 iterations

2. n_samples=100,000, n_clusters=256, time spent for 100 iterations

3. n_features=256, n_clusters=256, time spent for 100 iterations

4. n_features=32, n_clusters=1024, time spent for 100 iterations

5. n_features=1024, n_clusters=32, time spent for 100 iterations