SDRN icon indicating copy to clipboard operation
SDRN copied to clipboard

loss问题

Open hyliu777 opened this issue 3 years ago • 6 comments

你好,我看到你在论文中提到在14-Lap上loss训练50个epoch之后就只有200左右了,但是我参照你的代码默认的参数训练模型,loss在2000左右,请问这个差距的原因在哪呀,期望你的回复,感谢

hyliu777 avatar Aug 07 '21 00:08 hyliu777

您好,在运行的时候是出现了损失不收敛的问题么?那测试结果有上升么?还是测试也有问题?

chenshaowei57 avatar Aug 09 '21 07:08 chenshaowei57

我在bert-base上跑损失收敛,和论文中一样,但是我换成比如bert-tiny,total loss缓慢下降,每个batch的loss维持在200左右,应该是不收敛,target_acc也在0.88左右不上升了,relation_acc基本上为0,测试结果也是这样的。不知道您是否试过其他上游的预训练模型,还是模型只在bert-base上才能训练?

hyliu777 avatar Aug 10 '21 03:08 hyliu777

bert-tiny我没有尝试过,是不是tiny和base的分词和词表不一样导致的?

chenshaowei57 avatar Aug 19 '21 02:08 chenshaowei57

感谢!!!已经解决了,不是词表,是加载bert模型的方式错了

hyliu777 avatar Aug 25 '21 01:08 hyliu777

感谢!!!已经解决了,不是词表,是加载bert模型的方式错了

@LiuHuaYi ,请问下是怎么解决的吗?

我现在的结果呈现是这样的:

Instance: 3040; Time: 1.34s; loss: 34.2331; target_acc: 53895/61327=0.8788; relation_acc: 0/6450=0.0000 Epoch: 69 training finished. Time: 85.90s, speed: 35.45st/s, total loss: 2517.004978507757 totalloss: 2517.004978507757 test: time: 9.23s, speed: 0.00st/s relation result: Precision: 0.0000; Recall: 0.0000; F1: 0.0000 target result: Precision: 0.0000; Recall: 0.0000; F1: 0.0000 opinion result: Precision: 0.0000; Recall: 0.0000; F1: 0.0000

因为gpu是v100,我使用的torch版本不一样,稍微做了点改动,跑起来之后结果不太对

Zinc-30 avatar Aug 31 '21 12:08 Zinc-30

感谢!!!已经解决了,不是词表,是加载bert模型的方式错了

@LiuHuaYi ,请问下是怎么解决的吗?

我现在的结果呈现是这样的:

Instance: 3040; Time: 1.34s; loss: 34.2331; target_acc: 53895/61327=0.8788; relation_acc: 0/6450=0.0000 Epoch: 69 training finished. Time: 85.90s, speed: 35.45st/s, total loss: 2517.004978507757 totalloss: 2517.004978507757 test: time: 9.23s, speed: 0.00st/s relation result: Precision: 0.0000; Recall: 0.0000; F1: 0.0000 target result: Precision: 0.0000; Recall: 0.0000; F1: 0.0000 opinion result: Precision: 0.0000; Recall: 0.0000; F1: 0.0000

因为gpu是v100,我使用的torch版本不一样,稍微做了点改动,跑起来之后结果不太对

我是用from transformers import BertModel替换了作者代码中的from bert.modeling import BertModel,来加载的模型

hyliu777 avatar Sep 06 '21 07:09 hyliu777