ScalaConsultants / Aspect-Based-Sentiment-Analysis

💭 Aspect-Based-Sentiment-Analysis: Transformer & Explainable ML (TensorFlow)
Apache License 2.0
543 stars 90 forks source link

value error #31

Closed dh12306 closed 3 years ago

dh12306 commented 3 years ago

@marioosh @lkuczera @molowny @marekklis @jczuchnowski

image

image

ValueError Traceback (most recent call last)

in 1 import aspect_based_sentiment_analysis as absa 2 ----> 3 nlp = absa.load() 4 text = ("We are great fans of Slack, but we wish the subscriptions " 5 "were more accessible to small startups.") D:\rj\ana3\lib\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) D:\rj\ana3\lib\site-packages\transformers\modeling_tf_utils.py in from_pretrained(cls, pretrained_model_name_or_path, *model_args, **kwargs) 728 return load_pytorch_checkpoint_in_tf2_model(model, resolved_archive_file, allow_missing_keys=True) 729 --> 730 model(model.dummy_inputs, training=False) # build the network with dummy inputs 731 732 assert os.path.isfile(resolved_archive_file), "Error retrieving file {}".format(resolved_archive_file) D:\rj\ana3\lib\site-packages\tensorflow\python\keras\engine\base_layer.py in __call__(self, *args, **kwargs) 983 984 with ops.enable_auto_cast_variables(self._compute_dtype_object): --> 985 outputs = call_fn(inputs, *args, **kwargs) 986 987 if self._activity_regularizer: D:\rj\ana3\lib\site-packages\aspect_based_sentiment_analysis\models.py in call(self, token_ids, attention_mask, token_type_ids, training, **bert_kwargs) 148 sequence_output, pooled_output, hidden_states, attentions = outputs 149 pooled_output = self.dropout(pooled_output, training=training) --> 150 logits = self.classifier(pooled_output) 151 return logits, hidden_states, attentions D:\rj\ana3\lib\site-packages\tensorflow\python\keras\engine\base_layer.py in __call__(self, *args, **kwargs) 980 with ops.name_scope_v2(name_scope): 981 if not self.built: --> 982 self._maybe_build(inputs) 983 984 with ops.enable_auto_cast_variables(self._compute_dtype_object): D:\rj\ana3\lib\site-packages\tensorflow\python\keras\engine\base_layer.py in _maybe_build(self, inputs) 2616 if not self.built: 2617 input_spec.assert_input_compatibility( -> 2618 self.input_spec, inputs, self.name) 2619 input_list = nest.flatten(inputs) 2620 if input_list and self._dtype_policy.compute_dtype is None: D:\rj\ana3\lib\site-packages\tensorflow\python\keras\engine\input_spec.py in assert_input_compatibility(input_spec, inputs, layer_name) 194 ', found ndim=' + str(ndim) + 195 '. Full shape received: ' + --> 196 str(x.shape.as_list())) 197 # Check dtype. 198 if spec.dtype is not None: ValueError: Input 0 of layer classifier is incompatible with the layer: : expected min_ndim=2, found ndim=0. Full shape received: [] what should I do about this error ? thx~
dh12306 commented 3 years ago

I downloaded model file but still not work

image

rolczynski commented 3 years ago

Please update to the version 2.0.2 - it should work now 😊