so should encode the label like this encoded_label = [1, 2, 1, 3]
or like this encoded_label = [0, 1, 0, 2, 0, 1, 0, 3, 0]
Note: These encoded_label will be passed as targets in the loss mentioned above.
You want encoded_label = torch.tensor([1, 2, 1, 3]), otherwise the CTC loss will tip over. The CTCLoss implementation does follow the alignment with the enlarged sequence, but does this “padding” on the fly.
No, read the documentation, it differs depending on the device you are working. You should initiate all you label with equal length, perhaps by padding the them. The class acknowledges the length of each target through the “target_lengths” argument which should contain the length of each target in the batch.