![]() |
Version of embedding_lookup that avoids duplicate lookups.
tf.contrib.layers.embedding_lookup_unique(
params,
ids,
partition_strategy='mod',
name=None
)
This can save communication in the case of repeated ids.
Same interface as embedding_lookup. Except it supports multi-dimensional ids
which allows to not reshape input/output to fit gather.
Args:
params
: A list of tensors with the same shape and type, or aPartitionedVariable
. Shape[index, d1, d2, ...]
.ids
: A one-dimensionalTensor
with typeint32
orint64
containing the ids to be looked up inparams
. Shape[ids1, ids2, ...]
.partition_strategy
: A string specifying the partitioning strategy, relevant iflen(params) > 1
. Currently"div"
and"mod"
are supported. Default is"mod"
.name
: A name for this operation (optional).
Returns:
A Tensor
with the same type as the tensors in params
and dimension of
[ids1, ids2, d1, d2, ...]
.
Raises:
ValueError
: Ifparams
is empty.