MCPcopy Create free account
hub / github.com/FLC777/GLAT / get_normalized_probs

Method get_normalized_probs

fairseq/models/fairseq_model.py:546–555  ·  view source on GitHub ↗

Get normalized probabilities (or log probs) from a net's output.

(self, net_output, log_probs, sample=None)

Source from the content-addressed store, hash-verified

544 return self.encoder(src_tokens, src_lengths, **kwargs)
545
546 def get_normalized_probs(self, net_output, log_probs, sample=None):
547 """Get normalized probabilities (or log probs) from a net's output."""
548 encoder_out = net_output["encoder_out"]
549 if torch.is_tensor(encoder_out):
550 logits = encoder_out.float()
551 if log_probs:
552 return F.log_softmax(logits, dim=-1)
553 else:
554 return F.softmax(logits, dim=-1)
555 raise NotImplementedError
556
557 def max_positions(self):
558 """Maximum length supported by the model."""

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected