Cadene / vqa.pytorch

Visual Question Answering in Pytorch
717 stars 178 forks source link

Why don't you apply a softmax function before the final prediction? #41

Closed zwx8981 closed 6 years ago

zwx8981 commented 6 years ago

HI, thank you for great work, I have a little question. As a classification task,we usually apply a softmax function to convert the output of a model into a probabilistic vector, each entry of which represents the probability of the input that belonging to the corresponding category. However, it seems that in your code the output of the Mutan model (the output of the second multimodel fusion followed by only a linear transformation without a softmax) is directly fed into the loss function. Is there any special consideration?

https://github.com/Cadene/vqa.pytorch/blob/be1b6113130cda123d14c83b24c9a04acc3900d0/vqa/models/att.py#L152

Cadene commented 6 years ago

@zwx8981 Here we use nn.CrossEntropyLoss which combines nn.LogSoftmax and nn.NLLLoss. Thus, we don't need to add a softmax. It is already included.

zwx8981 commented 6 years ago

@Cadene Thank you!