當前位置: 首頁>>代碼示例>>Python>>正文


Python string_ops.string_to_hash_bucket_fast方法代碼示例

本文整理匯總了Python中tensorflow.python.ops.string_ops.string_to_hash_bucket_fast方法的典型用法代碼示例。如果您正苦於以下問題:Python string_ops.string_to_hash_bucket_fast方法的具體用法?Python string_ops.string_to_hash_bucket_fast怎麽用?Python string_ops.string_to_hash_bucket_fast使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在tensorflow.python.ops.string_ops的用法示例。


在下文中一共展示了string_ops.string_to_hash_bucket_fast方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _transform_feature

# 需要導入模塊: from tensorflow.python.ops import string_ops [as 別名]
# 或者: from tensorflow.python.ops.string_ops import string_to_hash_bucket_fast [as 別名]
def _transform_feature(self, inputs):
    input_tensor = _to_sparse_input(inputs.get(self.key))
    if not isinstance(input_tensor, sparse_tensor_lib.SparseTensor):
      raise ValueError('SparseColumn input must be a SparseTensor.')

    _assert_string_or_int(
        input_tensor.dtype,
        prefix='column_name: {} input_tensor'.format(self.key))

    if self.dtype.is_integer != input_tensor.dtype.is_integer:
      raise ValueError(
          'Column dtype and SparseTensors dtype must be compatible. '
          'key: {}, column dtype: {}, tensor dtype: {}'.format(
              self.key, self.dtype, input_tensor.dtype))

    if self.dtype == dtypes.string:
      sparse_values = input_tensor.values
    else:
      sparse_values = string_ops.as_string(input_tensor.values)

    sparse_id_values = string_ops.string_to_hash_bucket_fast(
        sparse_values, self.hash_bucket_size, name='lookup')
    return sparse_tensor_lib.SparseTensor(
        input_tensor.indices, sparse_id_values, input_tensor.dense_shape) 
開發者ID:ryfeus,項目名稱:lambda-packs,代碼行數:26,代碼來源:feature_column.py

示例2: _apply_transform

# 需要導入模塊: from tensorflow.python.ops import string_ops [as 別名]
# 或者: from tensorflow.python.ops.string_ops import string_to_hash_bucket_fast [as 別名]
def _apply_transform(self, input_tensors, **kwargs):
    """Applies the transformation to the `transform_input`.

    Args:
      input_tensors: a list of Tensors representing the input to
        the Transform.
      **kwargs: additional keyword arguments, unused here.

    Returns:
        A namedtuple of Tensors representing the transformed output.
    """
    result = string_ops.string_to_hash_bucket_fast(input_tensors[0],
                                                   self._num_buckets,
                                                   name=None)
    # pylint: disable=not-callable
    return self.return_type(result) 
開發者ID:ryfeus,項目名稱:lambda-packs,代碼行數:18,代碼來源:hashes.py

示例3: _get_string_to_hash_bucket_fn

# 需要導入模塊: from tensorflow.python.ops import string_ops [as 別名]
# 或者: from tensorflow.python.ops.string_ops import string_to_hash_bucket_fast [as 別名]
def _get_string_to_hash_bucket_fn(self, hasher_spec):
    """Returns the string_to_hash_bucket op to use based on `hasher_spec`."""
    if not isinstance(hasher_spec, HasherSpec):
      raise TypeError("hasher_spec must be of type HasherSpec %s" % hasher_spec)
    if hasher_spec.hasher == "fasthash":
      return string_ops.string_to_hash_bucket_fast
    if hasher_spec.hasher == "legacy":
      return string_ops.string_to_hash_bucket
    if hasher_spec.hasher == "stronghash":
      return functools.partial(
          string_ops.string_to_hash_bucket_strong, key=hasher_spec.key)
    raise ValueError("Unknown hasher %s" % hasher_spec.hasher) 
開發者ID:ryfeus,項目名稱:lambda-packs,代碼行數:14,代碼來源:lookup_ops.py

示例4: _do_transform

# 需要導入模塊: from tensorflow.python.ops import string_ops [as 別名]
# 或者: from tensorflow.python.ops.string_ops import string_to_hash_bucket_fast [as 別名]
def _do_transform(self, input_tensor):
    if self.dtype.is_integer:
      sparse_values = string_ops.as_string(input_tensor.values)
    else:
      sparse_values = input_tensor.values

    sparse_id_values = string_ops.string_to_hash_bucket_fast(
        sparse_values, self.bucket_size, name="lookup")
    return sparse_tensor_py.SparseTensor(input_tensor.indices, sparse_id_values,
                                         input_tensor.dense_shape) 
開發者ID:ryfeus,項目名稱:lambda-packs,代碼行數:12,代碼來源:feature_column.py

示例5: insert_transformed_feature

# 需要導入模塊: from tensorflow.python.ops import string_ops [as 別名]
# 或者: from tensorflow.python.ops.string_ops import string_to_hash_bucket_fast [as 別名]
def insert_transformed_feature(self, columns_to_tensors):
    """Handles sparse column to id conversion."""
    input_tensor = self._get_input_sparse_tensor(columns_to_tensors)

    if self.dtype.is_integer:
      sparse_values = string_ops.as_string(input_tensor.values)
    else:
      sparse_values = input_tensor.values

    sparse_id_values = string_ops.string_to_hash_bucket_fast(
        sparse_values, self.bucket_size, name="lookup")
    columns_to_tensors[self] = sparse_tensor_py.SparseTensor(
        input_tensor.indices, sparse_id_values, input_tensor.dense_shape) 
開發者ID:abhisuri97,項目名稱:auto-alt-text-lambda-api,代碼行數:15,代碼來源:feature_column.py

示例6: insert_transformed_feature

# 需要導入模塊: from tensorflow.python.ops import string_ops [as 別名]
# 或者: from tensorflow.python.ops.string_ops import string_to_hash_bucket_fast [as 別名]
def insert_transformed_feature(self, columns_to_tensors):
    """Handles sparse column to id conversion."""
    sparse_tensor = columns_to_tensors[self.name]
    if self.dtype.is_integer:
      sparse_values = string_ops.as_string(sparse_tensor.values)
    else:
      sparse_values = sparse_tensor.values

    sparse_id_values = string_ops.string_to_hash_bucket_fast(
        sparse_values, self.bucket_size, name="lookup")
    columns_to_tensors[self] = sparse_tensor_py.SparseTensor(
        sparse_tensor.indices, sparse_id_values, sparse_tensor.shape) 
開發者ID:tobegit3hub,項目名稱:deep_image_model,代碼行數:14,代碼來源:feature_column.py


注:本文中的tensorflow.python.ops.string_ops.string_to_hash_bucket_fast方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。