Skip to content

Commit

Permalink
Add real & imag op and api cn doc (PaddlePaddle#3042)
Browse files Browse the repository at this point in the history
* add real imag cn doc

* fix detail error

* add alias mapping

* fix alias error
  • Loading branch information
chenwhql authored Dec 18, 2020
1 parent b94bf21 commit ba9cef6
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 0 deletions.
2 changes: 2 additions & 0 deletions doc/paddle/api/alias_api_mapping
Original file line number Diff line number Diff line change
Expand Up @@ -546,3 +546,5 @@ paddle.nn.layer.common.UpsamplingNearest2D paddle.nn.UpsamplingNearest2D,paddle.
paddle.fluid.initializer.set_global_initializer paddle.nn.initializer.set_global_initializer
paddle.fluid.io.load_program_state paddle.static.load_program_state
paddle.fluid.io.set_program_state paddle.static.set_program_state
paddle.tensor.attribute.real paddle.real,paddle.tensor.real
paddle.tensor.attribute.imag paddle.imag,paddle.tensor.imag
36 changes: 36 additions & 0 deletions doc/paddle/api/paddle/tensor/attribute/imag_cn.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
.. _cn_api_tensor_imag:

imag
------

.. py:function:: paddle.imag(x, name=None)
返回一个包含输入复数Tensor的虚部数值的新Tensor。

参数:
- **x** (Tensor) - 输入Tensor,其数据类型可以为complex64或complex128。
- **name** (str,可选) - 具体用法请参见 :ref:`api_guide_Name` ,一般无需设置,默认值为None。

返回:Tensor,包含原复数Tensor的虚部数值。

**代码示例**:

.. code-block:: python
import paddle
x = paddle.to_tensor(
[[1 + 6j, 2 + 5j, 3 + 4j], [4 + 3j, 5 + 2j, 6 + 1j]])
# Tensor(shape=[2, 3], dtype=complex64, place=CUDAPlace(0), stop_gradient=True,
# [[(1+6j), (2+5j), (3+4j)],
# [(4+3j), (5+2j), (6+1j)]])
imag_res = paddle.imag(x)
# Tensor(shape=[2, 3], dtype=float32, place=CUDAPlace(0), stop_gradient=True,
# [[6., 5., 4.],
# [3., 2., 1.]])
imag_t = x.imag()
# Tensor(shape=[2, 3], dtype=float32, place=CUDAPlace(0), stop_gradient=True,
# [[6., 5., 4.],
# [3., 2., 1.]])
36 changes: 36 additions & 0 deletions doc/paddle/api/paddle/tensor/attribute/real_cn.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
.. _cn_api_tensor_real:

real
------

.. py:function:: paddle.real(x, name=None)
返回一个包含输入复数Tensor的实部数值的新Tensor。

参数:
- **x** (Tensor) - 输入Tensor,其数据类型可以为complex64或complex128。
- **name** (str,可选) - 具体用法请参见 :ref:`api_guide_Name` ,一般无需设置,默认值为None。

返回:Tensor,包含原复数Tensor的实部数值。

**代码示例**:

.. code-block:: python
import paddle
x = paddle.to_tensor(
[[1 + 6j, 2 + 5j, 3 + 4j], [4 + 3j, 5 + 2j, 6 + 1j]])
# Tensor(shape=[2, 3], dtype=complex64, place=CUDAPlace(0), stop_gradient=True,
# [[(1+6j), (2+5j), (3+4j)],
# [(4+3j), (5+2j), (6+1j)]])
real_res = paddle.real(x)
# Tensor(shape=[2, 3], dtype=float32, place=CUDAPlace(0), stop_gradient=True,
# [[1., 2., 3.],
# [4., 5., 6.]])
real_t = x.real()
# Tensor(shape=[2, 3], dtype=float32, place=CUDAPlace(0), stop_gradient=True,
# [[1., 2., 3.],
# [4., 5., 6.]])

0 comments on commit ba9cef6

Please sign in to comment.