espnet.nets.pytorch_backend.ctc.CTC
About 1 min
espnet.nets.pytorch_backend.ctc.CTC
class espnet.nets.pytorch_backend.ctc.CTC(odim, eprojs, dropout_rate, ctc_type='builtin', reduce=True)
Bases: Module
CTC module
- Parameters:
- odim (int) – dimension of outputs
- eprojs (int) – number of encoder projection units
- dropout_rate (float) – dropout rate (0.0 ~ 1.0)
- ctc_type (str) – builtin
- reduce (bool) – reduce the CTC loss into a scalar
Initializes internal Module state, shared by both nn.Module and ScriptModule.
argmax(hs_pad)
argmax of frame activations
- Parameters:hs_pad (torch.Tensor) – 3d tensor (B, Tmax, eprojs)
- Returns: argmax applied 2d tensor (B, Tmax)
- Return type: torch.Tensor
forced_align(h, y, blank_id=0)
forced alignment.
- Parameters:
- h (torch.Tensor) – hidden state sequence, 2d tensor (T, D)
- y (int) – id sequence tensor 1d tensor (L)
- y – blank symbol index
- Returns: best alignment results
- Return type: list
forward(hs_pad, hlens, ys_pad)
CTC forward
- Parameters:
- hs_pad (torch.Tensor) – batch of padded hidden state sequences (B, Tmax, D)
- hlens (torch.Tensor) – batch of lengths of hidden state sequences (B)
- ys_pad (torch.Tensor) – batch of padded character id sequence tensor (B, Lmax)
- Returns: ctc loss value
- Return type: torch.Tensor
log_softmax(hs_pad)
log_softmax of frame activations
- Parameters:hs_pad (torch.Tensor) – 3d tensor (B, Tmax, eprojs)
- Returns: log softmax applied 3d tensor (B, Tmax, odim)
- Return type: torch.Tensor
loss_fn(th_pred, th_target, th_ilen, th_olen)
softmax(hs_pad)
softmax of frame activations
- Parameters:hs_pad (torch.Tensor) – 3d tensor (B, Tmax, eprojs)
- Returns: log softmax applied 3d tensor (B, Tmax, odim)
- Return type: torch.Tensor