tf.tpu.experimental.embedding.FeatureConfig
Stay organized with collections
Save and categorize content based on your preferences.
Configuration data for one embedding feature.
tf.tpu.experimental.embedding.FeatureConfig(
table, max_sequence_length=0, name=None
)
This class holds the configuration data for a single embedding feature. The
main use is to assign features to tf.tpu.experimental.embedding.TableConfig
s
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.Tensor
s,
tf.SparseTensor
s or tf.RaggedTensor
s. 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)
.
Args |
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.
|
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.
Last updated 2020-10-01 UTC.
[null,null,["Last updated 2020-10-01 UTC."],[],[],null,["# tf.tpu.experimental.embedding.FeatureConfig\n\n\u003cbr /\u003e\n\n|-----------------------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.3.0/tensorflow/python/tpu/tpu_embedding_v2_utils.py#L547-L618) |\n\nConfiguration data for one embedding feature.\n\n#### View aliases\n\n\n**Compat aliases for migration**\n\nSee\n[Migration guide](https://www.tensorflow.org/guide/migrate) for\nmore details.\n\n[`tf.compat.v1.tpu.experimental.embedding.FeatureConfig`](/api_docs/python/tf/tpu/experimental/embedding/FeatureConfig)\n\n\u003cbr /\u003e\n\n tf.tpu.experimental.embedding.FeatureConfig(\n table, max_sequence_length=0, name=None\n )\n\nThis class holds the configuration data for a single embedding feature. The\nmain use is to assign features to [`tf.tpu.experimental.embedding.TableConfig`](../../../../tf/tpu/experimental/embedding/TableConfig)s\nvia the table parameter: \n\n table_config_one = tf.tpu.experimental.embedding.TableConfig(\n vocabulary_size=...,\n dim=...)\n table_config_two = tf.tpu.experimental.embedding.TableConfig(\n vocabulary_size=...,\n dim=...)\n feature_config = {\n 'feature_one': tf.tpu.experimental.embedding.FeatureConfig(\n table=table_config_one),\n 'feature_two': tf.tpu.experimental.embedding.FeatureConfig(\n table=table_config_one),\n 'feature_three': tf.tpu.experimental.embedding.FeatureConfig(\n table=table_config_two)}\n embedding = tf.tpu.experimental.embedding.TPUEmbedding(\n feature_config=feature_config,\n batch_size=...\n optimizer=tf.tpu.experimental.embedding.Adam(0.1))\n\nThe above configuration has 2 tables, and three features. The first two\nfeatures will be looked up in the first table and the third feature will be\nlooked up in the second table.\n\nWhen feeding features into `embedding.enqueue` they can be [`tf.Tensor`](../../../../tf/Tensor)s,\n[`tf.SparseTensor`](../../../../tf/sparse/SparseTensor)s or [`tf.RaggedTensor`](../../../../tf/RaggedTensor)s. When the argument\n`max_sequence_length` is 0, the default, you should expect a output of\n`embedding.dequeue` for this feature of shape `(batch_size, dim)`. If\n`max_sequence_length` is greater than 0, the feature is embedded as a sequence\nand padded up to the given length. The shape of the output for this feature\nwill be `(batch_size, max_sequence_length, dim)`.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|-----------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `table` | An instance of [`tf.tpu.experimental.embedding.TableConfig`](../../../../tf/tpu/experimental/embedding/TableConfig), describing the table in which this feature should be looked up. |\n| `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. |\n| `name` | An optional name for the feature, useful for debugging. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Raises ------ ||\n|--------------|----------------------------------------------------------------------------------------------------------------------------------------|\n| `ValueError` | if `table` is not an instance of [`tf.tpu.experimental.embedding.TableConfig`](../../../../tf/tpu/experimental/embedding/TableConfig). |\n| `ValueError` | if `max_sequence_length` not an integer or is negative. |\n\n\u003cbr /\u003e"]]