The partitioned embedding in embedding_weights must all be the same shape
except for the first dimension. The first dimension is allowed to vary as the
vocabulary size is not necessarily a multiple of P. embedding_weights
may be a PartitionedVariable as returned by using
tf.compat.v1.get_variable() with a
partitioner.
Invalid IDs (< 0) are pruned from input IDs and weights, as well as any IDs
with non-positive weight. For an entry with no features, the embedding vector
for default_id is returned, or the 0-vector if default_id is not supplied.
The ids and weights may be multi-dimensional. Embeddings are always aggregated
along the last dimension.
Args
embedding_weights
A list of P float Tensors or values representing
partitioned embedding Tensors. Alternatively, a PartitionedVariable
created by partitioning along dimension 0. The total unpartitioned shape
should be [e_0, e_1, ..., e_m], where e_0 represents the vocab size
and e_1, ..., e_m are the embedding dimensions.
sparse_ids
SparseTensor of shape [d_0, d_1, ..., d_n] containing the
ids. d_0 is typically batch size.
sparse_weights
SparseTensor of same shape as sparse_ids, containing
float weights corresponding to sparse_ids, or None if all weights are
be assumed to be 1.0.
combiner
A string specifying how to combine embedding results for each
entry. Currently "mean", "sqrtn" and "sum" are supported, with "mean" the
default.
default_id
The id to use for an entry with no features.
max_norm
If not None, all embeddings are l2-normalized to max_norm before
combining.
[null,null,["Last updated 2020-10-01 UTC."],[],[],null,["# tf.nn.safe_embedding_lookup_sparse\n\n\u003cbr /\u003e\n\n|--------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------|\n| [TensorFlow 1 version](/versions/r1.15/api_docs/python/tf/nn/safe_embedding_lookup_sparse) | [View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.0.0/tensorflow/python/ops/embedding_ops.py#L621-L682) |\n\nLookup embedding results, accounting for invalid IDs and empty features. \n\n tf.nn.safe_embedding_lookup_sparse(\n embedding_weights, sparse_ids, sparse_weights=None, combiner='mean',\n default_id=None, max_norm=None, name=None\n )\n\nThe partitioned embedding in `embedding_weights` must all be the same shape\nexcept for the first dimension. The first dimension is allowed to vary as the\nvocabulary size is not necessarily a multiple of `P`. `embedding_weights`\nmay be a `PartitionedVariable` as returned by using\n[`tf.compat.v1.get_variable()`](../../tf/compat/v1/get_variable) with a\npartitioner.\n\nInvalid IDs (\\\u003c 0) are pruned from input IDs and weights, as well as any IDs\nwith non-positive weight. For an entry with no features, the embedding vector\nfor `default_id` is returned, or the 0-vector if `default_id` is not supplied.\n\nThe ids and weights may be multi-dimensional. Embeddings are always aggregated\nalong the last dimension.\n| **Note:** when doing embedding lookup on `embedding_weights`, \"div\" partition strategy will be used. Support for other partition strategy will be added later.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|---------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `embedding_weights` | A list of `P` float `Tensor`s or values representing partitioned embedding `Tensor`s. Alternatively, a `PartitionedVariable` created by partitioning along dimension 0. The total unpartitioned shape should be `[e_0, e_1, ..., e_m]`, where `e_0` represents the vocab size and `e_1, ..., e_m` are the embedding dimensions. |\n| `sparse_ids` | `SparseTensor` of shape `[d_0, d_1, ..., d_n]` containing the ids. `d_0` is typically batch size. |\n| `sparse_weights` | `SparseTensor` of same shape as `sparse_ids`, containing float weights corresponding to `sparse_ids`, or `None` if all weights are be assumed to be 1.0. |\n| `combiner` | A string specifying how to combine embedding results for each entry. Currently \"mean\", \"sqrtn\" and \"sum\" are supported, with \"mean\" the default. |\n| `default_id` | The id to use for an entry with no features. |\n| `max_norm` | If not `None`, all embeddings are l2-normalized to max_norm before combining. |\n| `name` | A name for this operation (optional). |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ------- ||\n|---|---|\n| Dense `Tensor` of shape `[d_0, d_1, ..., d_{n-1}, e_1, ..., e_m]`. ||\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Raises ------ ||\n|--------------|----------------------------------|\n| `ValueError` | if `embedding_weights` is empty. |\n\n\u003cbr /\u003e"]]