[HuggingFace] AttributeError("'str' object has no attribute 'item'",)
See original GitHub issueDescribe 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.
To Reproduce
- Go to https://colab.research.google.com/drive/1SQ-FOgji8AiyrQ08sIVfDiA8OUw4bC12?usp=sharing#scrollTo=JL9OqcavmYVb
- Click
Run All
- See error
Screenshots
Additional context Python 3.7.9 wandb 0.10.12 torch 1.7.0+cu110 transformers 4.1.1
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:9 (3 by maintainers)
Top Results From Across the Web
[HuggingFace] AttributeError("'str' object has no attribute 'item'",)
When running the Bert algorithm, I have the same problem, I get the AttributeError ("'str' object has no attribute 'item'",) error in the...
Read more >AttributeError: 'str' object has no attribute 'size' - Stack Overflow
python - Huggingface error during training: AttributeError: 'str' object has no attribute 'size' - Stack Overflow. Stack Overflow for Teams – ...
Read more >'str' object has no attribute 'dtype' when pretraining wav2vec2 ...
I was trying to pretrain the word2vec2.0 using this file. However, I get the following error when I reach the training phase: AttributeError...
Read more >Item = {key: torch.tensor(val[idx]) for key, val in self.encodings ...
I get this error when loading the new test file (it does not have label) ... in self.encodings.items()} AttributeError: 'list' object has no...
Read more >SebastianS/github-issues · Datasets at Hugging Face
AbstractFileSystem) -> bool: AttributeError: 'EntryPoint' object has no attribute 'AbstractFileSystem' ``` ## Suggested fix ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I found the the docs on migrating from previous packages useful - paragraph 4.
https://huggingface.co/transformers/migration.html
I added ‘return_dict=False’ to my model argument and it worked as it should.
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.