senlinuc / caffe_ocr

主流ocr算法研究实验性的项目,目前实现了CNN+BLSTM+CTC架构
1.26k stars 536 forks source link

warp_ctc_loss_layer.cpp:56] Check failed: N_ == label_seq*** Check failure stack trace: *** ->num() (128 vs. 64) #59

Closed prfans closed 5 years ago

prfans commented 6 years ago

发现一个问题, 应该是bug: 训练样本图像高度须为32像素高度, 高于32, 比如36就会出错. 是否可以修复下,谢谢. @senlinuc

ManiroXi commented 5 years ago

网络结构要求输入高度为32,您可以修改网络参数适配

mengpengfei commented 5 years ago

对有些数据集 leveldb 训练报错怎么回事 Check failed: shape[i] >= 0 (-546308077 vs. 0)

zhudibo commented 5 years ago

修改输入图像的大小该怎么改网络啊?求指导,想把32改为64.

prfans commented 5 years ago

看那一层不合适,修改那一层的网络结构。

在 2019-05-16 11:23:14,"zhudibo" notifications@github.com 写道:

修改输入图像的大小该怎么改网络啊?求指导,想把32改为64.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

zhudibo commented 5 years ago

我已经修改好的,训练出的结果发现,没有32的好。

---Original--- From: "prfans"notifications@github.com Date: 2019/5/20 10:16:55 To: "senlinuc/caffe_ocr"caffe_ocr@noreply.github.com; Cc: "zhudibo"1020286694@qq.com;"Comment"comment@noreply.github.com; Subject: Re: [senlinuc/caffe_ocr] warp_ctc_losslayer.cpp:56] Check failed: N == label_seq Check failure stack trace: ->num() (128 vs. 64) (#59)

看那一层不合适,修改那一层的网络结构。

在 2019-05-16 11:23:14,"zhudibo" notifications@github.com 写道:

修改输入图像的大小该怎么改网络啊?求指导,想把32改为64.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread. — You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

mengpengfei commented 5 years ago

训练一直loss不下降是怎么回事?

prfans commented 5 years ago

练出的结果发现,没有32的

其他的参数应该也需要调整,比如卷积核尺寸等。

prfans commented 5 years ago

训练一直loss不下降是怎么回事?

这种问题一般检查下数据标注有无问题,输出层标签数量等错误。

mengpengfei commented 5 years ago

检查过了 输出层36个字符num_output: 37 ,数据标注也没有问题

zhudibo commented 5 years ago

练出的结果发现,没有32的

其他的参数应该也需要调整,比如卷积核尺寸等。

32的变为64的,卷积的大小我没变,我只是把lstm之前的一个池化层的kner_h,由4改为8.不知大佬怎么改的?

prfans commented 5 years ago

据标注也没有问题

那可能是训练数据问题,或者标注有错误的,或者数据集本身比较难训练。如果数据集没有问题,建议修改下学习率参数试试。

prfans commented 5 years ago

练出的结果发现,没有32的 其他的参数应该也需要调整,比如卷积核尺寸等。

32的变为64的,卷积的大小我没变,我只是把lstm之前的一个池化层的kner_h,由4改为8.不知大佬怎么改的?

64的图像肯定字符变大了,卷积核的尺寸可能也得增大处理,另外,也可以把前面的CNN去掉,换成inception v3等网络,然后在CNN后面再接LSTM和ctc。神经网络这类方法,参数得不停尝试。

zhudibo commented 5 years ago

我使用的是dense那个网络。这个网络的识别率是最高的,然后就使用它了,其他的我来试试

---Original--- From: "prfans"notifications@github.com Date: 2019/5/20 10:50:27 To: "senlinuc/caffe_ocr"caffe_ocr@noreply.github.com; Cc: "zhudibo"1020286694@qq.com;"Comment"comment@noreply.github.com; Subject: Re: [senlinuc/caffe_ocr] warp_ctc_losslayer.cpp:56] Check failed: N == label_seq Check failure stack trace: ->num() (128 vs. 64) (#59)

练出的结果发现,没有32的 其他的参数应该也需要调整,比如卷积核尺寸等。

32的变为64的,卷积的大小我没变,我只是把lstm之前的一个池化层的kner_h,由4改为8.不知大佬怎么改的?

64的图像肯定字符变大了,卷积核的尺寸可能也得增大处理,另外,也可以把前面的CNN去掉,换成inception v3等网络,然后在CNN后面再接LSTM和ctc。神经网络这类方法,参数得不停尝试。

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

mengpengfei commented 5 years ago

这学习率已经很低了吧

I0520 10:58:05.349864 10564 solver.cpp:342] Iteration 13545000, Testing net (#0) I0520 10:58:06.535334 9736 data_layer.cpp:78] Restarting data prefetching from start. I0520 10:58:06.627910 10564 solver.cpp:409] Test net output #0: acc = 0.045701 I0520 10:58:06.627910 10564 solver.cpp:409] Test net output #1: acc = 0 I0520 10:58:06.627910 10564 solver.cpp:409] Test net output #2: ctcloss = 21.4828 ( 1 = 21.4828 loss) I0520 10:58:06.674784 10564 solver.cpp:231] Iteration 13545000, loss = 21.2888 I0520 10:58:06.674784 10564 solver.cpp:249] Train net output #0: ctcloss = 21.2888 ( 1 = 21.2888 loss) I0520 10:58:06.674784 10564 sgd_solver.cpp:106] Iteration 13545000, lr = 4.47636e-07 I0520 10:58:13.256012 10564 solver.cpp:231] Iteration 13545100, loss = 21.3843 I0520 10:58:13.256012 10564 solver.cpp:249] Train net output #0: ctcloss = 21.3843 ( 1 = 21.3843 loss) I0520 10:58:13.256012 10564 sgd_solver.cpp:106] Iteration 13545100, lr = 4.47634e-07 I0520 10:58:19.844333 10564 solver.cpp:231] Iteration 13545200, loss = 21.2293 I0520 10:58:19.844333 10564 solver.cpp:249] Train net output #0: ctcloss = 21.2293 ( 1 = 21.2293 loss) I0520 10:58:19.844333 10564 sgd_solver.cpp:106] Iteration 13545200, lr = 4.47631e-07 I0520 10:58:26.444380 10564 solver.cpp:231] Iteration 13545300, loss = 21.3867 I0520 10:58:26.444380 10564 solver.cpp:249] Train net output #0: ctcloss = 21.3867 ( 1 = 21.3867 loss) I0520 10:58:26.444380 10564 sgd_solver.cpp:106] Iteration 13545300, lr = 4.47629e-07 I0520 10:58:33.061249 10564 solver.cpp:231] Iteration 13545400, loss = 21.4561 I0520 10:58:33.061249 10564 solver.cpp:249] Train net output #0: ctcloss = 21.4561 ( 1 = 21.4561 loss) I0520 10:58:33.061249 10564 sgd_solver.cpp:106] Iteration 13545400, lr = 4.47626e-07

prfans commented 5 years ago

这学习率已经很低了吧

I0520 10:58:05.349864 10564 solver.cpp:342] Iteration 13545000, Testing net (#0) I0520 10:58:06.535334 9736 data_layer.cpp:78] Restarting data prefetching from start. I0520 10:58:06.627910 10564 solver.cpp:409] Test net output #0: acc = 0.045701 I0520 10:58:06.627910 10564 solver.cpp:409] Test net output #1: acc = 0 I0520 10:58:06.627910 10564 solver.cpp:409] Test net output #2: ctcloss = 21.4828 ( 1 = 21.4828 loss) I0520 10:58:06.674784 10564 solver.cpp:231] Iteration 13545000, loss = 21.2888 I0520 10:58:06.674784 10564 solver.cpp:249] Train net output #0: ctcloss = 21.2888 ( 1 = 21.2888 loss) I0520 10:58:06.674784 10564 sgd_solver.cpp:106] Iteration 13545000, lr = 4.47636e-07 I0520 10:58:13.256012 10564 solver.cpp:231] Iteration 13545100, loss = 21.3843 I0520 10:58:13.256012 10564 solver.cpp:249] Train net output #0: ctcloss = 21.3843 ( 1 = 21.3843 loss) I0520 10:58:13.256012 10564 sgd_solver.cpp:106] Iteration 13545100, lr = 4.47634e-07 I0520 10:58:19.844333 10564 solver.cpp:231] Iteration 13545200, loss = 21.2293 I0520 10:58:19.844333 10564 solver.cpp:249] Train net output #0: ctcloss = 21.2293 ( 1 = 21.2293 loss) I0520 10:58:19.844333 10564 sgd_solver.cpp:106] Iteration 13545200, lr = 4.47631e-07 I0520 10:58:26.444380 10564 solver.cpp:231] Iteration 13545300, loss = 21.3867 I0520 10:58:26.444380 10564 solver.cpp:249] Train net output #0: ctcloss = 21.3867 ( 1 = 21.3867 loss) I0520 10:58:26.444380 10564 sgd_solver.cpp:106] Iteration 13545300, lr = 4.47629e-07 I0520 10:58:33.061249 10564 solver.cpp:231] Iteration 13545400, loss = 21.4561 I0520 10:58:33.061249 10564 solver.cpp:249] Train net output #0: ctcloss = 21.4561 ( 1 = 21.4561 loss) I0520 10:58:33.061249 10564 sgd_solver.cpp:106] Iteration 13545400, lr = 4.47626e-07

你这个肯定有问题,一千多万次,这么低的精度。

mengpengfei commented 5 years ago

总共训练了550w张,样本比较复杂,是是不是resnet-18网络层太浅导致的?

loss一直是21点多不下降

prfans commented 5 years ago

总共训练了550w张,样本比较复杂,是是不是resnet-18网络层太浅导致的?

loss一直是21点多不下降 你可以先换个简单的数据集,看看是否能否收敛。如果简单的数据集可以收敛,而你这个数据集不收敛,就建议更改网络结构了,比如把前面的CNN改复杂一点,把后边的LSTM也改复杂一点,同时增加训练样本量。

mengpengfei commented 5 years ago

试过了,简单样本收敛很快

prfans commented 5 years ago

试过了,简单样本收敛很快

那就建议改用更复杂的网络了。方便透漏是啥样本?550万张不收敛。

mengpengfei commented 5 years ago

生成的英数样本,干扰比较多,16000多个字体 如果每种字体生成10000张,就需要1.6亿张图片了 麻烦问下有没有更简便的方法

prfans commented 5 years ago

生成的英数样本,干扰比较多,16000多个字体

你这个任务比较复杂,我也在做一个OCR项目,字体也就几十种,我样本4000多万,是可以收敛的。 可能我加的干扰没有你的。 16000种字体,这个任务我没信心做好,样本类内差异可能会大于类间差异。

prfans commented 5 years ago

生成的英数样本,干扰比较多,16000多个字体 如果每种字体生成10000张,就需要1.6亿张图片了 麻烦问下有没有更简便的方法

16000种字体,不能根据应用场景拆分为几个模型进行训练吗?

mengpengfei commented 5 years ago

生成的英数样本,干扰比较多,16000多个字体

你这个任务比较复杂,我也在做一个OCR项目,字体也就几十种,我样本4000多万,是可以收敛的。 可能我加的干扰没有你的。 16000种字体,这个任务我没信心做好,样本类内差异可能会大于类间差异。 字体就几十种就要4000多万样本,看来我这个没发弄了

你感觉 这个如果跑一亿次迭代有没有可能收敛

prfans commented 5 years ago

生成的英数样本,干扰比较多,16000多个字体

你这个任务比较复杂,我也在做一个OCR项目,字体也就几十种,我样本4000多万,是可以收敛的。 可能我加的干扰没有你的。 16000种字体,这个任务我没信心做好,样本类内差异可能会大于类间差异。 字体就几十种就要4000多万样本,看来我这个没发弄了

样本一般是多了好,我看了英文的有些字体,平常几乎用不到。如果你按照我这种方式进行增广,确实一般机器也带不动。

prfans commented 5 years ago

生成的英数样本,干扰比较多,16000多个字体

你这个任务比较复杂,我也在做一个OCR项目,字体也就几十种,我样本4000多万,是可以收敛的。 可能我加的干扰没有你的。 16000种字体,这个任务我没信心做好,样本类内差异可能会大于类间差异。 字体就几十种就要4000多万样本,看来我这个没发弄了

你感觉 这个如果跑一亿次迭代有没有可能收敛

我觉得不太可能收敛。就没有收敛的迹象吧,一般前面收敛会快,后面收敛会慢,我猜你这个如果收敛也在几十亿迭代。

prfans commented 5 years ago

生成的英数样本,干扰比较多,16000多个字体

你这个任务比较复杂,我也在做一个OCR项目,字体也就几十种,我样本4000多万,是可以收敛的。 可能我加的干扰没有你的。 16000种字体,这个任务我没信心做好,样本类内差异可能会大于类间差异。 字体就几十种就要4000多万样本,看来我这个没发弄了

你感觉 这个如果跑一亿次迭代有没有可能收敛

我觉得你用目标检测算法比LSTM算法好使。

mengpengfei commented 5 years ago

目标检测比resnet或者densenet 这种cnn准确度高吗?

prfans commented 5 years ago

目标检测比resnet或者densenet 这种cnn准确度高吗?

你这个字体比较多,用这种循环神经网络,我感觉很难收敛。

Ryansanity commented 4 years ago

您好 请问一下 标题上的check failed是怎么解决的??