未验证 提交 e30af5b2 编写于 作者: C Chen Long 提交者: GitHub

Add docs (#2404)

* fix_1.8_docs test=release/1.8

* fix_style test=release/1.8
上级 bf30ceb9
......@@ -9,6 +9,7 @@ dataset
dataset/conll05.rst
dataset/imdb.rst
dataset/imikolov.rst
dataset/mnist.rst
dataset/movielens.rst
dataset/sentiment.rst
dataset/uci_housing.rst
......
mnist
+++++
.. automodule:: paddle.dataset.mnist
:members:
:noindex:
......@@ -55,5 +55,4 @@ fluid.dygraph
dygraph/SpectralNorm.rst
dygraph/to_variable.rst
dygraph/TracedLayer.rst
dygraph/Tracer.rst
dygraph/TreeConv.rst
.. THIS FILE IS GENERATED BY `gen_doc.{py|sh}`
!DO NOT EDIT THIS FILE MANUALLY!
.. _api_fluid_dygraph_Tracer:
Tracer
------
.. autoclass:: paddle.fluid.dygraph.Tracer
:members:
:noindex:
......@@ -117,7 +117,6 @@ fluid.layers
layers/eye.rst
layers/fc.rst
layers/fill_constant.rst
layers/fill_constant_batch_size_like.rst
layers/filter_by_instag.rst
layers/flatten.rst
layers/flip.rst
......@@ -129,7 +128,6 @@ fluid.layers
layers/gather_nd.rst
layers/gather_tree.rst
layers/gaussian_random.rst
layers/gaussian_random_batch_size_like.rst
layers/gelu.rst
layers/generate_mask_labels.rst
layers/generate_proposal_labels.rst
......@@ -345,7 +343,6 @@ fluid.layers
layers/unfold.rst
layers/Uniform.rst
layers/uniform_random.rst
layers/uniform_random_batch_size_like.rst
layers/unique.rst
layers/unique_with_counts.rst
layers/unsqueeze.rst
......
.. THIS FILE IS GENERATED BY `gen_doc.{py|sh}`
!DO NOT EDIT THIS FILE MANUALLY!
.. _api_fluid_layers_fill_constant_batch_size_like:
fill_constant_batch_size_like
-----------------------------
.. autofunction:: paddle.fluid.layers.fill_constant_batch_size_like
:noindex:
.. THIS FILE IS GENERATED BY `gen_doc.{py|sh}`
!DO NOT EDIT THIS FILE MANUALLY!
.. _api_fluid_layers_gaussian_random_batch_size_like:
gaussian_random_batch_size_like
-------------------------------
.. autofunction:: paddle.fluid.layers.gaussian_random_batch_size_like
:noindex:
.. THIS FILE IS GENERATED BY `gen_doc.{py|sh}`
!DO NOT EDIT THIS FILE MANUALLY!
.. _api_fluid_layers_uniform_random_batch_size_like:
uniform_random_batch_size_like
------------------------------
.. autofunction:: paddle.fluid.layers.uniform_random_batch_size_like
:noindex:
......@@ -8,11 +8,11 @@ dataset
.. toctree::
:maxdepth: 1
dataset_cn/mnist_cn.rst
dataset_cn/cifar_cn.rst
dataset_cn/Conll05_cn.rst
dataset_cn/imdb_cn.rst
dataset_cn/imikolov_cn.rst
dataset_cn/mnist_cn.rst
dataset_cn/movielens_cn.rst
dataset_cn/sentiment_cn.rst
dataset_cn/uci_housing_cn.rst
......
......@@ -17,9 +17,14 @@ fluid.dygraph
dygraph_cn/Conv3D_cn.rst
dygraph_cn/Conv3DTranspose_cn.rst
dygraph_cn/CosineDecay_cn.rst
dygraph_cn/disable_dygraph_cn.rst
dygraph_cn/disable_imperative_cn.rst
dygraph_cn/Dropout_cn.rst
dygraph_cn/declarative_cn.rst
dygraph_cn/Embedding_cn.rst
dygraph_cn/enable_dygraph_cn.rst
dygraph_cn/enable_imperative_cn.rst
dygraph_cn/enabled_cn.rst
dygraph_cn/ExponentialDecay_cn.rst
dygraph_cn/grad_cn.rst
dygraph_cn/GroupNorm_cn.rst
......
.. _cn_api_fluid_dygraph_disable_dygraph:
disable_dygraph
-------------------------------
.. py:function:: paddle.fluid.dygraph.disable_dygraph()
该接口关闭动态图模式。
.. note::
推荐使用 :ref:`cn_api_fluid_dygraph_disable_imperative` 。
返回
::::::::::::
代码示例
::::::::::::
.. code-block:: python
import paddle.fluid as fluid
import numpy as np
fluid.dygraph.enable_dygraph() # Now we are in dygraph mode
print(fluid.in_dygraph_mode()) # True
fluid.dygraph.disable_dygraph()
print(fluid.in_dygraph_mode()) # False
.. _cn_api_fluid_dygraph_disable_imperative:
disable_imperative
-------------------------------
.. py:function:: paddle.fluid.dygraph.disable_imperative()
该接口退出动态图模式。
返回
::::::::::::
代码示例
::::::::::::
.. code-block:: python
import paddle.fluid as fluid
fluid.dygraph.enable_imperative() # Now we are in imperative mode
x = fluid.layers.ones( (2, 2), "float32")
y = fluid.layers.zeros( (2, 2), "float32")
z = x + y
print( z.numpy() ) #[[1, 1], [1, 1]]
fluid.dygraph.disable_imperative() # Now we are in declarative mode
.. _cn_api_fluid_dygraph_enable_dygraph:
enable_dygraph
-------------------------------
.. py:function:: paddle.fluid.dygraph.enable_dygraph(place=None)
该接口打开动态图模式。
.. note::
推荐使用 :ref:`cn_api_fluid_dygraph_enable_imperative` 。
参数
::::::::::::
- **place** (fluid.CPUPlace 或 fluid.CUDAPlace,可选) - 执行动态图的设备数目。若为None,则设备根据paddle的编译方式决定。默认值为 ``None`` 。
返回
::::::::::::
代码示例
::::::::::::
.. code-block:: python
import paddle.fluid as fluid
import numpy as np
fluid.dygraph.enable_dygraph() # Now we are in dygraph mode
print(fluid.in_dygraph_mode()) # True
fluid.dygraph.disable_dygraph()
print(fluid.in_dygraph_mode()) # False
.. _cn_api_fluid_dygraph_enable_imperative:
enable_imperative
-------------------------------
.. py:function:: paddle.fluid.dygraph.enable_imperative(place=None)
该接口打开动态图模式。
参数
::::::::::::
- **place** (fluid.CPUPlace 或 fluid.CUDAPlace,可选) - 执行动态图的设备。若为None,则设备根据paddle的编译方式决定。默认值为 ``None`` 。
返回
::::::::::::
代码示例
::::::::::::
.. code-block:: python
import paddle.fluid as fluid
fluid.dygraph.enable_imperative() # Now we are in imperative mode
x = fluid.layers.ones( (2, 2), "float32")
y = fluid.layers.zeros( (2, 2), "float32")
z = x + y
print( z.numpy() ) #[[1, 1], [1, 1]]
.. _cn_api_fluid_dygraph_enabled:
enabled
-------------------------------
.. py:method:: paddle.fluid.dygraph.enabled()
这个函数用于检查程序是否运行在动态图模式。你可以使用 :ref:`cn_api_fluid_dygraph_guard` api进入动态图模式。或者使用 :ref:`cn_api_fluid_enable_dygraph` 和 :ref:`cn_api_fluid_disable_dygraph` api打开、关闭动态图模式。
.. note::
`fluid.dygraph.enabled` 实际上调用了 :ref:`cn_api_fluid_in_dygraph_mode` api,所以推荐使用 :ref:`cn_api_fluid_in_dygraph_mode` api。
返回
:::::::::
程序是否运行在动态图模式。
返回类型
:::::::::
bool
代码示例
:::::::::
.. code-block:: python
import paddle.fluid as fluid
fluid.enable_dygraph() # Now we are in dygragh mode
print(fluid.dygraph.enabled()) # True
fluid.disable_dygraph()
print(fluid.dygraph.enabled()) # False
......@@ -10,6 +10,7 @@ fluid
fluid_cn/BuildStrategy_cn.rst
fluid_cn/CompiledProgram_cn.rst
fluid_cn/ComplexVariable_cn.rst
fluid_cn/cpu_places_cn.rst
fluid_cn/CPUPlace_cn.rst
fluid_cn/create_lod_tensor_cn.rst
......
.. _cn_api_fluid_ComplexVariable:
ComplexVariable
-------------------------------
.. py:class:: paddle.fluid.ComplexVariable(real, imag)
:api_attr: 命令式编程模式(动态图)
``ComplexVariable`` 可以定义存储复数的变量。它包含两个参数 ``real`` 和 ``imag`` ,分别存储复数的实数部分与虚数部分。
.. note::
``ComplexVariable`` 不应该被直接调用。目前只支持动态图模式,请通过给 :ref:`cn_api_fluid_dygraph_to_variable` 传入复数数据的方式创建一个动态图下的复数变量。
参数
:::::::::
- **real** (Variable) - 存储复数的实数部分。
- **imag** (Variable) - 存储复数的虚数部分
代码示例
:::::::::
.. code-block:: python
import paddle.fluid as fluid
import numpy as np
a = np.array([1.0+2.0j, 0.2])
with fluid.dygraph.guard():
var = fluid.dygraph.to_variable(a, name="new_var")
print(var.name, var.dtype, var.shape)
# ({'real': u'new_var.real', 'imag': u'new_var.imag'}, 'complex128', [2L])
print(var.numpy())
# [1. +2.j 0.2+0.j]
......@@ -7,6 +7,9 @@ disable_dygraph
该接口关闭动态图模式。
.. note::
推荐使用 :ref:`cn_api_fluid_dygraph_disable_imperative` 。
返回
::::::::::::
......
......@@ -7,6 +7,9 @@ enable_dygraph
该接口打开动态图模式。
.. note::
推荐使用 :ref:`cn_api_fluid_enable_imperative` 。
参数
::::::::::::
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册