当前位置: 首页>>代码示例>>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;未经允许,请勿转载。