📅  最后修改于: 2023-12-03 15:04:10.964000             🧑  作者: Mango
The tensorflow.math.divide()
function is used to perform element-wise division of two tensors. It takes two arguments, x
and y
, and returns the element-wise division of x
by y
.
tensorflow.math.divide(
x,
y,
name=None
)
x
of shape [..., N]
.y
of shape [..., N]
, or a scalar: y
is broadcast to x
.The element-wise division of x
by y
.
import tensorflow as tf
# Defining tensors
x = tf.constant([8.0, 5.0, 6.0])
y = tf.constant([2.0, 3.0, 2.0])
# Element-wise division
result = tf.math.divide(x, y)
# Printing result
print("Result: ", result)
Output:
Result: tf.Tensor([4. 1.66666667 3. ], shape=(3,), dtype=float32)
In the above example, we have defined two tensors x
and y
and performed element-wise division between them using the tensorflow.math.divide()
function. The result is stored in the result
variable and printed using the print()
function.