contrib.layers.shared_embedding_columns
tf.contrib.layers.shared_embedding_columns
tf.contrib.layers.shared_embedding_columns
shared_embedding_columns( sparse_id_columns, dimension, combiner='mean', shared_embedding_name=None, initializer=None, ckpt_to_load_from=None, tensor_name_in_ckpt=None, max_norm=None, trainable=True )
Defined in tensorflow/contrib/layers/python/layers/feature_column.py
.
See the guide: Layers (contrib) > Feature columns
Creates a list of _EmbeddingColumn
sharing the same embedding.
Args:
-
sparse_id_columns
: An iterable of_SparseColumn
, such as those created bysparse_column_with_*
or crossed_column functions. Note thatcombiner
defined in each sparse_id_column is ignored. -
dimension
: An integer specifying dimension of the embedding. -
combiner
: A string specifying how to reduce if there are multiple entries in a single row. Currently "mean", "sqrtn" and "sum" are supported, with "mean" the default. "sqrtn" often achieves good accuracy, in particular with bag-of-words columns. Each of this can be thought as example level normalizations on the column:- "sum": do not normalize
- "mean": do l1 normalization
- "sqrtn": do l2 normalization For more information:
tf.embedding_lookup_sparse
.
-
shared_embedding_name
: (Optional). A string specifying the name of shared embedding weights. This will be needed if you want to reference the shared embedding separately from the generated_EmbeddingColumn
. -
initializer
: A variable initializer function to be used in embedding variable initialization. If not specified, defaults totf.truncated_normal_initializer
with mean 0.0 and standard deviation 1/sqrt(sparse_id_columns[0].length). -
ckpt_to_load_from
: (Optional). String representing checkpoint name/pattern to restore the column weights. Required iftensor_name_in_ckpt
is not None. -
tensor_name_in_ckpt
: (Optional). Name of theTensor
in the provided checkpoint from which to restore the column weights. Required ifckpt_to_load_from
is not None. -
max_norm
: (Optional). If not None, embedding values are l2-normalized to the value of max_norm. -
trainable
: (Optional). Should the embedding be trainable. Default is True
Returns:
A tuple of _EmbeddingColumn
with shared embedding space.
Raises:
-
ValueError
: if sparse_id_columns is empty, or its elements are not compatible with each other. -
TypeError
: ifsparse_id_columns
is not a sequence or is a string. If at least one element ofsparse_id_columns
is not aSparseTensor
.
© 2017 The TensorFlow Authors. All rights reserved.
Licensed under the Creative Commons Attribution License 3.0.
Code samples licensed under the Apache 2.0 License.
https://www.tensorflow.org/api_docs/python/tf/contrib/layers/shared_embedding_columns