kmkurn / pytorch-crf

(Linear-chain) Conditional random field in PyTorch.
https://pytorch-crf.readthedocs.io
MIT License
935 stars 151 forks source link

Multiply -1 before loss.backward()? #27

Closed nijianmo closed 5 years ago

nijianmo commented 5 years ago

Hi, thanks for providing this great tool!

I have one quick question about the loglikelihood returned by forward function: loss = model(emissions, tags, mask=mask).

Is the returned value the negative loglikelihood or likelihood? Should I multiply -1 before loss.backward()?

Thanks!

kmkurn commented 5 years ago

Hi, thank you for using this library!

The returned value is the log likelihood. So, to use it as a loss objective to minimize, you'd want to multiply it by -1 first. Hope this helps!

kmkurn commented 5 years ago

@nijianmo It seems that you've found your answer, so I'm closing this issue.