a-PyTorch-Tutorial-to-Image-Captioning icon indicating copy to clipboard operation
a-PyTorch-Tutorial-to-Image-Captioning copied to clipboard

If the length of the correct description is not equal to the predicted description length, the bleu evaluation cannot be performed.

Open hubin111 opened this issue 6 years ago • 4 comments

    assert len(references) == len(hypotheses)

# Calculate BLEU-4 scores
bleu4 = corpus_bleu(references, hypotheses)

hubin111 avatar Jun 18 '19 02:06 hubin111

Hey @hubin111 This situation you're describing is impossible! Because, for each image, we will always have a generated caption (hypothesis). This is a simple list [hyp1, hyp2, ...]. Accordingly, we'll have references as a list of lists [[ref1a, ref1b, ref1c, ref1d, ref1e], [ref2a, ref2b, ref2c, ref2d, ref2e], ... ].

Now, if you compute the length of these two lists, then they will match.

This assert statement assert len(references) == len(hypotheses)
just checks for whether we generated one caption for each image.

So, I don't see where the issue is coming from..

kmario23 avatar Jun 18 '19 14:06 kmario23

@kmario23 What you are suggesting makes complete sense. However, COCO dataset has 5 groundtruth captions per image. So since our model will generate one caption per image, how can their lengths be equal?

Ashwin-Ramesh2607 avatar Sep 09 '20 03:09 Ashwin-Ramesh2607

Python assertion checks for lengths only at the top level. See the example in my description above.

kmario23 avatar Sep 09 '20 21:09 kmario23

@kmario23 Yup, understood. Thanks :D

Ashwin-Ramesh2607 avatar Sep 10 '20 03:09 Ashwin-Ramesh2607