📅  最后修改于: 2023-12-03 15:34:06.842000             🧑  作者: Mango
tensorflow.math.floormod()
is a function in Tensorflow's Math module that returns the floor modulo of two input tensors.
tf.math.floormod(x, y, name=None)
where
x
: A tensor that can be any arbitrary dimension and data type.y
: A tensor with the same shape as x
and can be any arbitrary dimension and data type.name
: A name for the operation (optional).The function returns a tensor representing the element-wise floor modulo of the two input tensors.
import tensorflow as tf
x = tf.constant([-5, 10, 15, 20])
y = tf.constant([2, 3, 4, 5])
result = tf.math.floormod(x, y)
print(result)
The output of the above code will be:
tf.Tensor([-1 1 3 0], shape=(4,), dtype=int32)
In the example code above, we create two constant tensors x and y with values [-5, 10, 15, 20] and [2, 3, 4, 5] respectively. We then apply tf.math.floormod()
on these two tensors and store the result in the variable result. The output of the function is an array with the floor modulo of each element of x divided by its corresponding element in y.
Therefore, the output of the function is [-1, 1, 3, 0].