rad2deg

paddle. rad2deg ( x, name=None ) [source]

Convert each of the elements of input x from angles in radians to degrees.

Equation:
\[rad2deg(x)=180/ \pi * x\]
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
>>> import math

>>> x1 = paddle.to_tensor([3.142, -3.142, 6.283, -6.283, 1.570, -1.570])
>>> result1 = paddle.rad2deg(x1)
>>> result1
Tensor(shape=[6], dtype=float32, place=Place(cpu), stop_gradient=True,
[ 180.02334595, -180.02334595,  359.98937988, -359.98937988,
  89.95437622 , -89.95437622 ])

>>> x2 = paddle.to_tensor(math.pi/2)
>>> result2 = paddle.rad2deg(x2)
>>> result2
Tensor(shape=[], dtype=float32, place=Place(cpu), stop_gradient=True,
90.)

>>> x3 = paddle.to_tensor(1)
>>> result3 = paddle.rad2deg(x3)
>>> result3
Tensor(shape=[], dtype=float32, place=Place(cpu), stop_gradient=True,
57.29578018)