kmeans_pytorch icon indicating copy to clipboard operation
kmeans_pytorch copied to clipboard

Does not work with 2D, 3D features

Open morawi opened this issue 4 years ago • 1 comments

How to set the num_features?

morawi avatar Feb 09 '21 14:02 morawi

I gave the code a go, since I was iterating over K=1,..., n; seems that K=1 was the source of the problem. Although there might not be sense of using K=1, we can prevent the error using:

Line 57 
dimens = 0 if num_clusters==1 else 1
choice_cluster = torch.argmin(dis, dim=dimens)   # choice_cluster = torch.argmin(dis, dim=1) 

dim=dimens should replace all dim=1 instances

Or, adding throw error message whenever num_clusters <2

morawi avatar Feb 10 '21 16:02 morawi