| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
| from typing import Tuple |
|
|
| import torch |
| import torch.nn as nn |
|
|
|
|
| class EncoderInterface(nn.Module): |
| def forward( |
| self, x: torch.Tensor, x_lens: torch.Tensor |
| ) -> Tuple[torch.Tensor, torch.Tensor]: |
| """ |
| Args: |
| x: |
| A tensor of shape (batch_size, input_seq_len, num_features) |
| containing the input features. |
| x_lens: |
| A tensor of shape (batch_size,) containing the number of frames |
| in `x` before padding. |
| Returns: |
| Return a tuple containing two tensors: |
| - encoder_out, a tensor of (batch_size, out_seq_len, output_dim) |
| containing unnormalized probabilities, i.e., the output of a |
| linear layer. |
| - encoder_out_lens, a tensor of shape (batch_size,) containing |
| the number of frames in `encoder_out` before padding. |
| """ |
| raise NotImplementedError("Please implement it in a subclass") |
|
|