liuwei1206 / LEBERT

Code for the ACL2021 paper "Lexicon Enhanced Chinese Sequence Labelling Using BERT Adapter"
336 stars 60 forks source link

IndexError: list index out of range #48

Closed lijia2019310 closed 2 years ago

lijia2019310 commented 2 years ago

你好,我在单机GPU复现代码时,在做验证集时出现错误IndexError: list index out of range,
test: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████| 17/17 [00:03<00:00, 4.32it/s] Traceback (most recent call last): File "Trainer.py", line 597, in main() File "Trainer.py", line 591, in main evaloutput, = evaluate(model, args, test_dataset, label_vocab, global_steps, "test", write_file=True) File "Trainer.py", line 464, in evaluate all_label_ids, all_predict_ids, all_attention_mask, label_vocab) File "/root/autodl-tmp/function/metrics.py", line 37, in seq_f1_with_mask tmp_pred.append(label_vocab.convert_id_to_item(all_pred_labels[i][j]).replace("M-", "I-")) File "/root/autodl-tmp/feature/vocab.py", line 81, in convert_id_to_item return self.idx2item[id] IndexError: list index out of range

但是我在代码中找不到错误,这种情况怎么处理?

liuwei1206 commented 2 years ago

Hi,

It seems that one label is out of the range of idx2item. Please check all the items in idx2items and print the accident label.

kk19990709 commented 2 years ago

Hi, I met the same bug(index out of range) for times. I am trying to find the bug.