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

Upgrade examples to TensorFlow 2 in develop and 2.x docker images #1606

Open
tobegit3hub opened this issue Apr 23, 2020 · 2 comments
Open

Upgrade examples to TensorFlow 2 in develop and 2.x docker images #1606

tobegit3hub opened this issue Apr 23, 2020 · 2 comments

Comments

@tobegit3hub
Copy link
Contributor

tobegit3hub commented Apr 23, 2020

Now we follow the official documents to build and test tensorflow serving with latest dev docker image. The examples can not be run successfully because the tensorflow version is 2.1.0 in tensorflow/serving:latest-devel while the examples code like mnist_saved_model.py still uses TensorFlow 1.x APIs.

We should upgrade the examples to TensorFlow 2 so that users can build and test with latest docker images.

BTW, simply using tf_upgrade_v2 ./mnist_saved_model.py will not work because of some deprecated APIs like tf.contrib.lookup.index_to_string_table_from_tensor.

@tobegit3hub
Copy link
Contributor Author

The function index_to_string_table_from_tensor is not export in Python API after moving to TensorFlow 2.x core.

def index_to_string_table_from_tensor(vocabulary_list,
                                      default_value="UNK",
                                      name=None):
  """Returns a lookup table that maps a `Tensor` of indices into strings.

  This operation constructs a lookup table to map int64 indices into string
  values. The mapping is initialized from a string `vocabulary_list` 1-D
  `Tensor` where each element is a value and the corresponding index within the
  tensor is the key.

  Any input which does not have a corresponding index in 'vocabulary_list'
  (an out-of-vocabulary entry) is assigned the `default_value`

  The underlying table must be initialized by calling
  `session.run(tf.compat.v1.tables_initializer())` or
  `session.run(table.init())` once.

  Elements in `vocabulary_list` cannot have duplicates, otherwise when executing
  the table initializer op, it will throw a `FailedPreconditionError`.

  Sample Usages:

I'm not sure if we can request tensorflow to expose these APIs. If so, it is pretty easy to make these example scripts work as usual.

@spate141
Copy link

I agree with @tobegit3hub I'm dealing with similar issue with tables_initializer() and TF2.x code. How do I export my model for serving which is using StaticHashTables? I can't find any documentation anywhere!

CC: @gowthamkpr @misterpeddy

More info: tensorflow/tensorflow#42325

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

6 participants