hypot¶
- paddle. hypot ( x, y, name=None ) [source]
-
Calculate the length of the hypotenuse of a right-angle triangle. The equation is:
\[out = {\sqrt{x^2 + y^2}}\]- Parameters
-
x (Tensor) – The input Tensor, the data type is float32, float64, int32 or int64.
y (Tensor) – The input Tensor, the data type is float32, float64, int32 or int64.
name (str, optional) – Name for the operation (optional, default is None).For more information, please refer to Name.
- Returns
-
An N-D Tensor. If x, y have different shapes and are “broadcastable”, the resulting tensor shape is the shape of x and y after broadcasting. If x, y have the same shape, its shape is the same as x and y. And the data type is float32 or float64.
- Return type
-
out (Tensor)
Examples
>>> import paddle >>> x = paddle.to_tensor([3], dtype='float32') >>> y = paddle.to_tensor([4], dtype='float32') >>> res = paddle.hypot(x, y) >>> print(res) Tensor(shape=[1], dtype=float32, place=Place(cpu), stop_gradient=True, [5.])