Similar to *forward* but only return features. Returns: tuple: - the decoder's features of shape `(batch, tgt_len, embed_dim)` - a dictionary with any model-specific outputs
(self, src_tokens, src_lengths, prev_output_tokens, **kwargs)
| 318 | return self.decoder(prev_output_tokens, **kwargs) |
| 319 | |
| 320 | def extract_features(self, src_tokens, src_lengths, prev_output_tokens, **kwargs): |
| 321 | """ |
| 322 | Similar to *forward* but only return features. |
| 323 | |
| 324 | Returns: |
| 325 | tuple: |
| 326 | - the decoder's features of shape `(batch, tgt_len, embed_dim)` |
| 327 | - a dictionary with any model-specific outputs |
| 328 | """ |
| 329 | encoder_out = self.encoder(src_tokens, src_lengths=src_lengths, **kwargs) |
| 330 | features = self.decoder.extract_features( |
| 331 | prev_output_tokens, encoder_out=encoder_out, **kwargs |
| 332 | ) |
| 333 | return features |
| 334 | |
| 335 | def output_layer(self, features, **kwargs): |
| 336 | """Project features to the default output size (typically vocabulary size).""" |
nothing calls this directly
no test coverage detected