BruceW91 / CVSE

The official source code for the paper Consensus-Aware Visual-Semantic Embedding for Image-Text Matching (ECCV 2020)
172 stars 19 forks source link

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

Open AndresPMD opened 3 years ago

AndresPMD commented 3 years ago

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 commented 3 years ago

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