Get normalized probabilities (or log probs) from a net's output.
(self, net_output, log_probs, sample=None)
| 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.""" |
nothing calls this directly
no outgoing calls
no test coverage detected