Aspect-Based-Sentiment-Analysis
Aspect-Based-Sentiment-Analysis copied to clipboard
ValueError: The first argument to `Layer.call` must always be passed.
I install your module and run quick start
import aspect_based_sentiment_analysis as absa
recognizer = absa.aux_models.BasicPatternRecognizer()
nlp = absa.load(pattern_recognizer=recognizer)
and the following error occurred.
ValueError Traceback (most recent call last)
<ipython-input-356-900f8907a6c9> in <module>
2
3 recognizer = absa.aux_models.BasicPatternRecognizer()
----> 4 nlp = absa.load(pattern_recognizer=recognizer)
~/anaconda3/envs/myenv1/lib/python3.8/site-packages/aspect_based_sentiment_analysis/loads.py in load(name, text_splitter, reference_recognizer, pattern_recognizer, **model_kwargs)
32 try:
33 config = BertABSCConfig.from_pretrained(name, **model_kwargs)
---> 34 model = BertABSClassifier.from_pretrained(name, config=config)
35 tokenizer = transformers.BertTokenizer.from_pretrained(name)
36 professor = Professor(reference_recognizer, pattern_recognizer)
~/anaconda3/envs/myenv1/lib/python3.8/site-packages/transformers/modeling_tf_utils.py in from_pretrained(cls, pretrained_model_name_or_path, *model_args, **kwargs)
~/anaconda3/envs/myenv1/lib/python3.8/site-packages/tensorflow/python/keras/engine/base_layer.py in __call__(self, *args, **kwargs)
1010 def trainable(self, value):
1011 self._trainable = value
-> 1012 for layer in getattr(self, '_layers', []):
1013 layer.trainable = value
1014
~/anaconda3/envs/myenv1/lib/python3.8/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,
~/anaconda3/envs/myenv1/lib/python3.8/site-packages/tensorflow/python/keras/engine/base_layer.py in __call__(self, *args, **kwargs)
940 # TODO(fchollet): consider py_func as an alternative, which
941 # would enable us to run the underlying graph if needed.
--> 942 outputs = self._symbolic_call(inputs)
943
944 if outputs is None:
~/anaconda3/envs/myenv1/lib/python3.8/site-packages/tensorflow/python/keras/engine/base_layer.py in _split_out_first_arg(self, args, kwargs)
ValueError: The first argument to `Layer.call` must always be passed.
Can I know the solution?
I'm having the exact same problem.
same issue. bump
Note. This is likely a dependency issue @AschHarwood . If you create a conda env using the environment.yml mine works fine.
Has anyone solved the problem? I have the same issue.
the code works if you run in google colab
I had the same issue. I think it is caused by installing a newer version of transformers (4.6.1) while aspect-based-sentiment-analysis needs 2.5.0. Could also be caused by a different library that is updated by newer versions of transformers.
Running in the same issue, (installation for transformers 2.5.0 is also very problematic, so far unable to try this fix)