liuwei1206 / LEBERT

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

AttributeError: 'tuple' object has no attribute 'hidden_states' #31

Closed lvjiujin closed 2 years ago

lvjiujin commented 2 years ago
2021-09-19 20:23:44:INFO: ***** Running dev *****
2021-09-19 20:23:44:INFO:   Num examples = 271
2021-09-19 20:23:44:INFO:   Batch size = 16
dev:   0%|                                               | 0/17 [00:02<?, ?it/s]
Traceback (most recent call last):
  File "/root/python_proj/LEBERT/Trainer.py", line 601, in <module>
    main()
  File "/root/python_proj/LEBERT/Trainer.py", line 584, in main
    eval_output, _ = evaluate(model, args, dev_dataset, label_vocab, global_steps, "dev", write_file=True)
  File "/root/python_proj/LEBERT/Trainer.py", line 444, in evaluate
    outputs = model(**inputs)
  File "/root/miniconda3/lib/python3.8/site-packages/torch/nn/modules/module.py", line 727, in _call_impl
    result = self.forward(*input, **kwargs)
  File "/root/python_proj/LEBERT/wcbert_modeling.py", line 498, in forward
    outputs = self.bert(
  File "/root/miniconda3/lib/python3.8/site-packages/torch/nn/modules/module.py", line 727, in _call_impl
    result = self.forward(*input, **kwargs)
  File "/root/python_proj/LEBERT/wcbert_modeling.py", line 463, in forward
    hidden_states=encoder_outputs.hidden_states,
AttributeError: 'tuple' object has no attribute 'hidden_states'

Process finished with exit code 1

运行代码报tuple中没有hidden_states, 我的transformers版本是4.10.2,难道是transformers版本的问题?

liuwei1206 commented 2 years ago

I already provided the version of each module I used. Please try to follow it.