parameters: (params,
                                                 sp_values,
                                                 dimension=None,
                                                 sampled_candidates=None,
                                                 hash_key=None,
                                                 with_sign_hash=False,
                                                 name=None)
docstring: Looks up embeddings using parameter hashing for sparse values.
  
    This method looks up selected embedding dimensions if `sampled_candidates` is
    given, otherwise looks up all dimensions.
  
    The i-th embedding component of a value v in `values` is found by retrieving
    the weight whose index is a fingerprint of the pair (v,i).
    The concept is explored as "feature hashing" for model compression in this
    paper: http://arxiv.org/pdf/1504.04788.pdf
  
    This is logically equivalent to:
    * Transforming `sp_values` (which has shape `[d0, d1]`) into a one-hot
      `Tensor` of shape `[d0, N]`.
    * Multiplying with a `Tensor` `h` of shape `[N, dimension]`, where
      `h(i, j) = params[hash(i, j)]`.
  
    Args:
      params: A float `Tensor` with rank 1 and fully-defined shape.
      sp_values: A 2D `SparseTensor` to be embedded with shape `[d0, d1]`.
      dimension: An int `Tensor` of the final dimension. The user needs to provide
        either `dimension` or `sampled_candidates`.
      sampled_candidates: An optional `Tensor` of column indices to keep along the
        final dimension with shape `[d0, N]`. If given, `dimension` is ignored. If
        `None`, looks up all candidates.
      hash_key: Specify the hash_key that will be used by the `FingerprintCat64`
        function to combine the crosses fingerprints on SparseFeatureCrossOp
        (optional).
      with_sign_hash:  A `bool` indicating whether `h(i, j)` should be multiplied
        by `+1` or `-1`, where the value selected is determined by hashing `(i,
        j)`. This is often necessary to remove bias resulting from hash
        collisions.
      name: An optional name for this op.
  
    Returns:
      A `Tensor` of shape `[d0, dimension]`.
      If `sampled_candidates` is given, the output shape is `[d0, N]`.
  
    Raises:
      TypeError: If sp_values is not `SparseTensor`.
      ValueError: If both `dimension` and `sampled_candidates` are `None`.
docstring_summary: Looks up embeddings using parameter hashing for sparse values.
docstring_tokens: Looks up embeddings using parameter hashing for sparse values .
function: def _sampled_scattered_embedding_lookup_sparse(params,
                                                 sp_values,
                                                 dimension=None,
                                                 sampled_candidates=None,
                                                 hash_key=None,
                                                 with_sign_hash=False,
                                                 name=None):
    """Looks up embeddings using parameter hashing for sparse values.
  
    This method looks up selected embedding dimensions if `sampled_candidates` is
    given, otherwise looks up all dimensions.
  
    The i-th embedding component of a value v in `values` is found by retrieving
    the weight whose index is a fingerprint of the pair (v,i).
    The concept is explored as "feature hashing" for model compression in this
    paper: http://arxiv.org/pdf/1504.04788.pdf
  
    This is logically equivalent to:
    * Transforming `sp_values` (which has shape `[d0, d1]`) into a one-hot
      `Tensor` of shape `[d0, N]`.
    * Multiplying with a `Tensor` `h` of shape `[N, dimension]`, where
      `h(i, j) = params[hash(i, j)]`.
  
    Args:
      params: A float `Tensor` with rank 1 and fully-defined shape.
      sp_values: A 2D `SparseTensor` to be embedded with shape `[d0, d1]`.
      dimension: An int `Tensor` of the final dimension. The user needs to provide
        either `dimension` or `sampled_candidates`.
      sampled_candidates: An optional `Tensor` of column indices to keep along the
        final dimension with shape `[d0, N]`. If given, `dimension` is ignored. If
        `None`, looks up all candidates.
      hash_key: Specify the hash_key that will be used by the `FingerprintCat64`
        function to combine the crosses fingerprints on SparseFeatureCrossOp
        (optional).
      with_sign_hash:  A `bool` indicating whether `h(i, j)` should be multiplied
        by `+1` or `-1`, where the value selected is determined by hashing `(i,
        j)`. This is often necessary to remove bias resulting from hash
        collisions.
      name: An optional name for this op.
  
    Returns:
      A `Tensor` of shape `[d0, dimension]`.
      If `sampled_candidates` is given, the output shape is `[d0, N]`.
  
    Raises:
      TypeError: If sp_values is not `SparseTensor`.
      ValueError: If both `dimension` and `sampled_candidates` are `None`.
    """
    if not isinstance(sp_values, sparse_tensor.SparseTensor):
      raise TypeError("sp_values must be SparseTensor")
  
    with ops.name_scope(
        name=name,
        default_name="sampled_scattered_embedding_lookup_sparse",
        values=[sp_values, params, dimension, sampled_candidates]) as name_scope:
      segment_ids = sp_values.indices[:, 0]
      if sampled_candidates is not None:
        # Tile sampled_candidates so there is one line corresponding to each
        # element in sp_values.values
        sampled_candidates = array_ops.gather(sampled_candidates, segment_ids)
  
      embeddings = _sampled_scattered_embedding_lookup(
          params,
          sp_values.values,
          dimension=dimension,
          sampled_candidates=sampled_candidates,
          hash_key=hash_key,
          name="values_lookup")
      if with_sign_hash:
        signs = _sampled_scattered_embedding_lookup(
            array_ops.constant([-1., 1.]),
            sp_values.values,
            dimension=dimension,
            sampled_candidates=sampled_candidates,
            hash_key=hash_key,
            name="signs_lookup")
        embeddings = math_ops.multiply(signs, embeddings, name="signs_hash")
  
      if segment_ids.dtype != dtypes.int32:
        segment_ids = math_ops.cast(segment_ids, dtypes.int32)
      num_segments = array_ops.shape(sp_values)[0]
  
      return math_ops.unsorted_segment_sum(
          embeddings, segment_ids, num_segments=num_segments, name=name_scope)
function_tokens: def _sampled_scattered_embedding_lookup_sparse ( params , sp_values , dimension = None , sampled_candidates = None , hash_key = None , with_sign_hash = False , name = None ) : if not isinstance ( sp_values , sparse_tensor . SparseTensor ) : raise TypeError ( "sp_values must be SparseTensor" ) with ops . name_scope ( name = name , default_name = "sampled_scattered_embedding_lookup_sparse" , values = [ sp_values , params , dimension , sampled_candidates ] ) as name_scope : segment_ids = sp_values . indices [ : , 0 ] if sampled_candidates is not None : # Tile sampled_candidates so there is one line corresponding to each # element in sp_values.values sampled_candidates = array_ops . gather ( sampled_candidates , segment_ids ) embeddings = _sampled_scattered_embedding_lookup ( params , sp_values . values , dimension = dimension , sampled_candidates = sampled_candidates , hash_key = hash_key , name = "values_lookup" ) if with_sign_hash : signs = _sampled_scattered_embedding_lookup ( array_ops . constant ( [ - 1. , 1. ] ) , sp_values . values , dimension = dimension , sampled_candidates = sampled_candidates , hash_key = hash_key , name = "signs_lookup" ) embeddings = math_ops . multiply ( signs , embeddings , name = "signs_hash" ) if segment_ids . dtype != dtypes . int32 : segment_ids = math_ops . cast ( segment_ids , dtypes . int32 ) num_segments = array_ops . shape ( sp_values ) [ 0 ] return math_ops . unsorted_segment_sum ( embeddings , segment_ids , num_segments = num_segments , name = name_scope )