Element-wise hypotenuse of right triangles with legs x1 and x2.
tf.keras.ops.hypot(
x1, x2
)
This is equivalent to computing sqrt(x1**2 + x2**2) element-wise,
with shape determined by broadcasting.
Args |
x1
|
A tensor, representing the first leg of the right triangle.
|
x2
|
A tensor, representing the second leg of the right triangle.
|
Returns |
A tensor with a shape determined by broadcasting x1 and x2.
|
Example:
x1 = keras.ops.convert_to_tensor([3.0, 4.0, 5.0])
x2 = keras.ops.convert_to_tensor([4.0, 3.0, 12.0])
keras.ops.hypot(x1, x2)
array([5., 5., 13.], dtype=float32)
x1 = keras.ops.convert_to_tensor([[1, 2], [3, 4]])
x2 = keras.ops.convert_to_tensor([1, 1])
keras.ops.hypot(x1, x2)
array([[1.41421356 2.23606798],
[3.16227766 4.12310563]], dtype=float32)