tf.tpu.experimental.embedding_column
Stay organized with collections
Save and categorize content based on your preferences.
TPU version of tf.compat.v1.feature_column.embedding_column
.
tf.tpu.experimental.embedding_column(
categorical_column, dimension, combiner='mean', initializer=None,
max_sequence_length=0, learning_rate_fn=None
)
Note that the interface for tf.tpu.experimental.embedding_column
is
different from that of tf.compat.v1.feature_column.embedding_column
: The
following arguments are NOT supported: ckpt_to_load_from
,
tensor_name_in_ckpt
, max_norm
and trainable
.
Use this function in place of tf.compat.v1.feature_column.embedding_column
when you want to use the TPU to accelerate your embedding lookups via TPU
embeddings.
column = tf.feature_column.categorical_column_with_identity(...)
tpu_column = tf.tpu.experimental.embedding_column(column, 10)
...
def model_fn(features):
dense_feature = tf.keras.layers.DenseFeature(tpu_column)
embedded_feature = dense_feature(features)
...
estimator = tf.estimator.tpu.TPUEstimator(
model_fn=model_fn,
...
embedding_config_spec=tf.estimator.tpu.experimental.EmbeddingConfigSpec(
column=[tpu_column],
...))
Args |
categorical_column
|
A categorical column returned from
categorical_column_with_identity , weighted_categorical_column ,
categorical_column_with_vocabulary_file ,
categorical_column_with_vocabulary_list ,
sequence_categorical_column_with_identity ,
sequence_categorical_column_with_vocabulary_file ,
sequence_categorical_column_with_vocabulary_list
|
dimension
|
An integer specifying dimension of the embedding, must be > 0.
|
combiner
|
A string specifying how to reduce if there are multiple entries
in a single row for a non-sequence column. For more information, see
tf.feature_column.embedding_column .
|
initializer
|
A variable initializer function to be used in embedding
variable initialization. If not specified, defaults to
tf.compat.v1.truncated_normal_initializer with mean 0.0 and
standard deviation 1/sqrt(dimension) .
|
max_sequence_length
|
An non-negative integer specifying the max sequence
length. Any sequence shorter then this will be padded with 0 embeddings
and any sequence longer will be truncated. This must be positive for
sequence features and 0 for non-sequence features.
|
learning_rate_fn
|
A function that takes global step and returns learning
rate for the embedding table.
|
Returns |
A _TPUEmbeddingColumnV2 .
|
Raises |
ValueError
|
if dimension not > 0.
|
ValueError
|
if initializer is specified but not callable.
|
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_column\n\n\u003cbr /\u003e\n\n|------------------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v1.15.0/tensorflow/python/tpu/feature_column_v2.py#L35-L125) |\n\nTPU version of [`tf.compat.v1.feature_column.embedding_column`](../../../tf/feature_column/embedding_column).\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_column`](/api_docs/python/tf/compat/v1/tpu/experimental/embedding_column)\n\n\u003cbr /\u003e\n\n tf.tpu.experimental.embedding_column(\n categorical_column, dimension, combiner='mean', initializer=None,\n max_sequence_length=0, learning_rate_fn=None\n )\n\nNote that the interface for [`tf.tpu.experimental.embedding_column`](../../../tf/tpu/experimental/embedding_column) is\ndifferent from that of [`tf.compat.v1.feature_column.embedding_column`](../../../tf/feature_column/embedding_column): The\nfollowing arguments are NOT supported: `ckpt_to_load_from`,\n`tensor_name_in_ckpt`, `max_norm` and `trainable`.\n\nUse this function in place of [`tf.compat.v1.feature_column.embedding_column`](../../../tf/feature_column/embedding_column)\nwhen you want to use the TPU to accelerate your embedding lookups via TPU\nembeddings. \n\n column = tf.feature_column.categorical_column_with_identity(...)\n tpu_column = tf.tpu.experimental.embedding_column(column, 10)\n ...\n def model_fn(features):\n dense_feature = tf.keras.layers.DenseFeature(tpu_column)\n embedded_feature = dense_feature(features)\n ...\n\n estimator = tf.estimator.tpu.TPUEstimator(\n model_fn=model_fn,\n ...\n embedding_config_spec=tf.estimator.tpu.experimental.EmbeddingConfigSpec(\n column=[tpu_column],\n ...))\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|-----------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `categorical_column` | A categorical column returned from `categorical_column_with_identity`, `weighted_categorical_column`, `categorical_column_with_vocabulary_file`, `categorical_column_with_vocabulary_list`, `sequence_categorical_column_with_identity`, `sequence_categorical_column_with_vocabulary_file`, `sequence_categorical_column_with_vocabulary_list` |\n| `dimension` | An integer specifying dimension of the embedding, must be \\\u003e 0. |\n| `combiner` | A string specifying how to reduce if there are multiple entries in a single row for a non-sequence column. For more information, see [`tf.feature_column.embedding_column`](../../../tf/feature_column/embedding_column). |\n| `initializer` | A variable initializer function to be used in embedding variable initialization. If not specified, defaults to [`tf.compat.v1.truncated_normal_initializer`](../../../tf/initializers/truncated_normal) with mean `0.0` and standard deviation `1/sqrt(dimension)`. |\n| `max_sequence_length` | An non-negative integer specifying the max sequence length. Any sequence shorter then this will be padded with 0 embeddings and any sequence longer will be truncated. This must be positive for sequence features and 0 for non-sequence features. |\n| `learning_rate_fn` | A function that takes global step and returns learning rate for the embedding table. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ------- ||\n|---|---|\n| A `_TPUEmbeddingColumnV2`. ||\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Raises ------ ||\n|--------------|-------------------------------------------------|\n| `ValueError` | if `dimension` not \\\u003e 0. |\n| `ValueError` | if `initializer` is specified but not callable. |\n\n\u003cbr /\u003e"]]