{"id":15515988,"url":"https://github.com/subhadarship/kmeans_pytorch","last_synced_at":"2025-10-06T03:45:43.620Z","repository":{"id":36756415,"uuid":"230063490","full_name":"subhadarship/kmeans_pytorch","owner":"subhadarship","description":"kmeans using PyTorch","archived":false,"fork":false,"pushed_at":"2023-05-09T08:44:31.000Z","size":1030,"stargazers_count":514,"open_issues_count":32,"forks_count":82,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-05-08T20:51:14.255Z","etag":null,"topics":["docs","github-pages","gpu","jekylbook","jekyll","kmeans-clustering","pytorch"],"latest_commit_sha":null,"homepage":"https://subhadarship.github.io/kmeans_pytorch","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/subhadarship.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-12-25T07:43:23.000Z","updated_at":"2025-05-06T08:08:16.000Z","dependencies_parsed_at":"2024-06-18T17:00:26.795Z","dependency_job_id":"3de88f16-a4fb-4ccc-b7a9-267b3fcdb364","html_url":"https://github.com/subhadarship/kmeans_pytorch","commit_stats":{"total_commits":88,"total_committers":7,"mean_commits":"12.571428571428571","dds":"0.13636363636363635","last_synced_commit":"f7f36bd1cb4e3a761d73d584866d0a9c6b4d2805"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/subhadarship%2Fkmeans_pytorch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/subhadarship%2Fkmeans_pytorch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/subhadarship%2Fkmeans_pytorch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/subhadarship%2Fkmeans_pytorch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/subhadarship","download_url":"https://codeload.github.com/subhadarship/kmeans_pytorch/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254442854,"owners_count":22071877,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docs","github-pages","gpu","jekylbook","jekyll","kmeans-clustering","pytorch"],"created_at":"2024-10-02T10:05:16.496Z","updated_at":"2025-10-06T03:45:38.600Z","avatar_url":"https://github.com/subhadarship.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# K Means using PyTorch\nPyTorch implementation of kmeans for utilizing GPU\n\n![Alt Text](https://media.giphy.com/media/WsYIwIHHXUcuiR8BeS/giphy.gif)\n\n# Getting Started\n```\n\nimport torch\nimport numpy as np\nfrom kmeans_pytorch import kmeans\n\n# data\ndata_size, dims, num_clusters = 1000, 2, 3\nx = np.random.randn(data_size, dims) / 6\nx = torch.from_numpy(x)\n\n# kmeans\ncluster_ids_x, cluster_centers = kmeans(\n    X=x, num_clusters=num_clusters, distance='euclidean', device=torch.device('cuda:0')\n)\n```\n\nsee [`example.ipynb`](https://github.com/subhadarship/kmeans_pytorch/blob/master/example.ipynb) for a more elaborate example\n\n# Requirements\n* [PyTorch](http://pytorch.org/) version \u003e= 1.0.0\n* Python version \u003e= 3.6\n\n# Installation\n\ninstall with `pip`:\n```\npip install kmeans-pytorch\n```\n\n**Installing from source**\n\nTo install from source and develop locally:\n```\ngit clone https://github.com/subhadarship/kmeans_pytorch\ncd kmeans_pytorch\npip install --editable .\n```\n\n# CPU vs GPU\nsee [`cpu_vs_gpu.ipynb`](https://github.com/subhadarship/kmeans_pytorch/blob/master/cpu_vs_gpu.ipynb) for a comparison between CPU and GPU\n\n# Notes\n- useful when clustering large number of samples\n- utilizes GPU for faster matrix computations\n- support euclidean and cosine distances (for now)\n\n# Credits\n- This implementation closely follows the style of [this](https://github.com/overshiki/kmeans_pytorch)\n- Documentation is done using the awesome theme [jekyllbook](https://github.com/ebetica/jekyllbook)\n\n# License\n[MIT](https://github.com/subhadarship/kmeans_pytorch/blob/master/LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsubhadarship%2Fkmeans_pytorch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsubhadarship%2Fkmeans_pytorch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsubhadarship%2Fkmeans_pytorch/lists"}