View source on GitHub |
Looks up embeddings for the given ids and weights from a list of tensors.
tf.compat.v1.nn.embedding_lookup_sparse(
params,
sp_ids,
sp_weights,
partition_strategy='mod',
name=None,
combiner=None,
max_norm=None
)
This op assumes that there is at least one id for each row in the dense tensor represented by sp_ids (i.e. there are no rows with empty features), and that all the indices of sp_ids are in canonical row-major order.
sp_ids
and sp_weights
(if not None) are SparseTensor
s with rank of 2.
Embeddings are always aggregated along the last dimension.
It also assumes that all id values lie in the range [0, p0), where p0 is the sum of the size of params along dimension 0.
Returns | |
---|---|
A dense tensor representing the combined embeddings for the
sparse ids. For each row in the dense tensor represented by sp_ids , the op
looks up the embeddings for all ids in that row, multiplies them by the
corresponding weight, and combines these embeddings as specified.
In other words, if
and
then
For instance, if params is a 10x20 matrix, and sp_ids / sp_weights are
with
|
Raises | |
---|---|
TypeError
|
If sp_ids is not a SparseTensor , or if sp_weights is
neither None nor SparseTensor .
|
ValueError
|
If combiner is not one of {"mean", "sqrtn", "sum"}.
|