Huggingface error during training: AttributeError: 'str' object has no attribute 'size'

Asked
Active3 hr before
Viewed126 times

3 Answers

error
90%

AttributeError: 'str' object has no attribute 'size',While trying to finetune a Huggingface GPT2LMHeadModel model for casual language modeling (given a sequence of words, predict the next word) using Pytorch Lightning, I am getting an error during training:,Electrical Engineering,Asking for help, clarification, or responding to other answers.

Here transformer recent version may occur this

pip install transformers == 2.11 .0
88%

Describe the bug I get this error every time I try fine tuning BERT with W&B: AttributeError("'str' object has no attribute 'item'",) ...whether it's your example in Google Colab or it's my own fine-tuning experiment with my own machine & dataset.,I have the same problem, I get the AttributeError ("'str' object has no attribute 'item'",) error in the loss.item () statement. I've listened to your release suggestions, but still haven't been able to come up with a solution.,When running the Bert algorithm, I have the same problem, I get the AttributeError ("'str' object has no attribute 'item'",) error in the loss.item () statement. solution: Since there is an unequaled value to the total_train_loss value, When I set the value for "loss" I did "return_dict = False". Problem solved.,In this specific case the error was due to a change in the API from transformers 3.X to transformers 4.X. We'll update the colab, in the mean time if anyone else reaches this error you can explicitly install transformers==3.5.1 for this example to work.

Describe the bug
I get this error every time I try fine tuning BERT with W&B: AttributeError("'str' object has no attribute 'item'",) ...whether it's your example in Google Colab or it's my own fine-tuning experiment with my own machine & dataset.

AttributeError("'str' object has no attribute 'item'", )
load more v
72%

I am running the following code for machine translation with HuggingFace Transformers:, How to create a neural network for regression with PyTorch ,Collections About the Collections project Dissecting Deep Learning (work in progress) Mastering TensorFlow & Keras Mastering PyTorch Mastering Scikit-learn Generative Adversarial Networks Transformers , My name is Christian Versloot (Chris) and I love teaching developers how to build  awesome machine learning models.

I am running the following code for machine translation with HuggingFace Transformers:


from transformers import AutoTokenizer, AutoModelForSeq2SeqLM

 from transformers
 import AutoTokenizer, AutoModelForSeq2SeqLM
load more v

Other "error-undefined" queries related to "Huggingface error during training: AttributeError: 'str' object has no attribute 'size'"