espnet.nets.mt_interface.MTInterface
About 1 min
espnet.nets.mt_interface.MTInterface
class espnet.nets.mt_interface.MTInterface
Bases: object
MT Interface for ESPnet model implementation.
static add_arguments(parser)
Add arguments to parser.
property attention_plot_class
Get attention plot class.
classmethod build(idim: int, odim: int, **kwargs)
Initialize this class with python-level args.
- Parameters:
- idim (int) – The number of an input feature dim.
- odim (int) – The number of output vocab.
- Returns: A new instance of ASRInterface.
- Return type: ASRinterface
calculate_all_attentions(xs, ilens, ys)
Calculate attention.
- Parameters:
- xs (list) – list of padded input sequences [(T1, idim), (T2, idim), …]
- ilens (ndarray) – batch of lengths of input sequences (B)
- ys (list) – list of character id sequence tensor [(L1), (L2), (L3), …]
- Returns: attention weights (B, Lmax, Tmax)
- Return type: float ndarray
forward(xs, ilens, ys)
Compute loss for training.
- Parameters:
- xs – For pytorch, batch of padded source sequences torch.Tensor (B, Tmax, idim) For chainer, list of source sequences chainer.Variable
- ilens – batch of lengths of source sequences (B) For pytorch, torch.Tensor For chainer, list of int
- ys – For pytorch, batch of padded source sequences torch.Tensor (B, Lmax) For chainer, list of source sequences chainer.Variable
- Returns: loss value
- Return type: torch.Tensor for pytorch, chainer.Variable for chainer
translate(x, trans_args, char_list=None, rnnlm=None)
Translate x for evaluation.
- Parameters:
- x (ndarray) – input acouctic feature (B, T, D) or (T, D)
- trans_args (namespace) – argment namespace contraining options
- char_list (list) – list of characters
- rnnlm (torch.nn.Module) – language model module
- Returns: N-best decoding results
- Return type: list
translate_batch(x, trans_args, char_list=None, rnnlm=None)
Beam search implementation for batch.
- Parameters:
- x (torch.Tensor) – encoder hidden state sequences (B, Tmax, Henc)
- trans_args (namespace) – argument namespace containing options
- char_list (list) – list of characters
- rnnlm (torch.nn.Module) – language model module
- Returns: N-best decoding results
- Return type: list