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

Method forward

fairseq/models/fairseq_model.py:531–544  ·  view source on GitHub ↗

Run the forward pass for a encoder-only model. Feeds a batch of tokens through the encoder to generate features. Args: src_tokens (LongTensor): input tokens of shape `(batch, src_len)` src_lengths (LongTensor): source sentence lengths of shape `(bat

(self, src_tokens, src_lengths, **kwargs)

Source from the content-addressed store, hash-verified

529 assert isinstance(self.encoder, FairseqEncoder)
530
531 def forward(self, src_tokens, src_lengths, **kwargs):
532 """
533 Run the forward pass for a encoder-only model.
534
535 Feeds a batch of tokens through the encoder to generate features.
536
537 Args:
538 src_tokens (LongTensor): input tokens of shape `(batch, src_len)`
539 src_lengths (LongTensor): source sentence lengths of shape `(batch)`
540
541 Returns:
542 the encoder's output, typically of shape `(batch, src_len, features)`
543 """
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."""

Callers

nothing calls this directly

Calls 1

encoderMethod · 0.80

Tested by

no test coverage detected