LowinLi / Text-Summarizer-Pytorch-Chinese

提供一款中文版生成式摘要服务
MIT License
321 stars 48 forks source link

运行python /tmp/bishe/eval.py --task=validate --start_from=0005000.tar命令时遇到除零错误 #23

Open starryscholar opened 3 years ago

starryscholar commented 3 years ago

(myconda) root@cebf7236c869:~# python /tmp/bishe/eval.py --task=validate --start_from=0005000.tar 2021-05-13 01:43:28,991 - datautil.log - INFO - log鍚姩 /tmp/bishe/data/chunked/valid/valid* 2021-05-13 01:43:31,420 - data_util.log - INFO - Traceback (most recent call last): File "/tmp/bishe/eval.py", line 168, in eval_processor.evaluate_batch(False) File "/tmp/bishe/eval.py", line 102, in evaluate_batch rouge_1 = sum([x["rouge-1"]["f"] for x in scores]) / len(scores) ZeroDivisionError: division by zero image 代码: if article: self.print_original_predicted(decoded_sents, ref_sents, article_sents, load_file)

    scores = rouge.get_scores(decoded_sents, ref_sents)
    rouge_1 = sum([x["rouge-1"]["f"] for x in scores]) / len(scores)
    rouge_2 = sum([x["rouge-2"]["f"] for x in scores]) / len(scores)
    rouge_l = sum([x["rouge-l"]["f"] for x in scores]) / len(scores)
    logger.info(load_file + " rouge_1:" + "%.4f" % rouge_1 + " rouge_2:" + "%.4f" % rouge_2 + " rouge_l:" + "%.4f" % rouge_l)

image

LowinLi commented 3 years ago

会不会是传入了空的验证集呢

starryscholar commented 3 years ago

会不会是传入了空的验证集呢

image image 是这个验证集吗,有的呀