Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bad default parameters! #42

Open
fawazsammani opened this issue Feb 5, 2024 · 4 comments
Open

bad default parameters! #42

fawazsammani opened this issue Feb 5, 2024 · 4 comments

Comments

@fawazsammani
Copy link

fawazsammani commented Feb 5, 2024

can i know why on earth does the stable release have by default the number of k-means iterations as infinite, and assumes the condition of breaking the loop will be met??? You caused my GPU to run k-means infinitely for a single sample without breaking, for the whole weekend, and wasted 2 days of running experiments!

Either publish reliable code or don't touch your keyboard

@XA23i
Copy link

XA23i commented Mar 1, 2024

I got the same problem, and it just got stuck at the while loop.

@XA23i
Copy link

XA23i commented Mar 1, 2024

have you fixed it yet?

@fawazsammani
Copy link
Author

fawazsammani commented Mar 1, 2024

@XA23i I installed the dev:
pip install git+https://github.com/subhadarship/kmeans_pytorch.git

Then you can specify the iteration limits:
cluster_ids, cluster_centers = kmeans(X, num_clusters=K, distance='euclidean', device=device, tqdm_flag = False, iter_limit = 500)

However, I really do not recommend using his code, as its not reliable. You never know what other problems there are. I found out (too late unfortunately) that meta offers a very efficient library called faiss. You can use k-means very simply:

kmeans = faiss.Kmeans(X, k=K, niter=500, nredo=10)
kmeans.train(X.astype(np.float32))
distances, cluster_ids = kmeans.index.search(X, 1)

@XA23i
Copy link

XA23i commented Mar 1, 2024

Thank you, I'll try it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants