kmkurn / pytorch-crf

(Linear-chain) Conditional random field in PyTorch.

Home Page:https://pytorch-crf.readthedocs.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Should I apply softmax or log_softmax to my token_scores?

poteminr opened this issue · comments

embedded_text_input = self.encoder(input_ids=input_ids, attention_mask=attention_mask).last_hidden_state
embedded_text_input = self.dropout(F.leaky_relu(embedded_text_input))
 token_scores = F.log_softmax(self.feedforward(embedded_text_input), dim=-1)
 # or
 # token_scores = self.feedforward(embedded_text_input)

loss, output_tags = self.apply_crf(token_scores, labels, attention_mask, batch_size=batch_size)

Should I apply softmax before passing token_scores to the CRF?

Thank you!