tf.data.experimental.DatasetInitializer  |  TensorFlow v2.16.1 (original) (raw)

tf.data.experimental.DatasetInitializer

Stay organized with collections Save and categorize content based on your preferences.

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

View aliases

Compat aliases for migration

SeeMigration guide for more details.

tf.compat.v1.data.experimental.DatasetInitializer

tf.data.experimental.DatasetInitializer(
    dataset
)

Sample usage:

keys = tf.data.Dataset.range(100) values = tf.data.Dataset.range(100).map( lambda x: tf.strings.as_string(x * 2)) ds = tf.data.Dataset.zip((keys, values)) init = tf.data.experimental.DatasetInitializer(ds) table = tf.lookup.StaticHashTable(init, "") table.lookup(tf.constant([0, 1, 2], dtype=tf.int64)).numpy() array([b'0', b'2', b'4'], dtype=object)

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

initialize(
    table
)

Returns the table initialization op.

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 2024-04-26 UTC.