Open tobegit3hub opened 4 years ago
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.
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: https://github.com/tensorflow/tensorflow/issues/42325
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 likemnist_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 liketf.contrib.lookup.index_to_string_table_from_tensor
.