TFBertForSequenceClassification: TypeError: call() got an unexpected keyword argument 'labels'
See original GitHub issue🐛 Bug
Information
Model I am using TFBertForSequenceClassification
Language I am using the model on: English
The problem arises when using:
- the official example scripts: (give details below)
The tasks I am working on is:
- my own task or dataset: (give details below) To classify text and learn the model and package.
To reproduce
Steps to reproduce the behavior:
- pip install transformers (currently 2.11.0)
- run default code on website: https://huggingface.co/transformers/model_doc/bert.html#tfbertforsequenceclassification
- I tried to follow this: https://github.com/huggingface/transformers/issues/4848; and the issue remains the same.
import tensorflow as tf
from transformers import BertTokenizer, TFBertForSequenceClassification
tokenizer = BertTokenizer.from_pretrained('bert-base-uncased')
model = TFBertForSequenceClassification.from_pretrained('bert-base-uncased')
input_ids = tf.constant(tokenizer.encode("Hello, my dog is cute"))[None, :] # Batch size 1
labels = tf.reshape(tf.constant(1), (-1, 1)) # Batch size 1
outputs = model(input_ids, labels=labels)
loss, logits = outputs[:2]
Environment info
transformers
version: 2.11.0- Platform: Windows-10-10.0.18362-SP0
- Python version: 3.7.7
- PyTorch version (GPU?): not installed (NA)
- Tensorflow version (GPU?): 2.2.0 (True)
- Using GPU in script?: Yes
- Using distributed or parallel set-up in script?: No
Issue Analytics
- State:
- Created 3 years ago
- Comments:19 (1 by maintainers)
Top Results From Across the Web
nlp - Transformer TFBertForSequenceClassification Error ...
Transformer TFBertForSequenceClassification Error(compute_loss() got an unexpected keyword argument 'labels').
Read more >compute_loss() got an unexpected keyword argument 'labels ...
In particular, I'm getting an error TypeError: compute_loss() got an unexpected keyword argument 'labels' and I'm not really sure how to fix it....
Read more >ccompiler_spawn() got an unexpected keyword argument 'env ...
I got the same error when using Python 3.10. Apache-Superset currently only supports ... TypeError: call() got an unexpected keyword argument 'labels'#5151.
Read more >TypeError: forward() got an unexpected keyword argument ...
Anyway I'm trying to implement a Bert Classifier to discriminate between 2 sequences classes (BINARY CLASSIFICATION), with AX hyperparameters ...
Read more >Why do I get a keyword argument 'label' error on this form?
Why do I get a keyword argument 'label' error on ad_image1 __init__() got an unexpected keyword argument 'label' for my form class…
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
It is available in the version v3.0.0 which was released this morning 😃
You should try this
pip install git+https://github.com/huggingface/transformers
notpip install transformers
because the latest version isn’t available in any release