Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Loss Function Used #26

Open
witnik opened this issue Apr 8, 2022 · 1 comment
Open

Loss Function Used #26

witnik opened this issue Apr 8, 2022 · 1 comment

Comments

@witnik
Copy link

witnik commented Apr 8, 2022

Hi Shion,

I was trying to reproduce the model and realized that you used NLL loss in github yet it was mentioned in the paper to use Cross Entropy Loss. Would you mind suggesting which one of these loss function I should go further on my own?

Thanks

@shionhonda
Copy link
Contributor

Cross entropy loss is equivalent to NLL loss following the log-softmax operation (see here for more detail).

My Transformer model includes log-softmax in the forward function, so it is correct to use NLL loss.

out = F.log_softmax(out, dim=2) # (T,B,V)

To answer your question, it's up to your implementation. If your model outputs log of probability, use NLL loss. If it outputs logits, use cross entropy loss.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants