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

ValueError: could not broadcast input array from shape (2) into shape (3) #14

Open
AndresPMD opened this issue Jul 14, 2021 · 1 comment

Comments

@AndresPMD
Copy link

When training, at evaluation time, the function construct_N_with_KNN outputs an error in the following line:

index_N_neighbours[i] = cand_nearest_i2t[index_i_txt-1:index_i_txt+2]

The error is:

ValueError: could not broadcast input array from shape (2) into shape (3)

Which makes the code impossible to complete full training.

@gzwo-O
Copy link

gzwo-O commented Sep 19, 2021

Hi, I have met the same question as you. This is because when index_i_txt = 4999 ( the shape of cand_nearest_i2t is (5000, 5000) ), if we want to get 3 nearest neighbors, we can only get cand_nearest_i2t[4998: 5000], which size is 2. So you should modify the code as following.
image

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