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

Function group_embedding_lookup_sparse

tensorflow/python/ops/embedding_ops.py:1594–1930  ·  view source on GitHub ↗

This interface is designed for fused multiple embedding lookup. Args: params: list, tuple a list or tuple of trainable *Variable* or *EmbeddingVariable*. sp_ids: list, tuple a list or tuple of tf.SparseTensor or tf.RaggedTensor. btw Ragg

(params,
                                  sp_ids,
                                  combiners,
                                  sp_weights=None,
                                  partition_strategy='mod',
                                  is_sequence=False,
                                  params_num_per_group=sys.maxsize,
                                  name=None,
                                  )

Source from the content-addressed store, hash-verified

1592
1593@tf_export('nn.group_embedding_lookup_sparse')
1594def group_embedding_lookup_sparse(params,
1595 sp_ids,
1596 combiners,
1597 sp_weights=None,
1598 partition_strategy='mod',
1599 is_sequence=False,
1600 params_num_per_group=sys.maxsize,
1601 name=None,
1602 ):
1603 """
1604 This interface is designed for fused multiple embedding lookup.
1605 Args:
1606 params: list, tuple
1607 a list or tuple of trainable *Variable* or *EmbeddingVariable*.
1608 sp_ids: list, tuple
1609 a list or tuple of tf.SparseTensor or tf.RaggedTensor.
1610 btw RaggedTensor is preferred.
1611 combiners: list, tuple
1612 a list or tuple of string to specify the combiner of each embedding lookup,
1613 supported args is *sum* or *mean*
1614 sp_weights: list, tuple
1615 a list or tuple of tf.SparseTensor used for embedding lookup.
1616 is_sequence: bool
1617 return list of `Tensor` of shape `[batch_size, D]` when is False
1618 return list of `Tensor` of shape `[batch_size, T, D]` when is True
1619 params_num_per_group: int
1620 The number of params in GroupEmbedding op.Function will schedule len(params) // params_num_per_group + 1
1621 GroupEmbedding Op. Default setting would launch one Op containing all params which is suitable for GPU scenarios
1622 to maximize the GPU utilization.On the contrast, you could set value to 1 when Op
1623 is placed on CPU so as to maximize inter parallelism.
1624 name: The operations name
1625 Returns
1626 -------
1627 emb_vec: list
1628 a list of tf.Tensor(the results of lookup).
1629 """
1630
1631 if combiners is None:
1632 logging.warn('The default value of combiner will change from "mean" to "sqrtn" after 2016/11/01.'
1633 )
1634 combiners = ['mean'] * len(params)
1635 if not isinstance(combiners, list):
1636 combiners = [combiners]
1637 for combiner in combiners:
1638 if combiner not in ('mean', 'sum'):
1639 raise ValueError("combiners must be one of 'mean', 'sum'")
1640
1641 if params is None:
1642 raise ValueError('params must be specified')
1643 if not isinstance(params, list):
1644 params = [params]
1645
1646 #Currently do not support PartitionedVariable.
1647 for index, param in enumerate(params):
1648 if isinstance(param, variables.PartitionedVariable):
1649 tmp_param = list(param)
1650 if len(tmp_param) != 1:
1651 raise TypeError("PartitionedVariable not support in 'group_embedding_lookup_sparse'. ")

Callers

nothing calls this directly

Calls 12

divmodFunction · 0.85
embedding_lookup_sparseFunction · 0.70
rangeFunction · 0.70
sizeMethod · 0.45
name_scopeMethod · 0.45
appendMethod · 0.45
to_sparseMethod · 0.45
get_shapeMethod · 0.45
popMethod · 0.45
formatMethod · 0.45

Tested by

no test coverage detected