tf.tpu.experimental.embedding.FeatureConfig

Configuration data for one embedding feature.

This class holds the configuration data for a single embedding feature. The main use is to assign features to tf.tpu.experimental.embedding.TableConfigs via the table parameter:

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.

When feeding features into embedding.enqueue they can be tf.Tensors, tf.SparseTensors or tf.RaggedTensors. When the argument max_sequence_length is 0, the default, you should expect a output of embedding.dequeue for this feature of shape (batch_size, dim). If max_sequence_length is greater than 0, the feature is embedded as a sequence and padded up to the given length. The shape of the output for this feature will be (batch_size, max_sequence_length, dim).

table An instance of tf.tpu.experimental.embedding.TableConfig, describing the table in which this feature should be looked up.
max_sequence_length If positive, the feature is a sequence feature with the corresponding maximum sequence length. If the sequence is longer than this, it will be truncated. If 0, the feature is not a sequence feature.
name An optional name for the feature, useful for debugging.

ValueError if table is not an instance of