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

ValueError: The first argument to Layer.call must always be passed. #43

Open
fspanda opened this issue Feb 23, 2021 · 7 comments
Open
Labels
help wanted Extra attention is needed

Comments

@fspanda
Copy link

fspanda commented Feb 23, 2021

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?

@rolczynski rolczynski added bug Something isn't working help wanted Extra attention is needed and removed bug Something isn't working labels Mar 8, 2021
@AschHarwood
Copy link

I'm having the exact same problem.

@mileschandler
Copy link

same issue. bump

@mileschandler
Copy link

Note. This is likely a dependency issue @AschHarwood . If you create a conda env using the environment.yml mine works fine.

@Nikola1023
Copy link

Has anyone solved the problem? I have the same issue.

@tatiana-norkina
Copy link

the code works if you run in google colab

@Schluca
Copy link

Schluca commented Jun 3, 2021

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.

@arditobryan
Copy link

Running in the same issue, (installation for transformers 2.5.0 is also very problematic, so far unable to try this fix)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

8 participants