BruceW91/CVSE

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

Opened this issue · 1 comments

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.

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