This operation converts tensor of strings into int64 indices.
The mapping is initialized from a string mapping tensor where each element
is a key and corresponding index within the tensor is the value.
Any entry in the input which does not have a corresponding entry in 'mapping'
(an out-of-vocabulary entry) is assigned the default_value
Elements in mapping cannot be duplicated, otherwise the initialization
will throw a FailedPreconditionError.
The underlying table must be initialized by calling
session.run(tf.compat.v1.tables_initializer) once.
[null,null,["Last updated 2020-10-01 UTC."],[],[],null,["# tf.contrib.lookup.string_to_index\n\n\u003cbr /\u003e\n\n|----------------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v1.15.0/tensorflow/contrib/lookup/lookup_ops.py#L146-L192) |\n\nMaps `tensor` of strings into `int64` indices based on `mapping`. (deprecated) \n\n tf.contrib.lookup.string_to_index(\n tensor, mapping, default_value=-1, name=None\n )\n\n| **Warning:** THIS FUNCTION IS DEPRECATED. It will be removed after 2017-01-07. Instructions for updating: This op will be removed after the deprecation date. Please switch to index_table_from_tensor and call the lookup method of the returned table.\n\nThis operation converts `tensor` of strings into `int64` indices.\nThe mapping is initialized from a string `mapping` tensor where each element\nis a key and corresponding index within the tensor is the value.\n\nAny entry in the input which does not have a corresponding entry in 'mapping'\n(an out-of-vocabulary entry) is assigned the `default_value`\n\nElements in `mapping` cannot be duplicated, otherwise the initialization\nwill throw a FailedPreconditionError.\n\nThe underlying table must be initialized by calling\n`session.run(tf.compat.v1.tables_initializer)` once.\n\n#### For example:\n\n mapping_strings = tf.constant([\"emerson\", \"lake\", \"palmer\"])\n feats = tf.constant([\"emerson\", \"lake\", \"and\", \"palmer\"])\n ids = tf.contrib.lookup.string_to_index(\n feats, mapping=mapping_strings, default_value=-1)\n ...\n tf.compat.v1.tables_initializer().run()\n\n ids.eval() ==\u003e [0, 1, -1, 2]\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|-----------------|-------------------------------------------------------------------------|\n| `tensor` | A 1-D input `Tensor` with the strings to map to indices. |\n| `mapping` | A 1-D string `Tensor` that specifies the mapping of strings to indices. |\n| `default_value` | The `int64` value to use for out-of-vocabulary strings. Defaults to -1. |\n| `name` | A name for this op (optional). |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ------- ||\n|---|---|\n| The mapped indices. It has the same shape and tensor type (dense or sparse) as `tensor`. ||\n\n\u003cbr /\u003e"]]