CTCLoss input validations

I have been trying to debug ctc going to nan all day. Finally I realized that it is going to inf first and then to nan. I then saw it was happening when the predicted label length and target length are very close.
To the best of my knowlledge if the target length is <= predicted label length ctc should be able to calculate a value. unless there are repeating characters and then it should be + 1 for each of those to accomodate for a null in between them

I noticed that if I make taget length significantly bigger things work out. Is there an explicit formula f(target_len) = minimum predicted label len ?
I saved the inputs into CTCLoss if you are interested in inspecting. I can’t paste it here though - so not sur e how to pass them…

so I limited to 2*target_len-1 which works. There is probably a lower limit that would still work, but good enough.

In PyTorch/master there is a flag to zero infinite losses.

Best regards

Thomas

1 Like