1. 程式人生 > >Tensorflow的tf.nn.ctc_loss經常遇到的兩個問題:

Tensorflow的tf.nn.ctc_loss經常遇到的兩個問題:

1.CTC Loss Error: invalidArgumentError: Not Enough time for target transition sequence.

2.CTC Loss Error: InvalidArgumentError: sequence_length(b) <= time
In this case b is each example in a minibatch. sequence_length(b) is the number of time stamps you have for that example. This is specified in the sequence_length argument passed to tf.nn.ctc_loss which is a 1-d tensor of sequence lengths.

sequence length 的維度為一維batchsize大小的向量,要求sequence length 中的每一個樣例長度都要小於max time step,這裡錯誤的原因就是資料的sequence 比lstm的step還長,如果資料直接進入lstm那麼step等於資料補齊後的最長sequence,但例如ocr問題在進入rnn前先進行卷積,所以sequence的長度要考慮cnn的shape.

3.ctc_loss error “No valid path found.”

“It turns out that the ctc_loss requires that the label lengths be shorter than the input lengths. If the label lengths are too long, the loss calculator cannot unroll completely and therefore cannot compute the loss.”
——

https://stackoverflow.com/questions/45130184/ctc-loss-error-no-valid-path-found