ScalaConsultants / Aspect-Based-Sentiment-Analysis

💭 Aspect-Based-Sentiment-Analysis: Transformer & Explainable ML (TensorFlow)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Getting error with basic first code

theoflaus opened this issue · comments

Hi, I tried only the first lines of code that were :

import aspect_based_sentiment_analysis as absa

nlp = absa.load()
text = ("We are great fans of Slack, but we wish the subscriptions "
        "were more accessible to small startups.")

slack, price = nlp(text, aspects=['slack', 'price'])
assert price.sentiment == absa.Sentiment.negative
assert slack.sentiment == absa.Sentiment.positive

and got the following error :

Traceback (most recent call last):
File "test_absa.py", line 3, in
nlp = absa.load()
File "C:\Users\theo.flaus\Anaconda3\envs\test\lib\site-packages\aspect_based_sentiment_analysis\loads.py", line 34, in load
model = BertABSClassifier.from_pretrained(name, config=config)
File "C:\Users\theo.flaus\Anaconda3\envs\test\lib\site-packages\transformers\modeling_tf_utils.py", line 2699, in from_pretrained
model(model.dummy_inputs) # build the network with dummy inputs
File "C:\Users\theo.flaus\Anaconda3\envs\test\lib\site-packages\keras\utils\traceback_utils.py", line 67, in error_handler
raise e.with_traceback(filtered_tb) from None
File "C:\Users\theo.flaus\Anaconda3\envs\test\lib\site-packages\aspect_based_sentiment_analysis\models.py", line 141, in call
outputs = self.bert(
ValueError: Exception encountered when calling layer "bert_abs_classifier" (type BertABSClassifier).
The first argument to Layer.call must always be passed.

Call arguments received by layer "bert_abs_classifier" (type BertABSClassifier):
• 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'>

Any idea how to solve this ?

Same here, any solutions?

I got the same error. For me it was solved when I installed from the environment.yml. My problem in specific is that I had Python >3.7

A bit late, but can confirm (at least for me) changing Python version immediately fixed the issue.

To create a new virtual environment with Python version 3.6 in Jupyter Notebook, take a look at this.

This is what it looks like for me:
image

I am unable to install python version 3.6 on jupyter notebook colab. I get an error like this
image
Any ideas why this might be the case?
@VedantNemane

@VedantNemane I installed 3.6.13 venv on pycharm and that can deal with the installation at least. btw 3.6.8 and 3.6.10 didn't help installing this package. Thanks for the guide!