W3cubDocs

/TensorFlow 2.4

tf.raw_ops.SparseCrossHashed

Generates sparse cross from a list of sparse and dense tensors.

The op takes two lists, one of 2D SparseTensor and one of 2D Tensor, each representing features of one feature column. It outputs a 2D SparseTensor with the batchwise crosses of these features.

For example, if the inputs are

inputs[0]: SparseTensor with shape = [2, 2]
[0, 0]: "a"
[1, 0]: "b"
[1, 1]: "c"

inputs[1]: SparseTensor with shape = [2, 1]
[0, 0]: "d"
[1, 0]: "e"

inputs[2]: Tensor [["f"], ["g"]]

then the output will be

shape = [2, 2]
[0, 0]: "a_X_d_X_f"
[1, 0]: "b_X_e_X_g"
[1, 1]: "c_X_e_X_g"

if hashed_output=true then the output will be

shape = [2, 2]
[0, 0]: FingerprintCat64(
            Fingerprint64("f"), FingerprintCat64(
                Fingerprint64("d"), Fingerprint64("a")))
[1, 0]: FingerprintCat64(
            Fingerprint64("g"), FingerprintCat64(
                Fingerprint64("e"), Fingerprint64("b")))
[1, 1]: FingerprintCat64(
            Fingerprint64("g"), FingerprintCat64(
                Fingerprint64("e"), Fingerprint64("c")))
Args
indices A list of Tensor objects with type int64. 2-D. Indices of each input SparseTensor.
values A list of Tensor objects with types from: int64, string. 1-D. values of each SparseTensor.
shapes A list with the same length as indices of Tensor objects with type int64. 1-D. Shapes of each SparseTensor.
dense_inputs A list of Tensor objects with types from: int64, string. 2-D. Columns represented by dense Tensor.
num_buckets A Tensor of type int64. It is used if hashed_output is true. output = hashed_value%num_buckets if num_buckets > 0 else hashed_value.
strong_hash A Tensor of type bool. boolean, if true, siphash with salt will be used instead of farmhash.
salt A Tensor of type int64. Specify the salt that will be used by the siphash function.
name A name for the operation (optional).
Returns
A tuple of Tensor objects (output_indices, output_values, output_shape).
output_indices A Tensor of type int64.
output_values A Tensor of type int64.
output_shape A Tensor of type int64.

© 2020 The TensorFlow Authors. All rights reserved.
Licensed under the Creative Commons Attribution License 3.0.
Code samples licensed under the Apache 2.0 License.
https://www.tensorflow.org/versions/r2.4/api_docs/python/tf/raw_ops/SparseCrossHashed