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

Can't reproduce the exampe in the Readme #21

Open
IlnarSelimcan opened this issue May 25, 2023 · 3 comments
Open

Can't reproduce the exampe in the Readme #21

IlnarSelimcan opened this issue May 25, 2023 · 3 comments

Comments

@IlnarSelimcan
Copy link

Hi,

first of all, thanks for sharing this code!

When I copy-paste the example from the Examples section of the Readme, the line output = reloaded_model([s1, s2, s3]) causes the following error:

In [16]: output = reloaded_model([s1, s2, s3])
    ...: 
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-16-977dbd3103dd> in <cell line: 1>()
----> 1 output = reloaded_model([s1, s2, s3])

~/.cache/pypoetry/virtualenvs/tftokenizers-F6-m1WpK-py3.8/lib/python3.8/site-packages/tensorflow/python/saved_model/load.py in _call_attribute(instance, *args, **kwargs)
    699 
    700 def _call_attribute(instance, *args, **kwargs):
--> 701   return instance.__call__(*args, **kwargs)
    702 
    703 

~/.cache/pypoetry/virtualenvs/tftokenizers-F6-m1WpK-py3.8/lib/python3.8/site-packages/tensorflow/python/util/traceback_utils.py in error_handler(*args, **kwargs)
    151     except Exception as e:
    152       filtered_tb = _process_traceback_frames(e.__traceback__)
--> 153       raise e.with_traceback(filtered_tb) from None
    154     finally:
    155       del filtered_tb

~/.cache/pypoetry/virtualenvs/tftokenizers-F6-m1WpK-py3.8/lib/python3.8/site-packages/tensorflow/python/saved_model/function_deserialization.py in restored_function_body(*args, **kwargs)
    261     """Calls a restored function or raises an error if no matching function."""
    262     if not saved_function.concrete_functions:
--> 263       raise ValueError("Found zero restored functions for caller function.")
    264     # This is the format of function.graph.structured_input_signature. At this
    265     # point, the args and kwargs have already been canonicalized.

ValueError: Found zero restored functions for caller function.

Have you guys ever encountered that before?

@IlnarSelimcan
Copy link
Author

Packages were installed this way:

## git clone https://github.com/Hugging-Face-Supporter/tftokenizers.git
## cd tftokenizers
## conda create -n py38 python=3.8
## conda activate py38
## curl -sSL https://install.python-poetry.org/ | python3 -
## poetry env use `which python3.8`
## poetry shell
## poetry install

@IlnarSelimcan
Copy link
Author

@IlnarSelimcan
Copy link
Author

The following change made the error go away:

selimcan@patroclus:/tmp/tft/tftokenizers$ git diff
diff --git a/tftokenizers/model.py b/tftokenizers/model.py
index 1d91bca..ef77ea0 100644
--- a/tftokenizers/model.py
+++ b/tftokenizers/model.py
@@ -39,6 +39,7 @@ class TFModel(keras.layers.Layer):
         self.tokenizer = tokenizer
         self.model = model
 
+    @tf.function(input_signature=(tf.TensorSpec(shape=[None], dtype=tf.string),))
     def call(
         self,
         inputs,

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

1 participant