MCPcopy Create free account
hub / github.com/apple/axlearn / predict

Method predict

axlearn/audio/decoder_asr.py:302–318  ·  view source on GitHub ↗

Computes logits. Args: input_batch: A dict containing: inputs: A Tensor of shape [batch_size, num_frames, dim]. paddings: A 0/1 Tensor of shape [batch_size, num_frames]. 1's represent paddings. Returns: Logits of shape [batch_

(self, input_batch: Nested[Tensor])

Source from the content-addressed store, hash-verified

300 )
301
302 def predict(self, input_batch: Nested[Tensor]) -> Tensor:
303 """Computes logits.
304
305 Args:
306 input_batch: A dict containing:
307 inputs: A Tensor of shape [batch_size, num_frames, dim].
308 paddings: A 0/1 Tensor of shape [batch_size, num_frames]. 1's represent paddings.
309
310 Returns:
311 Logits of shape [batch_size, num_frames, vocab_size]. Logits corresponding to padding
312 frames will be 0's. Note that the returned logits are not proper log probabilities, i.e.
313 we have not subtracted the log-partition function.
314 """
315 inputs = input_batch["inputs"]
316 paddings: Tensor = input_batch["paddings"]
317 logits = self.lm_head(inputs)
318 return logits * safe_not(paddings)[..., None]
319
320 def _loss_summaries(
321 self,

Callers 5

forwardMethod · 0.95
_tokens_to_scoresMethod · 0.95
greedy_decodeMethod · 0.95
alignMethod · 0.95
tokens_to_scoresMethod · 0.45

Calls 1

safe_notFunction · 0.90

Tested by

no test coverage detected