AttributeError: 'str' object has no attribute 'size'
DICPZhou opened this issue · 2 comments
DICPZhou commented
when I run the command
"python transformers_trainer.py --device=cuda:0 --dataset=conll2003_sample --model_folder=saved_models --embedder_type=bert-base-cased"
Error output is : AttributeError: 'str' object has no attribute 'size'
is it the version of transformers? The version of transformers I used is 4.0.0
allanj commented
Can you paste the complete error stack trace here?
allanj commented
I found out the issue, if you are using the recent version of transformers, you can do the following or simply git pull
Our latest commit c399962 solve this issue. What I did was replacing
self.model = context_models[transformer_model_name]["model"].from_pretrained(transformer_model_name,
output_hidden_states= output_hidden_states)
with
self.model = context_models[transformer_model_name]["model"].from_pretrained(transformer_model_name,
output_hidden_states= output_hidden_states,
return_dict=False)
Because the recent transformer package will return a dictionary by default.