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

Why do you use log_softmax in sampling?

Open RodinIvan opened this issue 6 years ago • 1 comments

In line 94 in caption.py you use: scores = F.log_softmax(scores, dim=1)

Could you explain the reason for log_softmax here? You did not use it in forward() method.

More than that, I tried your model on my dataset and got BLEU = 0.16 on test set with that code for captioning. It produced almost similar captions for all images. But when i removed log_softmax line I got BLEU = 0.60... and I'm a little bit confused with that.

RodinIvan avatar Feb 06 '19 15:02 RodinIvan

@RodinIvan log_softmax is used to implement beam search. In beam search, you take the log_softmax of the concatenated scores, as opposed to taking the softmax only like after the cross entropy loss. This is how beam search is implemented.

fawazsammani avatar Feb 21 '19 01:02 fawazsammani