Skip to content

Commit a779a71

Browse files
committed
add expm1, atan2 api, test=develop
1 parent 1634f88 commit a779a71

File tree

2 files changed

+80
-0
lines changed

2 files changed

+80
-0
lines changed

docs/api/paddle/atan2_cn.rst

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
.. _cn_api_fluid_layers_atan2:
2+
3+
atan2
4+
-------------------------------
5+
6+
.. py:function:: paddle.atan2(y, x, name=None)
7+
8+
9+
10+
11+
对y/x进行逐元素的arctangent运算,通过符号确定象限
12+
13+
.. math::
14+
atan2(y,x)=\left\{\begin{matrix}
15+
& tan^{-1}(\frac{y}{x}) & x > 0 \\
16+
& tan^{-1}(\frac{y}{x}) + \pi & y>=0, x < 0 \\
17+
& tan^{-1}(\frac{y}{x}) - \pi & y<0, x < 0 \\
18+
& +\frac{\pi}{2} & y>0, x = 0 \\
19+
& -\frac{\pi}{2} & y<0, x = 0 \\
20+
&\text{undefined} & y=0, x = 0
21+
\end{matrix}\right.
22+
23+
24+
参数:
25+
- **y** (Tensor) - 输入的Tensor,数据类型为:float16、float32、float64。
26+
- **x** (Tensor) - 输入的Tensor,数据类型为:float16、float32、float64。
27+
- **name** (str,可选) - 操作的名称(可选,默认值为None)。更多信息请参见 :ref:`api_guide_Name`。
28+
29+
返回: 输出Tensor,与 ``x`` 维度相同、数据类型相同。
30+
31+
返回类型: Tensor
32+
33+
**代码示例**:
34+
35+
.. code-block:: python
36+
37+
import paddle
38+
y=paddle.to_tensor([-1, +1, +1, -1]).astype('float32')
39+
#Tensor(shape=[4], dtype=float32, place=CUDAPlace(0), stop_gradient=True,
40+
# [-1, 1, 1, -1])
41+
x=paddle.to_tensor([-1, -1, +1, +1]).astype('float32')
42+
#Tensor(shape=[4], dtype=float32, place=CUDAPlace(0), stop_gradient=True,
43+
# [-1, -1, 1, 1])
44+
45+
out=paddle.atan2(y, x)
46+
#Tensor(shape=[4], dtype=float32, place=CUDAPlace(0), stop_gradient=True,
47+
# [-2.35619450, 2.35619450, 0.78539819, -0.78539819])

docs/api/paddle/expm1_cn.rst

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
.. _cn_api_fluid_layers_expm1:
2+
3+
expm1
4+
-------------------------------
5+
6+
.. py:function:: paddle.expm1(x, name=None)
7+
8+
9+
10+
11+
对输入,逐元素进行以自然数e为底指数运算并减1。
12+
13+
.. math::
14+
out = e^x - 1
15+
16+
参数:
17+
- **x** (Tensor) - 该OP的输入为多维Tensor。数据类型为:float16、float32、float64。
18+
- **name** (str, 可选) - 操作的名称(可选,默认值为None)。更多信息请参见 :ref:`api_guide_Name`。
19+
20+
返回: 输出为Tensor,与 ``x`` 维度相同、数据类型相同。
21+
22+
返回类型: Tensor
23+
24+
**代码示例**:
25+
26+
.. code-block:: python
27+
28+
import paddle
29+
30+
x = paddle.to_tensor([-0.4, -0.2, 0.1, 0.3])
31+
out = paddle.expm1(x)
32+
print(out)
33+
# [-0.32967997, -0.18126924, 0.10517092, 0.34985882]

0 commit comments

Comments
 (0)