Lookup embedding results, accounting for invalid IDs and empty features.
tf.compat.v2.nn.safe_embedding_lookup_sparse( embedding_weights, sparse_ids, sparse_weights=None, combiner='mean', default_id=None, max_norm=None, name=None )
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
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.
Note: when doing embedding lookup on
embedding_weights, "div" partition strategy will be used. Support for other partition strategy will be added later.
| || A list of |
| || |
| || |
| ||A string specifying how to combine embedding results for each entry. Currently "mean", "sqrtn" and "sum" are supported, with "mean" the default.|
| ||The id to use for an entry with no features.|
| || If not |
| ||A name for this operation (optional).|
| Dense |
| || if |
© 2020 The TensorFlow Authors. All rights reserved.
Licensed under the Creative Commons Attribution License 3.0.
Code samples licensed under the Apache 2.0 License.