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

AttributeError: 'MiniBatchKMeans' object has no attribute 'cluster_centers_' #4

Open
harshraj32 opened this issue May 10, 2021 · 4 comments

Comments

@harshraj32
Copy link

Traceback (most recent call last):
File "VideoBERT/VideoBERT/I3D/minibatch_hkmeans.py", line 30, in
main()
File "VideoBERT/VideoBERT/I3D/minibatch_hkmeans.py", line 26, in main
hkmeans(root, prefix, 4, 12, batch_size, 15, save_dir, 'vecs', centroid_dir)
File "/usr/local/lib/python3.7/dist-packages/hkmeans_minibatch/hkmeans.py", line 99, in hkmeans
hkmeans_recursive(root, prefix, h, k, batch_size, epochs, save_dir, save_prefix, centroid_dir)
File "/usr/local/lib/python3.7/dist-packages/hkmeans_minibatch/hkmeans.py", line 85, in hkmeans_recursive
centroids, labelled_data = minibatch_kmeans(root, prefix, k, batch_size, epochs)
File "/usr/local/lib/python3.7/dist-packages/hkmeans_minibatch/hkmeans.py", line 42, in minibatch_kmeans
return kmeans.cluster_centers_, labelled_data
AttributeError: 'MiniBatchKMeans' object has no attribute 'cluster_centers_'

the line i ran without any changes :
!python3 VideoBERT/VideoBERT/I3D/minibatch_hkmeans.py -r /content/VideoBERT/VideoBERT/data/features -b 1 -s /content/VideoBERT/VideoBERT/data/kmean_vectors -c /content/VideoBERT/VideoBERT/data/centroids -p hkm

@ammesatyajit
Copy link
Owner

Your batch size seems to be 1. Ideally, it should be a multiple of how many vectors are in each file containing the feature vectors. This probably is the problem, since I had files with 20 vectors each, and I used a batch size of 500.

@ammesatyajit
Copy link
Owner

If you have a batch size of 1, the kmeans will not be able to complete because by definition it requires multiple examples to update the centroids.

@harshraj32
Copy link
Author

also should this be the output in label.json file we are creating, looks like hkmeans is predicting all zero values for the files

"QU1Y4ogmSDE": [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
],

@chenjianqiang199526
Copy link

Has the problem been solved? I also had the same problem

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

3 participants