deg2rad¶
- paddle. deg2rad ( x, name=None ) [source]
-
Convert each of the elements of input x from degrees to angles in radians.
\[deg2rad(x)=\pi * x / 180\]- Parameters
-
x (Tensor) – An N-D Tensor, the data type is float32, float64, int32, int64.
name (str, optional) – Name for the operation (optional, default is None). For more information, please refer to Name.
- Returns
-
An N-D Tensor, the shape and data type is the same with input (The output data type is float32 when the input data type is int).
- Return type
-
out (Tensor)
Examples
import paddle x1 = paddle.to_tensor([180.0, -180.0, 360.0, -360.0, 90.0, -90.0]) result1 = paddle.deg2rad(x1) print(result1) # Tensor(shape=[6], dtype=float32, place=CUDAPlace(0), stop_gradient=True, # [3.14159274, -3.14159274, 6.28318548, -6.28318548, 1.57079637, # -1.57079637]) x2 = paddle.to_tensor(180) result2 = paddle.deg2rad(x2) print(result2) # Tensor(shape=[], dtype=float32, place=CUDAPlace(0), stop_gradient=True, # 3.14159274)