ToHashBucketFast

public final class ToHashBucketFast

Converts each string in the input Tensor to its hash mod by a number of buckets.

The hash function is deterministic on the content of the string within the process and will never change. However, it is not suitable for cryptography. This function may be used when CPU time is scarce and inputs are trusted or unimportant. There is a risk of adversaries constructing inputs that all hash to the same bucket. To prevent this problem, use a strong hash function with `tf.string_to_hash_bucket_strong`.

Examples:

>>> tf.strings.to_hash_bucket_fast(["Hello", "TensorFlow", "2.x"], 3).numpy() array([0, 2, 2])

Constants

String OP_NAME The name of this op, as known by TensorFlow core engine

Public Methods

Output<TInt64>
asOutput()
Returns the symbolic handle of the tensor.
static ToHashBucketFast
create(Scope scope, Operand<TString> input, Long numBuckets)
Factory method to create a class wrapping a new ToHashBucketFast operation.
Output<TInt64>
output()
A Tensor of the same shape as the input `string_tensor`.

Inherited Methods

Constants

public static final String OP_NAME

The name of this op, as known by TensorFlow core engine

Constant Value: "StringToHashBucketFast"

Public Methods

public Output<TInt64> asOutput ()

Returns the symbolic handle of the tensor.

Inputs to TensorFlow operations are outputs of another TensorFlow operation. This method is used to obtain a symbolic handle that represents the computation of the input.

public static ToHashBucketFast create (Scope scope, Operand<TString> input, Long numBuckets)

Factory method to create a class wrapping a new ToHashBucketFast operation.

Parameters
scope current scope
input The strings to assign a hash bucket.
numBuckets The number of buckets.
Returns
  • a new instance of ToHashBucketFast

public Output<TInt64> output ()

A Tensor of the same shape as the input `string_tensor`.