Paddle icon indicating copy to clipboard operation
Paddle copied to clipboard

[paddle v2] 训练中的测试集结果 与 使用模型预测的测试集结果不一致问题

Open shiyazhou121 opened this issue 8 years ago • 6 comments

paddle版本:v2 0.11 问题:我在训练过程中使用测试集评估,准召率都是99%,但我使用训练好的模型来预测这份测试集,准召率很低,我不知道哪部分出现问题。以下是我的代码以及部分结果。 evaluator配置 image 训练中的event配置 image 训练日志中test的打印 image infer代码 image network代码 image

shiyazhou121 avatar Jun 04 '18 07:06 shiyazhou121

从给出的脚本配置上看没有发现大的问题。怀疑是送数据的问题。

  1. test的时候数据不需要加batch
  2. 检查一下train_reader中的处理方式,确保和infer时候对数据文件的读取和处理方式完全一致

另外看上去存模型和取模型的路径似乎不一致?

JiayiFeng avatar Jun 04 '18 09:06 JiayiFeng

@JiayiFeng train_reader 跟infer数据处理过程是一样的,模型路径也没问题。如果不加batch应该怎么写?有没有教程或者例子??我看官方给的例子都是封装好的数据,而且也是batch的。还有我使用的trainer.test(),这个有没有例子或者接口的说明,源代码也行。

shiyazhou121 avatar Jun 05 '18 05:06 shiyazhou121

@JiayiFeng 还有想问下如果确定paddle.parameters.Parameter.from_tar执行成功了?

shiyazhou121 avatar Jun 05 '18 06:06 shiyazhou121

trainer.test()的源码:https://github.com/PaddlePaddle/Paddle/blob/develop/python/paddle/v2/trainer.py#L217

使用例子:https://github.com/PaddlePaddle/models/blob/develop/image_classification/train.py#L115

Paddle/models下面的各个例子几乎都有使用trainer.test()。

JiayiFeng avatar Jun 05 '18 06:06 JiayiFeng

@JiayiFeng 谢谢你的帮忙 ^_^
我发现训练产生的参数文件是一样的。 下图是我训练生成的模型文件的md5,其中.model 是用merge_v2_model生成的,可以发现每轮的参数是一样的 image 下图是params_pass_1.tar 和 params_pass_60.tar 解压后,每个层的参数文件的md5对比,发现也是一样的。 image 因此我目前定位到在训练保存参数出现问题,或者训练出现问题。

以下是我的event函数代码 image

以下是我的train代码 image

image

能帮我看看到底哪里出现了问题吗??

[暂时解决]发现训练时,写了两遍dnn_trainer = paddle.trainer.SGD(cost=cost, parameters=parameters, update_equation=optimizer),去掉第一个后,训练出得模型参数就正常了。 但是不明白为什么写两遍会出现这种问题,猜测是trainer会生成name?两个trainer就有不同的name?先训练着看看效果。

shiyazhou121 avatar Jun 05 '18 07:06 shiyazhou121

您好,此issue在近一个月内暂无更新,我们将于今天内关闭。若在关闭后您仍需跟进提问,可重新开启此问题,我们将在24小时内回复您。因关闭带来的不便我们深表歉意,请您谅解~感谢您对PaddlePaddle的支持! Hello, this issue has not been updated in the past month. We will close it today for the sake of other user‘s experience. If you still need to follow up on this question after closing, please feel free to reopen it. In that case, we will get back to you within 24 hours. We apologize for the inconvenience caused by the closure and thank you so much for your support of PaddlePaddle Group!

shanyi15 avatar Aug 15 '18 10:08 shanyi15