question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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:

  1. pip install transformers (currently 2.11.0)
  2. run default code on website: https://huggingface.co/transformers/model_doc/bert.html#tfbertforsequenceclassification
  3. 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:closed
  • Created 3 years ago
  • Comments:19 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
LysandreJikcommented, Jun 29, 2020

It is available in the version v3.0.0 which was released this morning 😃

1reaction
QixinLicommented, Jun 27, 2020

You should try this pip install git+https://github.com/huggingface/transformers not pip install transformers because the latest version isn’t available in any release

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found