Tensorflow的tf.nn.ctc_loss经常遇到的两个问题:

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/ssmixi/article/details/81166771

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

—— 标签的长度大于sequence length,比如ocr识别中原始图像经过卷积倍,池化后time step 维度减小,小于标签的长度。例如,输入矩阵长度为4,你得标签文本为‘world’长度为5,矩阵最多只能包含4个字符。甚至当标签文本包含重复的字符时,如‘pizza’,ctc算法必须插入一个特殊字符(空格)在之间,被允许的标签长度甚至减1。
https://stackoverflow.com/questions/50654740/ctc-loss-error-invalidargumenterror-not-enough-time-for-target-transition-seque

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.

——https://www.cnblogs.com/yuetz/p/6762501.html

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

猜你喜欢

转载自blog.csdn.net/ssmixi/article/details/81166771
今日推荐