tf.keras.ops.hypot
Stay organized with collections
Save and categorize content based on your preferences.
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)
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 2026-10-31 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 2026-10-31 UTC."],[],[]]