transformers: TFBertForSequenceClassification: TypeError: call() got an unexpected keyword argument 'labels'
π 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
transformersversion: 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
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 19 (1 by maintainers)
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/transformersnotpip install transformersbecause the latest version isnβt available in any release