fastnlp / fastNLP

fastNLP: A Modularized and Extensible NLP Framework. Currently still in incubation.
https://gitee.com/fastnlp/fastNLP
Apache License 2.0
3.05k stars 451 forks source link

ClassifyFPreRecMetric f_type=’micro' 训练时pre!=acc? #395

Closed MrYxJ closed 2 years ago

MrYxJ commented 2 years ago

Describe the bug 我在做二分类实验时使用fastNLP.core.metrics.ClassifyFPreRecMetric作为模型metric,设置参数f_type=‘micro‘,在模型训练的过程中,针对验证集输出metric结果时,如下图显示 image pre,rec,acc的指标理应都一样,但只满足rec==acc。 当模型训练完后,再次调用ClassifyFPreRecMetric,是正常满足pre==rec==acc。 image

yhcc commented 2 years ago

我们在最新的fastNLP上测试了一下(使用了随机的数据进行二分类),结果显示pre/rec/f是完全一致的。不知道您的fastNLP是哪个版本的?

yhcc commented 2 years ago

非常抱歉,最后找到错误原因了。的确是一个bug,这个bug会在某一个batch如果target只有一类时就会导致。我们会在之后的版本中修复这个bug。