ctc
CTCLoss
Bases: Criterion
The wrapper class for torch.nn.functional.ctc_loss.
Source code in speechain/criterion/ctc.py
__call__(ctc_logits, enc_feat_len, text, text_len)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ctc_logits
|
Tensor
|
(batch, enc_feat_len, vocab) The model output from the CTC layer before the softmax operation. |
required |
enc_feat_len
|
Tensor
|
(batch,) The length of encoder feature sequences (<= the length of acoustic feature sequence) |
required |
text
|
Tensor
|
(batch, text_len) The grount-truth token index sequences. |
required |
text_len
|
Tensor
|
(batch,) The length of each token index sequence. |
required |
Source code in speechain/criterion/ctc.py
criterion_init(blank=0, zero_infinity=True)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
weight
|
float The weight on the CTC loss in the overall ASR loss. Used to balance the loss terms outside this class. |
required | |
blank
|
int
|
int = 0 The blank label for CTC modeling. In order to use CuDNN, blank must be set to 0. |
0
|
zero_infinity
|
bool
|
bool = True Whether to zero infinite losses and the associated gradients when calculating the CTC loss. |
True
|