[null,null,["Last updated 2024-04-26 UTC."],[],[],null,["# tf.compat.v1.tables_initializer\n\n\u003cbr /\u003e\n\n|-----------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.16.1/tensorflow/python/ops/lookup_ops.py#L67-L108) |\n\nReturns an Op that initializes all tables of the default graph.\n\n#### View aliases\n\n\n**Compat aliases for migration**\n\nSee\n[Migration guide](https://www.tensorflow.org/guide/migrate) for\nmore details.\n\n[`tf.compat.v1.initializers.tables_initializer`](https://www.tensorflow.org/api_docs/python/tf/compat/v1/tables_initializer)\n\n\u003cbr /\u003e\n\n tf.compat.v1.tables_initializer(\n name='init_all_tables'\n )\n\n\u003cbr /\u003e\n\nMigrate to TF2\n--------------\n\n\u003cbr /\u003e\n\n| **Caution:** This API was designed for TensorFlow v1. Continue reading for details on how to migrate from this API to a native TensorFlow v2 equivalent. See the [TensorFlow v1 to TensorFlow v2 migration guide](https://www.tensorflow.org/guide/migrate) for instructions on how to migrate the rest of your code.\n\n[`tf.compat.v1.tables_initializer`](../../../tf/compat/v1/tables_initializer) is no longer needed with eager execution and\n[`tf.function`](../../../tf/function). In TF2, when creating an initializable table like a\n[`tf.lookup.StaticHashTable`](../../../tf/lookup/StaticHashTable), the table will automatically be initialized on\ncreation.\n\n#### Before \\& After Usage Example\n\nBefore: \n\n with tf.compat.v1.Session():\n init = tf.compat.v1.lookup.KeyValueTensorInitializer(['a', 'b'], [1, 2])\n table = tf.compat.v1.lookup.StaticHashTable(init, default_value=-1)\n tf.compat.v1.tables_initializer().run()\n result = table.lookup(tf.constant(['a', 'c'])).eval()\n result\n array([ 1, -1], dtype=int32)\n\nAfter: \n\n init = tf.lookup.KeyValueTensorInitializer(['a', 'b'], [1, 2])\n table = tf.lookup.StaticHashTable(init, default_value=-1)\n table.lookup(tf.constant(['a', 'c'])).numpy()\n array([ 1, -1], dtype=int32)\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\nDescription\n-----------\n\n### Used in the notebooks\n\n| Used in the tutorials |\n|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| - [Universal Sentence Encoder-Lite demo](https://www.tensorflow.org/hub/tutorials/semantic_similarity_with_tf_hub_universal_encoder_lite) - [Wiki40B Language Models](https://www.tensorflow.org/hub/tutorials/wiki40b_lm) |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|--------|------------------------------------------|\n| `name` | Optional name for the initialization op. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ------- ||\n|---|---|\n| An Op that initializes all tables. Note that if there are not tables the returned Op is a NoOp. ||\n\n\u003cbr /\u003e"]]