tf.raw_ops.SparseCross
bookmark_borderbookmark
Stay organized with collections
Save and categorize content based on your preferences.
Generates sparse cross from a list of sparse and dense tensors.
View aliases
Compat aliases for migration
See
Migration guide for
more details.
tf.compat.v1.raw_ops.SparseCross
tf.raw_ops.SparseCross(
indices,
values,
shapes,
dense_inputs,
hashed_output,
num_buckets,
hash_key,
out_type,
internal_type,
name=None
)
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 .
|
hashed_output
|
A bool .
If true, returns the hash of the cross instead of the string.
This will allow us avoiding string manipulations.
|
num_buckets
|
An int that is >= 0 . It is used if hashed_output is true.
output = hashed_value%num_buckets if num_buckets > 0 else hashed_value.
|
hash_key
|
An int .
Specify the hash_key that will be used by the FingerprintCat64
function to combine the crosses fingerprints.
|
out_type
|
A tf.DType from: tf.int64, tf.string .
|
internal_type
|
A tf.DType from: tf.int64, tf.string .
|
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 out_type .
|
output_shape
|
A Tensor of type int64 .
|
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates. Some content is licensed under the numpy license.
Last updated 2024-04-26 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-04-26 UTC."],[],[],null,["# tf.raw_ops.SparseCross\n\n\u003cbr /\u003e\n\nGenerates sparse cross from a list of sparse and dense tensors.\n\n#### View aliases\n\n\n**Compat aliases for migration**\n\nSee\n[Migration guide](https://www.tensorflow.org/guide/migrate) for\nmore details.\n\n[`tf.compat.v1.raw_ops.SparseCross`](https://www.tensorflow.org/api_docs/python/tf/raw_ops/SparseCross)\n\n\u003cbr /\u003e\n\n tf.raw_ops.SparseCross(\n indices,\n values,\n shapes,\n dense_inputs,\n hashed_output,\n num_buckets,\n hash_key,\n out_type,\n internal_type,\n name=None\n )\n\nThe op takes two lists, one of 2D `SparseTensor` and one of 2D `Tensor`, each\nrepresenting features of one feature column. It outputs a 2D `SparseTensor` with\nthe batchwise crosses of these features.\n\nFor example, if the inputs are \n\n inputs[0]: SparseTensor with shape = [2, 2]\n [0, 0]: \"a\"\n [1, 0]: \"b\"\n [1, 1]: \"c\"\n\n inputs[1]: SparseTensor with shape = [2, 1]\n [0, 0]: \"d\"\n [1, 0]: \"e\"\n\n inputs[2]: Tensor [[\"f\"], [\"g\"]]\n\nthen the output will be \n\n shape = [2, 2]\n [0, 0]: \"a_X_d_X_f\"\n [1, 0]: \"b_X_e_X_g\"\n [1, 1]: \"c_X_e_X_g\"\n\nif hashed_output=true then the output will be \n\n shape = [2, 2]\n [0, 0]: FingerprintCat64(\n Fingerprint64(\"f\"), FingerprintCat64(\n Fingerprint64(\"d\"), Fingerprint64(\"a\")))\n [1, 0]: FingerprintCat64(\n Fingerprint64(\"g\"), FingerprintCat64(\n Fingerprint64(\"e\"), Fingerprint64(\"b\")))\n [1, 1]: FingerprintCat64(\n Fingerprint64(\"g\"), FingerprintCat64(\n Fingerprint64(\"e\"), Fingerprint64(\"c\")))\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|-----------------|----------------------------------------------------------------------------------------------------------------------------------------|\n| `indices` | A list of `Tensor` objects with type `int64`. 2-D. Indices of each input `SparseTensor`. |\n| `values` | A list of `Tensor` objects with types from: `int64`, `string`. 1-D. values of each `SparseTensor`. |\n| `shapes` | A list with the same length as `indices` of `Tensor` objects with type `int64`. 1-D. Shapes of each `SparseTensor`. |\n| `dense_inputs` | A list of `Tensor` objects with types from: `int64`, `string`. 2-D. Columns represented by dense `Tensor`. |\n| `hashed_output` | A `bool`. If true, returns the hash of the cross instead of the string. This will allow us avoiding string manipulations. |\n| `num_buckets` | An `int` that is `\u003e= 0`. It is used if hashed_output is true. output = hashed_value%num_buckets if num_buckets \\\u003e 0 else hashed_value. |\n| `hash_key` | An `int`. Specify the hash_key that will be used by the `FingerprintCat64` function to combine the crosses fingerprints. |\n| `out_type` | A [`tf.DType`](../../tf/dtypes/DType) from: `tf.int64, tf.string`. |\n| `internal_type` | A [`tf.DType`](../../tf/dtypes/DType) from: `tf.int64, tf.string`. |\n| `name` | A name for the operation (optional). |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ------- ||\n|------------------|--------------------------------|\n| A tuple of `Tensor` objects (output_indices, output_values, output_shape). ||\n| `output_indices` | A `Tensor` of type `int64`. |\n| `output_values` | A `Tensor` of type `out_type`. |\n| `output_shape` | A `Tensor` of type `int64`. |\n\n\u003cbr /\u003e"]]