Skip to content

Commit f31d72c

Browse files
committed
add expm1, atan2 api, test=develop
1 parent b4b2ea1 commit f31d72c

File tree

3 files changed

+92
-0
lines changed

3 files changed

+92
-0
lines changed

docs/api/paddle/Overview_cn.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ tensor数学操作
4040
" :ref:`paddle.any <cn_api_tensor_any>` ", "对指定维度上的Tensor元素进行逻辑或运算"
4141
" :ref:`paddle.asin <cn_api_fluid_layers_asin>` ", "arcsine函数"
4242
" :ref:`paddle.atan <cn_api_fluid_layers_atan>` ", "arctangent函数"
43+
" :ref:`paddle.atan2 <cn_api_paddle_atan2>` ", "arctangent2函数"
4344
" :ref:`paddle.ceil <cn_api_fluid_layers_ceil>` ", "向上取整运算函数"
4445
" :ref:`paddle.clip <cn_api_tensor_clip>` ", "将输入的所有元素进行剪裁,使得输出元素限制在[min, max]内"
4546
" :ref:`paddle.conj <cn_api_tensor_conj>` ", "逐元素计算Tensor的共轭运算"
@@ -51,6 +52,7 @@ tensor数学操作
5152
" :ref:`paddle.equal_all <cn_api_tensor_equal_all>` ", "如果所有相同位置的元素相同返回True,否则返回False"
5253
" :ref:`paddle.erf <cn_api_fluid_layers_erf>` ", "逐元素计算 Erf 激活函数"
5354
" :ref:`paddle.exp <cn_api_fluid_layers_exp>` ", "逐元素进行以自然数e为底指数运算"
55+
" :ref:`paddle.expm1 <cn_api_paddle_expm1>` ", "逐元素进行exp(x)-1运算"
5456
" :ref:`paddle.floor <cn_api_fluid_layers_floor>` ", "向下取整函数"
5557
" :ref:`paddle.floor_divide <cn_api_tensor_floor_divide>` ", "逐元素整除算子,输入 x 与输入 y 逐元素整除,并将各个位置的输出元素保存到返回结果中"
5658
" :ref:`paddle.greater_equal <cn_api_tensor_cn_greater_equal>` ", "逐元素地返回 x>=y 的逻辑值"

docs/api/paddle/atan2_cn.rst

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
.. _cn_api_paddle_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+
:::::::::
26+
27+
- **y** (Tensor) - 输入的Tensor,数据类型为:float16、float32、float64。
28+
- **x** (Tensor) - 输入的Tensor,数据类型为:float16、float32、float64。
29+
- **name** (str,可选) - 操作的名称(可选,默认值为None)。更多信息请参见 :ref:`api_guide_Name`。
30+
31+
返回
32+
:::::::::
33+
34+
输出Tensor,与 ``x`` 维度相同、数据类型相同。
35+
36+
代码示例
37+
:::::::::
38+
39+
.. code-block:: python
40+
41+
import paddle
42+
43+
y = paddle.to_tensor([-1, +1, +1, -1]).astype('float32')
44+
#Tensor(shape=[4], dtype=float32, place=CUDAPlace(0), stop_gradient=True,
45+
# [-1, 1, 1, -1])
46+
47+
x = paddle.to_tensor([-1, -1, +1, +1]).astype('float32')
48+
#Tensor(shape=[4], dtype=float32, place=CUDAPlace(0), stop_gradient=True,
49+
# [-1, -1, 1, 1])
50+
51+
out = paddle.atan2(y, x)
52+
#Tensor(shape=[4], dtype=float32, place=CUDAPlace(0), stop_gradient=True,
53+
# [-2.35619450, 2.35619450, 0.78539819, -0.78539819])

docs/api/paddle/expm1_cn.rst

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
.. _cn_api_paddle_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+
:::::::::
18+
19+
- **x** (Tensor) - 该OP的输入为多维Tensor。数据类型为:float16、float32、float64。
20+
- **name** (str, 可选) - 操作的名称(可选,默认值为None)。更多信息请参见 :ref:`api_guide_Name`。
21+
22+
返回
23+
:::::::::
24+
25+
输出为Tensor,与 ``x`` 维度相同、数据类型相同。
26+
27+
代码示例
28+
:::::::::
29+
30+
.. code-block:: python
31+
32+
import paddle
33+
34+
x = paddle.to_tensor([-0.4, -0.2, 0.1, 0.3])
35+
out = paddle.expm1(x)
36+
print(out)
37+
# [-0.32967997, -0.18126924, 0.10517092, 0.34985882]

0 commit comments

Comments
 (0)