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 May 27, 2021
1 parent 1634f88 commit eed825c
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 0 deletions.
47 changes: 47 additions & 0 deletions docs/api/paddle/atan2_cn.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
.. _cn_api_fluid_layers_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,数据类型为:float32、float64、float16。
- x (Tensor) - 输入的Tensor,数据类型为:float32、float64、float16。
- name (str,可选) - 操作的名称(可选,默认值为None)。更多信息请参见 :ref:`api_guide_Name`。

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

返回类型: Tensor

**代码示例**:

.. 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])
33 changes: 33 additions & 0 deletions docs/api/paddle/expm1_cn.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
.. _cn_api_fluid_layers_expm1:

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

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

.. math::
out = e^x - 1
参数:
- **x** (Tensor) - 该OP的输入为多维Tensor。数据类型为float32,float64,float16。
- **name** (str, 可选) - 具体用法请参见 :ref:`api_guide_Name`,一般无需设置,默认值为None。

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

返回类型: Tensor

**代码示例**:

.. 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 eed825c

Please sign in to comment.