tf.sparse.cross
Генерирует разреженное перекрестное произведение из списка разреженных и плотных тензоров.
tf.sparse.cross(
inputs, name=None, separator=None
)
Например, если входные данные:
* 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"]]
то выход будет:
shape = [2, 2] [0, 0]: "a_X_d_X_f" [1, 0]: "b_X_e_X_g" [1, 1]: "c_X_e_X_g"
Настройка разделителя "Y":
inp_0 = tf.constant([['a'], ['b']]) inp_1 = tf.constant([['c'], ['d']]) output = tf.sparse.cross([inp_0, inp_1], separator='_Y_') output.values <tf.Tensor: shape=(2,), dtype=string, numpy=array([b'a_Y_c', b'b_Y_d'], dtype=object)>
| Аргументы | |
|---|---|
inputs | Итерируемый список из Tensor или SparseTensor. |
name | Необязательное имя для операции. |
separator | Строка, добавляемая между каждым объединяемым элементом. По умолчанию 'X'. |
| Возвращаемые значения | |
|---|---|
Разреженный тензор типа string. |
© 2022 The TensorFlow Authors. All rights reserved.
Licensed under the Creative Commons Attribution License 4.0.
Code samples licensed under the Apache 2.0 License.
https://www.tensorflow.org/api_docs/python/tf/sparse/cross