CTCLoss

class dragon.vm.torch.nn.CTCLoss(
  padding_mask=- 1,
  reduction='mean'
)[source]

Compute the ctc loss with batched labels. [Graves & Gomez, 2006].

Examples:

# t: num_steps
# n: batch_size
# c: num_classes(with blank at 0)
t, n, c = 8, 4, 5
m = torch.nn.CTCLoss(padding_mask=-1).cuda()
logits = torch.ones(t, n, c)
labels = torch.tensor([[1, 2, 3],
                       [1, 2, -1],
                       [1, -1, -1],
                       [1, 1, 1]], dtype='int32')
loss = m(logits, labels)

__init__

CTCLoss.__init__(
  padding_mask=- 1,
  reduction='mean'
)[source]

Create CTCLoss module.

Parameters:
  • padding_mask (int, optional, default=-1) – The mask for padding the redundant labels.
  • reduction ({'none', 'mean', 'sum'}, optional) – The reduce method.