IBM / HOTT

Code for NeurIPS 2019 paper "Hierarchical Optimal Transport for Document Representation"
MIT License
54 stars 21 forks source link

boolean index did not match indexed array #2

Closed rmh1480 closed 4 years ago

rmh1480 commented 4 years ago

Hi,

After running main.py, I get the following error:

Traceback (most recent call last): File "./main.py", line 67, in test_error = knn(X_train, X_test, y_train, y_test, methods[method], C, n_neighbors=7) File "HOTT/knn_classifier.py", line 25, in knn doc_to_train = [method(doc, x, C) for x in X_train.T] File "HOTT/knn_classifier.py", line 25, in doc_to_train = [method(doc, x, C) for x in X_train.T] File "HOTT/hott.py", line 11, in hott C_reduced = C[id_p][:, id_q] IndexError: boolean index did not match indexed array along dimension 1; dimension is 70 but corresponding boolean dimension is 552

Any pointers on how to resolve this issue are appreciated. Best, Raja

EnnengYang commented 4 years ago

You should change line 39 of main.py file to bow_train, bow_test, y_train, y_test = train_test_split(bow_data, y)

rmh1480 commented 4 years ago

Same error after changing line 39 to: bow_train, bow_test, y_train, y_test = train_test_split(bow_data, y)

Traceback (most recent call last): File "./main.py", line 67, in test_error = knn(X_train, X_test, y_train, y_test, methods[method], C, n_neighbors=7) File "HOTT/knn_classifier.py", line 25, in knn doc_to_train = [method(doc, x, C) for x in X_train.T] File "HOTT/knn_classifier.py", line 25, in doc_to_train = [method(doc, x, C) for x in X_train.T] File "HOTT/hott.py", line 11, in hott C_reduced = C[id_p][:, id_q] IndexError: boolean index did not match indexed array along dimension 1; dimension is 70 but corresponding boolean dimension is 552

EnnengYang commented 4 years ago

You might also need to change the knn_classifier.py line 25 doc_to_train = [method(doc, x, C) for x in X_train.T] -> doc_to_train = [method(doc, x, C) for x in X_train]

EnnengYang commented 4 years ago

By the way, hott(p, q, C, threshold=None) has a problem, so you can use the def hoftt(p, q, C) model first.

moonfolk commented 4 years ago

Hi all,

Thanks for pointing out the bugs. I've revised the code. All methods seem to run correctly now. Please let me know if you encounter any further issues.

Best, Mikhail

rmh1480 commented 4 years ago

Thanks Mikhail for fixing this issue, it is working now.

Best, Raja