facebookresearch / deepcluster

Deep Clustering for Unsupervised Learning of Visual Features
Other
1.68k stars 324 forks source link

Dealing with empty clusters #87

Closed dkajtoch closed 3 years ago

dkajtoch commented 3 years ago

Hello, where exactly in the code do you deal with empty clusters? I couldn't spot that part

when a cluster becomes empty, we randomly select a non-empty cluster and use its centroid with a small random perturbation as the new centroid for the empty cluster.

mathildecaron31 commented 3 years ago

Hi @dkajtoch

This is handled in faiss: https://github.com/facebookresearch/faiss/blob/b78e21aaab5ee6dd57c797c2665a3be89ba4f854/faiss/Clustering.cpp#L212-L218

dkajtoch commented 3 years ago

Thanks! This is exactly what I was looking for

mathildecaron31 commented 3 years ago

you can also take a look at my implementation in pytorch for deepercluster: https://github.com/facebookresearch/DeeperCluster/blob/d38ada109f8334f6ae4c84a218d79848a936ed6f/src/distributed_kmeans.py#L259-L279