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])
| 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, |
no test coverage detected