zhoujx4 / DuEE

百度2021年语言与智能技术竞赛多形态信息抽取赛道事件抽取部分torch版baseline
71 stars 10 forks source link

标签数据下标不对。 #3

Closed obouluh closed 3 years ago

obouluh commented 3 years ago

您好!我在复现时碰到以下问题: File "run_ner.py", line 179, in main() File "run_ner.py", line 161, in main eval_p, eval_r, eval_f1, eval_loss = evaluate(args, eval_iter, model, metric) File "run_ner.py", line 46, in evaluate n_infer, n_label, n_correct = metric.compute(batch["all_seq_lens"], preds, batch['all_labels']) File "/home//DuEE/metric/metric.py", line 74, in compute ] for sent_index in range(len(lengths))] File "/home//DuEE/metric/metric.py", line 74, in ] for sent_index in range(len(lengths))] File "/home/***/DuEE/metric/metric.py", line 73, in for index in labels[sent_index][:lengths[sent_index]] KeyError: -1

打印出来label [[-1 26 26 ... -1 -1 -1] [-1 26 26 ... -1 -1 -1] [-1 26 26 ... 26 26 26] ... [-1 26 26 ... -1 -1 -1] [-1 26 26 ... -1 -1 -1] [-1 26 26 ... -1 -1 -1]]

对比一下,除了与paddle的ChunkEvaluator类中,相关的下标不同以外 image 好像没有其他区别。 请问有没有解决方法?

zhoujx4 commented 3 years ago

你好,这里漏了一个1,bert预测的第一为【CLS】,没意义的,所以没必要保留哈

------------------ 原始邮件 ------------------ 发件人: "zhoujx4/DuEE" @.>; 发送时间: 2021年4月23日(星期五) 下午3:10 @.>; @.***>; 主题: [zhoujx4/DuEE] 标签数据下标不对。 (#3)

您好!我在复现时碰到以下问题: File "run_ner.py", line 179, in main() File "run_ner.py", line 161, in main eval_p, eval_r, eval_f1, eval_loss = evaluate(args, eval_iter, model, metric) File "run_ner.py", line 46, in evaluate n_infer, n_label, n_correct = metric.compute(batch["all_seq_lens"], preds, batch['all_labels']) File "/home//DuEE/metric/metric.py", line 74, in compute ] for sent_index in range(len(lengths))] File "/home//DuEE/metric/metric.py", line 74, in ] for sent_index in range(len(lengths))] File "/home/***/DuEE/metric/metric.py", line 73, in for index in labels[sent_index][:lengths[sent_index]] KeyError: -1

打印出来label [[-1 26 26 ... -1 -1 -1] [-1 26 26 ... -1 -1 -1] [-1 26 26 ... 26 26 26] ... [-1 26 26 ... -1 -1 -1] [-1 26 26 ... -1 -1 -1] [-1 26 26 ... -1 -1 -1]]

对比一下,除了与paddle的ChunkEvaluator类中,相关的下标不同以外

好像没有其他区别。 请问有没有解决方法?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.

zhoujx4 commented 3 years ago

你好,这里漏了一个1,bert预测的第一为【CLS】,没意义的,所以没必要保留哈

因为在id2label_dict这个字典里面没有-1这个键,自然就报错了

------------------ 原始邮件 ------------------ 发件人: "zhoujx4/DuEE" @.>; 发送时间: 2021年4月23日(星期五) 下午3:10 @.>; @.***>; 主题: [zhoujx4/DuEE] 标签数据下标不对。 (#3)

您好!我在复现时碰到以下问题: File "run_ner.py", line 179, in main() File "run_ner.py", line 161, in main eval_p, eval_r, eval_f1, eval_loss = evaluate(args, eval_iter, model, metric) File "run_ner.py", line 46, in evaluate n_infer, n_label, n_correct = metric.compute(batch["all_seq_lens"], preds, batch['all_labels']) File "/home//DuEE/metric/metric.py", line 74, in compute ] for sent_index in range(len(lengths))] File "/home//DuEE/metric/metric.py", line 74, in ] for sent_index in range(len(lengths))] File "/home/***/DuEE/metric/metric.py", line 73, in for index in labels[sent_index][:lengths[sent_index]] KeyError: -1

打印出来label [[-1 26 26 ... -1 -1 -1] [-1 26 26 ... -1 -1 -1] [-1 26 26 ... 26 26 26] ... [-1 26 26 ... -1 -1 -1] [-1 26 26 ... -1 -1 -1] [-1 26 26 ... -1 -1 -1]]

对比一下,除了与paddle的ChunkEvaluator类中,相关的下标不同以外

好像没有其他区别。 请问有没有解决方法?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.

obouluh commented 3 years ago

@zhoujx4 已解决,谢谢