MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / embedding_lookup_v2

Function embedding_lookup_v2

tensorflow/python/ops/embedding_ops.py:433–469  ·  view source on GitHub ↗

Looks up `ids` in a list of embedding tensors. This function is used to perform parallel lookups on the list of tensors in `params`. It is a generalization of `tf.gather`, where `params` is interpreted as a partitioning of a large embedding tensor. `params` may be a `PartitionedVariable`

(params, ids, max_norm=None, name=None)

Source from the content-addressed store, hash-verified

431
432@tf_export("nn.embedding_lookup", v1=[])
433def embedding_lookup_v2(params, ids, max_norm=None, name=None):
434 """Looks up `ids` in a list of embedding tensors.
435 This function is used to perform parallel lookups on the list of
436 tensors in `params`. It is a generalization of
437 `tf.gather`, where `params` is
438 interpreted as a partitioning of a large embedding tensor. `params` may be
439 a `PartitionedVariable` as returned by using `tf.compat.v1.get_variable()`
440 with a
441 partitioner.
442 If `len(params) > 1`, each element `id` of `ids` is partitioned between
443 the elements of `params` according to the `partition_strategy`.
444 In all strategies, if the id space does not evenly divide the number of
445 partitions, each of the first `(max_id + 1) % len(params)` partitions will
446 be assigned one more id.
447 The `partition_strategy` is always `"div"` currently. This means that we
448 assign ids to partitions in a contiguous manner. For instance, 13 ids are
449 split across 5 partitions as:
450 `[[0, 1, 2], [3, 4, 5], [6, 7, 8], [9, 10], [11, 12]]`
451 The results of the lookup are concatenated into a dense
452 tensor. The returned tensor has shape `shape(ids) + shape(params)[1:]`.
453 Args:
454 params: A single tensor representing the complete embedding tensor, or a
455 list of P tensors all of same shape except for the first dimension,
456 representing sharded embedding tensors. Alternatively, a
457 `PartitionedVariable`, created by partitioning along dimension 0. Each
458 element must be appropriately sized for the 'div' `partition_strategy`.
459 ids: A `Tensor` with type `int32` or `int64` containing the ids to be looked
460 up in `params`.
461 max_norm: If not `None`, each embedding is clipped if its l2-norm is larger
462 than this value.
463 name: A name for the operation (optional).
464 Returns:
465 A `Tensor` with the same type as the tensors in `params`.
466 Raises:
467 ValueError: If `params` is empty.
468 """
469 return embedding_lookup(params, ids, "div", name, max_norm=max_norm)
470
471
472def _tile_combine_embedding(embeddings, segment_ids, column_ids, sp_shape):

Callers

nothing calls this directly

Calls 1

embedding_lookupFunction · 0.70

Tested by

no test coverage detected