tf.compat.v1.tables_initializer
Stay organized with collections
Save and categorize content based on your preferences.
Returns an Op that initializes all tables of the default graph.
tf.compat.v1.tables_initializer(
name='init_all_tables'
)
tf.compat.v1.tables_initializer
is no longer needed with eager execution and
tf.function
. In TF2, when creating an initializable table like a
tf.lookup.StaticHashTable
, the table will automatically be initialized on
creation.
Before & After Usage Example
Before:
with tf.compat.v1.Session():
init = tf.compat.v1.lookup.KeyValueTensorInitializer(['a', 'b'], [1, 2])
table = tf.compat.v1.lookup.StaticHashTable(init, default_value=-1)
tf.compat.v1.tables_initializer().run()
result = table.lookup(tf.constant(['a', 'c'])).eval()
result
array([ 1, -1], dtype=int32)
After:
init = tf.lookup.KeyValueTensorInitializer(['a', 'b'], [1, 2])
table = tf.lookup.StaticHashTable(init, default_value=-1)
table.lookup(tf.constant(['a', 'c'])).numpy()
array([ 1, -1], dtype=int32)
Description
Args |
name
|
Optional name for the initialization op.
|
Returns |
An Op that initializes all tables. Note that if there are
not tables the returned Op is a NoOp.
|
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates. Some content is licensed under the numpy license.
Last updated 2023-10-06 UTC.
[{
"type": "thumb-down",
"id": "missingTheInformationINeed",
"label":"Missing the information I need"
},{
"type": "thumb-down",
"id": "tooComplicatedTooManySteps",
"label":"Too complicated / too many steps"
},{
"type": "thumb-down",
"id": "outOfDate",
"label":"Out of date"
},{
"type": "thumb-down",
"id": "samplesCodeIssue",
"label":"Samples / code issue"
},{
"type": "thumb-down",
"id": "otherDown",
"label":"Other"
}]
[{
"type": "thumb-up",
"id": "easyToUnderstand",
"label":"Easy to understand"
},{
"type": "thumb-up",
"id": "solvedMyProblem",
"label":"Solved my problem"
},{
"type": "thumb-up",
"id": "otherUp",
"label":"Other"
}]
{"lastModified": "Last updated 2023-10-06 UTC."}
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2023-10-06 UTC."],[],[]]