Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting Error while calling BERTClassifier #66

Open
Gaurav7004 opened this issue Feb 2, 2022 · 4 comments
Open

Getting Error while calling BERTClassifier #66

Gaurav7004 opened this issue Feb 2, 2022 · 4 comments

Comments

@Gaurav7004
Copy link

import transformers
import aspect_based_sentiment_analysis as absa

name = 'absa/classifier-rest-0.2'
model = absa.BertABSClassifier.from_pretrained(name)
tokenizer = absa.BertTokenizer.from_pretrained(name)


ValueError Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_40004/473772509.py in
5
6 name = 'absa/classifier-rest-0.2'
----> 7 model = absa.BertABSClassifier.from_pretrained(name)
8
9 tokenizer = BertTokenizer.from_pretrained(model)

~\Anaconda3\lib\site-packages\transformers\modeling_tf_utils.py in from_pretrained(cls, pretrained_model_name_or_path, *model_args, **kwargs)
1593 model(model.dummy_inputs) # build the network with dummy inputs
1594 else:
-> 1595 model(model.dummy_inputs) # build the network with dummy inputs
1596
1597 assert os.path.isfile(resolved_archive_file), f"Error retrieving file {resolved_archive_file}"

~\Anaconda3\lib\site-packages\keras\utils\traceback_utils.py in error_handler(*args, **kwargs)
65 except Exception as e: # pylint: disable=broad-except
66 filtered_tb = _process_traceback_frames(e.traceback)
---> 67 raise e.with_traceback(filtered_tb) from None
68 finally:
69 del filtered_tb

~\Anaconda3\lib\site-packages\aspect_based_sentiment_analysis\models.py in call(self, token_ids, attention_mask, token_type_ids, training, **bert_kwargs)
139 **bert_kwargs
140 ) -> Tuple[tf.Tensor, Tuple[tf.Tensor, ...], Tuple[tf.Tensor, ...]]:
--> 141 outputs = self.bert(
142 inputs=token_ids,
143 attention_mask=attention_mask,

ValueError: Exception encountered when calling layer "bert_abs_classifier_10" (type BertABSClassifier).

The first argument to Layer.call must always be passed.

Call arguments received:
• token_ids={'input_ids': 'tf.Tensor(shape=(3, 5), dtype=int32)'}
• attention_mask=None
• token_type_ids=None
• training=False
• bert_kwargs=<class 'inspect._empty'>

@caballeto
Copy link

Getting same error.

@liorc-git
Copy link

liorc-git commented Mar 31, 2022

I have the same problem with python 3.9 (worked well with 3.8).
Also - can anyone shed some light about the difference between the models absa/bert-rest-0.2 and absa/classifiers-rest-0.2 ? As in some of my attempts I noticed that the first managed to load and the second didn't.
In https://huggingface.co/absa it seems they were all updated at the same date.

@pmenonlek
Copy link

Getting the same error when working in python 3.9

@linayc
Copy link

linayc commented Mar 2, 2023

Facing this issue as well..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants