tf.tpu.experimental.embedding.TableConfig

Configuration data for one embedding table.

Used in the notebooks

Used in the guide Used in the tutorials

This class holds the configuration data for a single embedding table. It is used as the table parameter of a tf.tpu.experimental.embedding.FeatureConfig. Multiple tf.tpu.experimental.embedding.FeatureConfig objects can use the same tf.tpu.experimental.embedding.TableConfig object. In this case a shared table will be created for those feature lookups.

table_config_one = tf.tpu.experimental.embedding.TableConfig(
    vocabulary_size=...,
    dim=...)
table_config_two = tf.tpu.experimental.embedding.TableConfig(
    vocabulary_size=...,
    dim=...)
feature_config = {
    'feature_one': tf.tpu.experimental.embedding.FeatureConfig(
        table=table_config_one),
    'feature_two': tf.tpu.experimental.embedding.FeatureConfig(
        table=table_config_one),
    'feature_three': tf.tpu.experimental.embedding.FeatureConfig(
        table=table_config_two)}
embedding = tf.tpu.experimental.embedding.TPUEmbedding(
    feature_config=feature_config,
    batch_size=...
    optimizer=tf.tpu.experimental.embedding.Adam(0.1))

The above configuration has 2 tables, and three features. The first two features will be looked up in the first table and the third feature will be looked up in the second table.

vocabulary_size Size of the table's vocabulary (number of rows).
dim The embedding dimension (width) of the table.
initializer A callable initializer taking one parameter, the shape of the variable that will be initialized. Will be called once per task, to initialize that task's shard of the embedding table. If not specified, defaults to truncated_normal_initializer with mean 0.0 and standard deviation 1/sqrt(dim).
optimizer An optional instance of an optimizer parameters class, instance of one of tf.tpu.experimental.embedding.SGD, tf.tpu.experimental.embedding.Adagrad or tf.tpu.experimental.embedding.Adam. If set will override the global optimizer passed to tf.tpu.experimental.embedding.TPUEmbedding.
combiner A string specifying how to reduce if there are multiple entries in a single row. Currently 'mean', 'sqrtn', 'sum' are supported, with 'mean' the default. 'sqrtn' often achieves good accuracy, in particular with bag-of-words columns. For more information, see tf.nn.embedding_lookup_sparse.
name An optional string used to name the table. Must be defined if running on SparseCore.
quantization_config The simulated quantization config. An instance of tf.tpu.experimental.embedding.QuantizationConfig. See the class for more documentation.
layout If the table already has its layout computed, you can pass it in here. Otherwise, we will compute it for you. Most users should leave this as None.

ValueError if vocabulary_size is not a positive integer.
ValueError if dim is not a positive integer.
ValueError if initializer is specified and is not callable.
ValueError if combiner is not supported.