Skip to content

Commit

Permalink
add expm1, atan2 api, test=develop
Browse files Browse the repository at this point in the history
  • Loading branch information
ronny1996 committed Jun 10, 2021
1 parent b4b2ea1 commit b0403cc
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 0 deletions.
2 changes: 2 additions & 0 deletions docs/api/paddle/Overview_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ tensor数学操作
" :ref:`paddle.any <cn_api_tensor_any>` ", "对指定维度上的Tensor元素进行逻辑或运算"
" :ref:`paddle.asin <cn_api_fluid_layers_asin>` ", "arcsine函数"
" :ref:`paddle.atan <cn_api_fluid_layers_atan>` ", "arctangent函数"
" :ref:`paddle.atan2 <cn_api_paddle_atan2>` ", "arctangent2函数"
" :ref:`paddle.ceil <cn_api_fluid_layers_ceil>` ", "向上取整运算函数"
" :ref:`paddle.clip <cn_api_tensor_clip>` ", "将输入的所有元素进行剪裁,使得输出元素限制在[min, max]内"
" :ref:`paddle.conj <cn_api_tensor_conj>` ", "逐元素计算Tensor的共轭运算"
Expand All @@ -51,6 +52,7 @@ tensor数学操作
" :ref:`paddle.equal_all <cn_api_tensor_equal_all>` ", "如果所有相同位置的元素相同返回True,否则返回False"
" :ref:`paddle.erf <cn_api_fluid_layers_erf>` ", "逐元素计算 Erf 激活函数"
" :ref:`paddle.exp <cn_api_fluid_layers_exp>` ", "逐元素进行以自然数e为底指数运算"
" :ref:`paddle.expm1 <cn_api_paddle_expm1>` ", "逐元素进行以exp(x)-1运算"
" :ref:`paddle.floor <cn_api_fluid_layers_floor>` ", "向下取整函数"
" :ref:`paddle.floor_divide <cn_api_tensor_floor_divide>` ", "逐元素整除算子,输入 x 与输入 y 逐元素整除,并将各个位置的输出元素保存到返回结果中"
" :ref:`paddle.greater_equal <cn_api_tensor_cn_greater_equal>` ", "逐元素地返回 x>=y 的逻辑值"
Expand Down
52 changes: 52 additions & 0 deletions docs/api/paddle/atan2_cn.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
.. _cn_api_paddle_atan2:

atan2
-------------------------------

.. py:function:: paddle.atan2(y, x, name=None)
对y/x进行逐元素的arctangent运算,通过符号确定象限

.. math::
atan2(y,x)=\left\{\begin{matrix}
& tan^{-1}(\frac{y}{x}) & x > 0 \\
& tan^{-1}(\frac{y}{x}) + \pi & y>=0, x < 0 \\
& tan^{-1}(\frac{y}{x}) - \pi & y<0, x < 0 \\
& +\frac{\pi}{2} & y>0, x = 0 \\
& -\frac{\pi}{2} & y<0, x = 0 \\
&\text{undefined} & y=0, x = 0
\end{matrix}\right.
参数
:::::::::

- **y** (Tensor) - 输入的Tensor,数据类型为:float16、float32、float64。
- **x** (Tensor) - 输入的Tensor,数据类型为:float16、float32、float64。
- **name** (str,可选) - 操作的名称(可选,默认值为None)。更多信息请参见 :ref:`api_guide_Name`。

返回
:::::::::

输出Tensor,与 ``x`` 维度相同、数据类型相同。

**代码示例**:

.. code-block:: python
import paddle
y = paddle.to_tensor([-1, +1, +1, -1]).astype('float32')
#Tensor(shape=[4], dtype=float32, place=CUDAPlace(0), stop_gradient=True,
# [-1, 1, 1, -1])
x = paddle.to_tensor([-1, -1, +1, +1]).astype('float32')
#Tensor(shape=[4], dtype=float32, place=CUDAPlace(0), stop_gradient=True,
# [-1, -1, 1, 1])
out = paddle.atan2(y, x)
#Tensor(shape=[4], dtype=float32, place=CUDAPlace(0), stop_gradient=True,
# [-2.35619450, 2.35619450, 0.78539819, -0.78539819])
36 changes: 36 additions & 0 deletions docs/api/paddle/expm1_cn.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
.. _cn_api_paddle_expm1:

expm1
-------------------------------

.. py:function:: paddle.expm1(x, name=None)
对输入,逐元素进行以自然数e为底指数运算并减1。

.. math::
out = e^x - 1
参数
:::::::::

- **x** (Tensor) - 该OP的输入为多维Tensor。数据类型为:float16、float32、float64。
- **name** (str, 可选) - 操作的名称(可选,默认值为None)。更多信息请参见 :ref:`api_guide_Name`。

返回
:::::::::

输出为Tensor,与 ``x`` 维度相同、数据类型相同。

**代码示例**:

.. code-block:: python
import paddle
x = paddle.to_tensor([-0.4, -0.2, 0.1, 0.3])
out = paddle.expm1(x)
print(out)
# [-0.32967997, -0.18126924, 0.10517092, 0.34985882]

0 comments on commit b0403cc

Please sign in to comment.