Closed pengshancai closed 3 years ago
Have you used the patch for generation_utils provided in the code?
You have to copy patch/generation_utils.py
to your path /root/anaconda3/envs/wow/lib/python3.7/site-packages/transformers/
Oh, I did not notice that. Thanks!
Hi there, During training, the code report the following bug
File "doha.py", line 756, in
main()
File "doha.py", line 746, in main
qa.train()
File "doha.py", line 528, in train
results = self.evaluate(dev_data)
File "doha.py", line 613, in evaluate
pred, total_eval_loss, total_words = self.predict((dev_examples, dev_features))
File "doha.py", line 575, in predict
top_p=0.9,
File "/root/anaconda3/envs/wow/lib/python3.7/site-packages/torch/autograd/grad_mode.py", line 28, in decorate_context
return func(*args, *kwargs)
File "/root/anaconda3/envs/wow/lib/python3.7/site-packages/transformers/generation_utils.py", line 396, in generate
encoder_outputs: ModelOutput = encoder(input_ids, attention_mask=attention_mask, return_dict=True)
File "/root/anaconda3/envs/wow/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1051, in _call_impl
return forward_call(input, **kwargs)
File "/root/anaconda3/envs/wow/lib/python3.7/site-packages/transformers/modeling_bart.py", line 331, in forward
attention_mask = invert_mask(attention_mask)
File "/root/anaconda3/envs/wow/lib/python3.7/site-packages/transformers/modeling_bart.py", line 135, in invert_mask
assert attention_mask.dim() == 2
AttributeError: 'tuple' object has no attribute 'dim'
I am using transformer 3.1.0, it seems to me that during encoding, the attention mask must be a tensor instead of a tuple containing 2 tensors
Any suggestion on this?