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

Error with shape of arguments for Google Patents saved model prediction #34

Open
LAristodemou opened this issue Jan 20, 2021 · 1 comment
Assignees

Comments

@LAristodemou
Copy link

While running the following line of code:
response, inputs, masked_text = bert_predictor.predict(texts)
the following error comes up for the shape of the tensor. I have followed the jupyter notebook as is.
(tf version: 1.15.2)

----------------------Error--------------------------

`ValueError Traceback (most recent call last)
in ()
----> 1 response, inputs, masked_text = bert_predictor.predict(texts)
2 train_inputs = response['cls_token']
3 train_labels = tf.convert_to_tensor(classes)

3 frames
in predict(self, texts, mlm_ids, context_tokens)
140 input_mask=tf.convert_to_tensor(inputs['input_mask'], dtype=tf.int64),
141 input_ids=tf.convert_to_tensor(inputs['input_ids'], dtype=tf.int64),
--> 142 mlm_positions=tf.convert_to_tensor(inputs['mlm_ids'], dtype=tf.int64),
143 )
144

/tensorflow-1.15.2/python3.6/tensorflow_core/python/eager/function.py in call(self, *args, **kwargs)
1079 TypeError: For invalid positional/keyword argument combinations.
1080 """
-> 1081 return self._call_impl(args, kwargs)
1082
1083 def _call_impl(self, args, kwargs, cancellation_manager=None):

/tensorflow-1.15.2/python3.6/tensorflow_core/python/eager/function.py in _call_impl(self, args, kwargs, cancellation_manager)
1119 raise TypeError("Keyword arguments {} unknown. Expected {}.".format(
1120 list(kwargs.keys()), list(self._arg_keywords)))
-> 1121 return self._call_flat(args, self.captured_inputs, cancellation_manager)
1122
1123 def _filtered_call(self, args, kwargs):

/tensorflow-1.15.2/python3.6/tensorflow_core/python/eager/function.py in _call_flat(self, args, captured_inputs, cancellation_manager)
1208 arg_name, arg,
1209 self._func_graph.inputs[i].shape,
-> 1210 arg.shape))
1211 elif (self._signature is not None and
1212 isinstance(self._signature[i], tensor_spec.TensorSpec)):

ValueError: The argument 'mlm_positions' (value Tensor("Const_20:0", shape=(0,), dtype=int64)) is not compatible with the shape this function was traced with. Expected shape (?, 45), but got shape (0,).

If you called get_concrete_function, you may need to pass a tf.TensorSpec(..., shape=...) with a less specific shape, having None on axes which can vary.`

@robert-srebrovic
Copy link
Collaborator

robert-srebrovic commented Jan 22, 2021

The code is only compatible with tf2, could you try re-running with tensorflow >= 2.0? You may need to run "!pip install tensorflow" in the colab notebook. Then to confirm your version "print(tf.__version__)".

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

3 participants