W3cubDocs

/TensorFlow 2.3

tf.lookup.experimental.DatasetInitializer

Creates a table initializer from a tf.data.Dataset.

Sample usage:

keys = tf.data.Dataset.range(100)
values = tf.data.Dataset.range(100).map(
    lambda x: string_ops.as_string(x * 2))
ds = tf.data.Dataset.zip((keys, values))
init = tf.lookup.experimental.DatasetInitializer(ds)
table = tf.lookup.StaticHashTable(init, "")
output = table.lookup([0, 1, 2])
assertEquals(outputs, ["0", "2", "4"])

Raises: ValueError if dataset doesn't conform to specifications.

Args
dataset A tf.data.Dataset object that produces tuples of scalars. The first scalar is treated as a key and the second as value.
Attributes
dataset A tf.data.Dataset object that produces tuples of scalars. The first scalar is treated as a key and the second as value.
key_dtype The expected table key dtype.
value_dtype The expected table value dtype.

Methods

initialize

View source

Returns the table initialization op.

© 2020 The TensorFlow Authors. All rights reserved.
Licensed under the Creative Commons Attribution License 3.0.
Code samples licensed under the Apache 2.0 License.
https://www.tensorflow.org/versions/r2.3/api_docs/python/tf/lookup/experimental/DatasetInitializer