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

apply_saved_models for Tensorflow 2.7 models #282

Open
agrimabahl opened this issue Jul 8, 2022 · 1 comment
Open

apply_saved_models for Tensorflow 2.7 models #282

agrimabahl opened this issue Jul 8, 2022 · 1 comment

Comments

@agrimabahl
Copy link

Hi 👋

My application uses the apply_saved_models api within tf-transform to run inference on tensorflow models.
For a TF2 model from tf-hub, when running apply_saved_models I get the following error -

---------------------------------------------------------------------------
NotImplementedError                       Traceback (most recent call last)
<ipython-input-30-594dff228f07> in <module>()
     19       constant_graph_def,
     20       input_map=inputs,
---> 21       return_elements=output_tensor_names + loaded_initializer_op_names)
     22

/usr/local/lib/python3.7/site-packages/tensorflow/python/util/deprecation.py in new_func(*args, **kwargs)
    550                 'in a future version' if date is None else ('after %s' % date),
    551                 instructions)
--> 552       return func(*args, **kwargs)
    553
    554     doc = _add_deprecated_arg_notice_to_docstring(

/usr/local/lib/python3.7/site-packages/tensorflow/python/framework/importer.py in import_graph_def(***failed resolving arguments***)
    410       return_elements=return_elements,
    411       name=name,
--> 412       producer_op_list=producer_op_list)
    413
    414

/usr/local/lib/python3.7/site-packages/tensorflow/python/framework/importer.py in _import_graph_def_internal(graph_def, input_map, return_elements, validate_colocation_constraints, name, producer_op_list)
    492   options = scoped_options.options
    493   _PopulateTFImportGraphDefOptions(options, prefix, input_map, return_elements,
--> 494                                    validate_colocation_constraints)
    495
    496   # _ProcessNewOps mutates the new operations. _mutation_lock ensures a

/usr/local/lib/python3.7/site-packages/tensorflow/python/framework/importer.py in _PopulateTFImportGraphDefOptions(options, prefix, input_map, return_elements, validate_colocation_constraints)
    227       src_name, src_idx = _ParseTensorName(input_src)
    228       src_name = compat.as_str(src_name)
--> 229       dst_output = input_dst._as_tf_output()  # pylint: disable=protected-access
    230       c_api.TF_ImportGraphDefOptionsAddInputMapping(options, src_name, src_idx,
    231                                                     dst_output)

/usr/local/lib/python3.7/site-packages/tensorflow/python/framework/ops.py in _as_tf_output(self)
   1330   def _as_tf_output(self):
   1331     raise NotImplementedError(
-> 1332         "_as_tf_output not supported when eager execution is enabled.")
   1333
   1334   def eval(self, feed_dict=None, session=None):

NotImplementedError: _as_tf_output not supported when eager execution is enabled.

is there an alternative API more suited to TF2 models since apply_saved_models can only be used with TF2 behavior disabled and TF2 does not support GraphDefs.

Thank you!

@zoyahav
Copy link
Member

zoyahav commented Jul 21, 2022

Could you share with us the code snippet you're running?
And which API you're using, is it pretrained_models.apply_saved_model, and how is it used?

Since you're running into an eager execution error, it's not clear to me how tensorflow-transform is used here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants