tf.contrib.lookup.index_to_string

View source on GitHub

Maps tensor of indices into string values based on mapping. (deprecated)

This operation converts int64 indices into string values. The mapping is initialized from a string mapping 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 'mapping' (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) once.

For example:

mapping_string = tf.constant(["emerson", "lake", "palmer"])
indices = tf.constant([1, 5], tf.int64)
values = tf.contrib.lookup.index_to_string(
    indices, mapping=mapping_string, default_value="UNKNOWN")
...
tf.compat.v1.tables_initializer().run()

values.eval() ==> ["lake", "UNKNOWN"]

tensor A int64 Tensor with the indices to map to strings.
mapping A 1-D string Tensor that specifies the strings to map from indices.
default_value The string value to use for out-of-vocabulary indices.
name A name for this op (optional).

The strings values associated to the indices. The resultant dense feature value tensor has the same shape as the corresponding indices.