wzhouad / ATLOP

Source code for paper "Document-Level Relation Extraction with Adaptive Thresholding and Localized Context Pooling", AAAI 2021
197 stars 39 forks source link

model.py #4

Closed qiunlp closed 4 years ago

qiunlp commented 4 years ago

When I run train.py, there is an err in model.py:

line 45, in get_hrt e_att.append(attention[i, :, start + offset])
IndexError: too many indices for tensor of dimension 1

Thanks.

wzhouad commented 4 years ago

I cannot locate the error if not enough information is provided. Update your code to the latest patch, check whether your library versions match our requirements, and see whether you can reproduce the error.

qiunlp commented 4 years ago

Traceback (most recent call last): File "/home/qwh/桌面/D_ATLOP/train.py", line 293, in main() File "/home/qwh/桌面/D_ATLOP/train.py", line 290, in main train(args, model, train_features, dev_features,test_features) File "/home/qwh/桌面/D_ATLOP/train.py", line 202, in train finetune(train_features, optimizer, args.num_train_epochs) File "/home/qwh/桌面/D_ATLOP/train.py", line 164, in finetune outputs = model(inputs) File "/home/qwh/.local/lib/python3.6/site-packages/torch/nn/modules/module.py", line 550, in call result = self.forward(*input, kwargs) File "/home/qwh/桌面/D_ATLOP/model.py", line 91, in forward sequence_output, attention = self.encode(input_ids, attention_mask) File "/home/qwh/桌面/D_ATLOP/model.py", line 32, in encode sequence_output, attention = process_long_input(self.model, input_ids, attention_mask, start_tokens, end_tokens) File "/home/qwh/桌面/D_ATLOP/long_seq.py", line 17, in process_long_input output_attentions=True,* File "/home/qwh/.local/lib/python3.6/site-packages/torch/nn/modules/module.py", line 550, in call result = self.forward(input, kwargs) TypeError: forward() got an unexpected keyword argument 'output_attentions'

模块long_seq.py 中 output_attentions=True出错

当我去除 output_attentions=True时又出现另外一个错误: ine 45, in get_hrt e_att.append(attention[i, :, start + offset]) IndexError: too many indices for tensor of dimension 1

请问什么原因呢?谢谢!我是想改编成CPU版的

wzhouad commented 4 years ago

transformers版本太低,请更新到3.4.0

qiunlp commented 3 years ago

论文中公式(3)(4)(5)(6)(7)对应代码的哪一部分?谢谢指教

wzhouad commented 3 years ago

(3)(4)(5)对应的是enhanced baseline的classifier,没有在代码中实现。(6)(7)对应model.py 98 99行。