未验证 提交 e89704e8 编写于 作者: Z zq19 提交者: GitHub

Zq 1.6 (#1583)

* fix_content_cn (#1579)

fix-contents_cn

* fix-apis-develop

* fix-one-error
上级 c36aaddc
=============
fluid.average
=============
.. toctree::
:maxdepth: 1
average/WeightedAverage.rst
.. THIS FILE IS GENERATED BY `gen_doc.{py|sh}`
!DO NOT EDIT THIS FILE MANUALLY!
.. _api_fluid_average_WeightedAverage:
WeightedAverage
---------------
.. autoclass:: paddle.fluid.average.WeightedAverage
:members:
:inherited-members:
:noindex:
=================
fluid.data_feeder
=================
.. toctree::
:maxdepth: 1
data_feeder/DataFeeder.rst
.. THIS FILE IS GENERATED BY `gen_doc.{py|sh}`
!DO NOT EDIT THIS FILE MANUALLY!
.. _api_fluid_data_feeder_DataFeeder:
DataFeeder
----------
.. autoclass:: paddle.fluid.data_feeder.DataFeeder
:members:
:inherited-members:
:noindex:
......@@ -14,7 +14,6 @@ fluid.dygraph
dygraph/Conv3DTranspose.rst
dygraph/CosineDecay.rst
dygraph/Embedding.rst
dygraph/enabled.rst
dygraph/ExponentialDecay.rst
dygraph/FC.rst
dygraph/GroupNorm.rst
......@@ -24,22 +23,17 @@ fluid.dygraph
dygraph/Layer.rst
dygraph/LayerNorm.rst
dygraph/load_dygraph.rst
dygraph/load_persistables.rst
dygraph/NaturalExpDecay.rst
dygraph/NCE.rst
dygraph/no_grad.rst
dygraph/NoamDecay.rst
dygraph/not_support.rst
dygraph/PiecewiseDecay.rst
dygraph/PolynomialDecay.rst
dygraph/Pool2D.rst
dygraph/PRelu.rst
dygraph/prepare_context.rst
dygraph/save_dygraph.rst
dygraph/save_persistables.rst
dygraph/SpectralNorm.rst
dygraph/start_gperf_profiler.rst
dygraph/stop_gperf_profiler.rst
dygraph/to_variable.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_enabled:
enabled
-------
.. autofunction:: paddle.fluid.dygraph.enabled
:noindex:
.. THIS FILE IS GENERATED BY `gen_doc.{py|sh}`
!DO NOT EDIT THIS FILE MANUALLY!
.. _api_fluid_dygraph_load_persistables:
load_persistables
-----------------
.. autofunction:: paddle.fluid.dygraph.load_persistables
:noindex:
.. THIS FILE IS GENERATED BY `gen_doc.{py|sh}`
!DO NOT EDIT THIS FILE MANUALLY!
.. _api_fluid_dygraph_not_support:
not_support
-----------
.. autofunction:: paddle.fluid.dygraph.not_support
:noindex:
.. THIS FILE IS GENERATED BY `gen_doc.{py|sh}`
!DO NOT EDIT THIS FILE MANUALLY!
.. _api_fluid_dygraph_save_persistables:
save_persistables
-----------------
.. autofunction:: paddle.fluid.dygraph.save_persistables
:noindex:
.. THIS FILE IS GENERATED BY `gen_doc.{py|sh}`
!DO NOT EDIT THIS FILE MANUALLY!
.. _api_fluid_dygraph_start_gperf_profiler:
start_gperf_profiler
--------------------
.. autofunction:: paddle.fluid.dygraph.start_gperf_profiler
:noindex:
.. THIS FILE IS GENERATED BY `gen_doc.{py|sh}`
!DO NOT EDIT THIS FILE MANUALLY!
.. _api_fluid_dygraph_stop_gperf_profiler:
stop_gperf_profiler
-------------------
.. autofunction:: paddle.fluid.dygraph.stop_gperf_profiler
:noindex:
......@@ -10,7 +10,7 @@
# python gen_doc.py --module_name layers.${module} --module_prefix layers --output layers/${module}.rst
#done
for module in layers data_feeder dataset clip metrics executor initializer io nets optimizer profiler regularizer transpiler backward average profiler unique_name dygraph
for module in layers dataset clip metrics executor initializer io nets optimizer profiler regularizer transpiler backward profiler unique_name dygraph
do
python gen_doc.py --module_name ${module} --module_prefix ${module} --output ${module} --to_multiple_files True
python gen_module_index.py ${module} fluid.${module}
......
......@@ -8,12 +8,10 @@ API Reference
../flags_en.rst
../api_guides/index_en.rst
fluid.rst
average.rst
backward.rst
clip.rst
data/data_reader.rst
data/dataset.rst
data_feeder.rst
dataset.rst
dygraph.rst
executor.rst
......
......@@ -12,7 +12,6 @@ fluid.io
io/compose.rst
io/ComposeNotAligned.rst
io/DataLoader.rst
io/Fake.rst
io/firstn.rst
io/load.rst
io/load_inference_model.rst
......
.. THIS FILE IS GENERATED BY `gen_doc.{py|sh}`
!DO NOT EDIT THIS FILE MANUALLY!
.. _api_fluid_io_Fake:
Fake
----
.. autoclass:: paddle.fluid.io.Fake
:members:
:inherited-members:
:noindex:
.. THIS FILE IS GENERATED BY `gen_doc.{py|sh}`
!DO NOT EDIT THIS FILE MANUALLY!
.. _api_fluid_io_PipeReader:
PipeReader
--------
.. autoclass:: paddle.fluid.io.PipeReader
:members:
:inherited-members:
:noindex:
......@@ -70,7 +70,6 @@ fluid.layers
layers/deformable_conv.rst
layers/deformable_roi_pooling.rst
layers/density_prior_box.rst
layers/detection_map.rst
layers/detection_output.rst
layers/diag.rst
layers/dice_loss.rst
......@@ -97,6 +96,7 @@ fluid.layers
layers/equal.rst
layers/exp.rst
layers/expand.rst
layers/expand_as.rst
layers/exponential_decay.rst
layers/eye.rst
layers/fc.rst
......@@ -164,7 +164,6 @@ fluid.layers
layers/lstm_unit.rst
layers/LSTMCell.rst
layers/margin_rank_loss.rst
layers/match_matrix_tensor.rst
layers/matmul.rst
layers/maxout.rst
layers/mean.rst
......@@ -174,7 +173,6 @@ fluid.layers
layers/mul.rst
layers/multi_box_head.rst
layers/multiclass_nms.rst
layers/multiclass_nms2.rst
layers/multiplex.rst
layers/MultivariateNormalDiag.rst
layers/natural_exp_decay.rst
......@@ -301,7 +299,6 @@ fluid.layers
layers/thresholded_relu.rst
layers/topk.rst
layers/transpose.rst
layers/tree_conv.rst
layers/unfold.rst
layers/Uniform.rst
layers/uniform_random.rst
......@@ -310,7 +307,6 @@ fluid.layers
layers/unique_with_counts.rst
layers/unsqueeze.rst
layers/unstack.rst
layers/var_conv_2d.rst
layers/warpctc.rst
layers/where.rst
layers/While.rst
......
.. THIS FILE IS GENERATED BY `gen_doc.{py|sh}`
!DO NOT EDIT THIS FILE MANUALLY!
.. _api_fluid_layers_detection_map:
detection_map
-------------
.. autofunction:: paddle.fluid.layers.detection_map
:noindex:
.. THIS FILE IS GENERATED BY `gen_doc.{py|sh}`
!DO NOT EDIT THIS FILE MANUALLY!
.. _api_fluid_layers_tree_conv:
.. _api_fluid_layers_expand_as:
tree_conv
expand_as
---------
.. autofunction:: paddle.fluid.layers.tree_conv
.. autofunction:: paddle.fluid.layers.expand_as
:noindex:
.. THIS FILE IS GENERATED BY `gen_doc.{py|sh}`
!DO NOT EDIT THIS FILE MANUALLY!
.. _api_fluid_layers_match_matrix_tensor:
match_matrix_tensor
-------------------
.. autofunction:: paddle.fluid.layers.match_matrix_tensor
:noindex:
.. THIS FILE IS GENERATED BY `gen_doc.{py|sh}`
!DO NOT EDIT THIS FILE MANUALLY!
.. _api_fluid_layers_multiclass_nms2:
multiclass_nms2
---------------
.. autofunction:: paddle.fluid.layers.multiclass_nms2
:noindex:
.. THIS FILE IS GENERATED BY `gen_doc.{py|sh}`
!DO NOT EDIT THIS FILE MANUALLY!
.. _api_fluid_layers_var_conv_2d:
var_conv_2d
-----------
.. autofunction:: paddle.fluid.layers.var_conv_2d
:noindex:
=======================
fluid.average
=======================
.. toctree::
:maxdepth: 1
average_cn/WeightedAverage_cn.rst
.. _cn_api_fluid_average_WeightedAverage:
WeightedAverage
-------------------------------
.. py:class:: paddle.fluid.average.WeightedAverage
计算加权平均值。
平均计算完全通过Python完成。它们不会改变Paddle的程序,也不会修改NN模型的配置。它们完全是Python函数的包装器。
**示例代码**
.. code-block:: python
import paddle.fluid as fluid
avg = fluid.average.WeightedAverage()
avg.add(value=2.0, weight=1)
avg.add(value=4.0, weight=2)
avg.eval()
# 结果为 3.333333333.
# 因为 (2.0 * 1 + 4.0 * 2) / (1 + 2) = 3.333333333
=======================
fluid.data_feeder
=======================
.. toctree::
:maxdepth: 1
data_feeder_cn/DataFeeder_cn.rst
.. _cn_api_fluid_data_feeder_DataFeeder:
DataFeeder
-------------------------------
.. py:class:: paddle.fluid.data_feeder.DataFeeder(feed_list, place, program=None)
``DataFeeder`` 负责将reader(数据读取函数)返回的数据转换为可以被 ``Executor`` 和 ``ParallelExecutor`` 解析的数据结构 - 用作executor的feed参数
reader通常是一个用来从文件中读取/生成数据样本的自定义python生成器,该函数通常会返回一个包含样本实例数据的列表。
参数:
- **feed_list** (list) – 向模型输入的变量列表或者变量名列表
- **place** (:ref:`cn_api_fluid_CPUPlace` | :ref:`cn_api_fluid_CUDAPlace` ) – place表明是向GPU还是CPU中输入数据。如果想向GPU中输入数据, 请使用 ``fluid.CUDAPlace(i)`` (i 代表 the GPU id);如果向CPU中输入数据, 请使用 ``fluid.CPUPlace()``
- **program** (:ref:`cn_api_fluid_Program` ) – 需要向其中输入数据的Program。如果为None, 会默认使用 ``default_main_program()`` 。 缺省值为None
异常情况: ``ValueError`` – 如果一些变量不在此 Program 中
**代码示例**
.. code-block:: python
import numpy as np
import paddle
import paddle.fluid as fluid
place = fluid.CPUPlace()
def reader():
for _ in range(4):
yield np.random.random([4]).astype('float32'), np.random.random([3]).astype('float32'),
main_program = fluid.Program()
startup_program = fluid.Program()
with fluid.program_guard(main_program, startup_program):
data_1 = fluid.layers.data(name='data_1', shape=[-1, 2, 2])
data_2 = fluid.layers.data(name='data_2', shape=[-1, 1, 3])
out = fluid.layers.fc(input=[data_1, data_2], size=2)
# ...
feeder = fluid.DataFeeder([data_1, data_2], place)
exe = fluid.Executor(place)
exe.run(startup_program)
feed_data = feeder.feed(reader())
# print feed_data to view feed results
# print(feed_data['data_1'])
# print(feed_data['data_2'])
outs = exe.run(program=main_program,
feed=feed_data,
fetch_list=[out])
print(outs)
.. py:method:: feed(iterable)
根据创建DataFeeder时候传入的feed_list(变量列表) 和iterable (自定义python生成器) 将原始数据转换为tensor结构
参数:
- **iterable** (generator) – 自定义的python生成器,用来获取原始输入数据
返回:以变量名为key,tensor为value的dict
返回类型: dict
**代码示例**
.. code-block:: python
# 本示例中,reader函数会返回一个长度为3的数组,每个元素都是ndarray类型,
# 分别对应data_1, data_2, data_3的原始数据
# feed函数内部会将每个传入的ndarray转换为Paddle内部用于计算的tensor结构
# 返回的结果是一个size为3的dict,key分别为data_1, data_2, data_3
# result['data_1'] 为一个shape 为 [5, 2, 1, 3] 的LoD-tensor 其中5为batch size, [2, 1, 3]为data_1的shape
# result['data_2'], result['data_3']以此类推
import numpy as np
import paddle.fluid as fluid
def reader(limit=5):
for i in range(1, limit + 1):
yield np.ones([6]).astype('float32') * i , np.ones([1]).astype('int64') * i, np.random.random([9]).astype('float32')
data_1 = fluid.layers.data(name='data_1', shape=[2, 1, 3])
data_2 = fluid.layers.data(name='data_2', shape=[1], dtype='int64')
data_3 = fluid.layers.data(name='data_3', shape=[3, 3], dtype='float32')
feeder = fluid.DataFeeder(['data_1','data_2', 'data_3'], fluid.CPUPlace())
result = feeder.feed(reader())
print(result['data_1'])
print(result['data_2'])
print(result['data_3'])
.. py:method:: feed_parallel(iterable, num_places=None)
功能类似于 ``feed`` 函数,feed_parallel用于使用多个设备(CPU|GPU)的情况,iterable为自定义的生成器列表,
列表中的每个生成器返回的数据最后会feed到相对应的设备中
参数:
- **iterable** (list(generator)) – 自定义的python生成器列表,列表元素个数与num_places保持一致
- **num_places** (int) – 设备数目。默认为None。
返回: 返回值为dict的生成器,生成器返回一个键值对为 ``变量名-tensor`` 组成的dict
返回类型: generator
.. note::
设备(CPU或GPU)的数目 - ``num-places`` 必须等于 ``iterable`` 参数中的生成器数量
**代码示例**
.. code-block:: python
import numpy as np
import paddle.fluid as fluid
def generate_reader(batch_size, base=0, factor=1):
def _reader():
for i in range(batch_size):
yield np.ones([4]) * factor + base, np.ones([4]) * factor + base + 5
return _reader()
x = fluid.layers.data(name='x', shape=[-1, 2, 2])
y = fluid.layers.data(name='y', shape=[-1, 2, 2], dtype='float32')
z = fluid.layers.elementwise_add(x, y)
feeder = fluid.DataFeeder(['x','y'], fluid.CPUPlace())
place_num = 2
places = [fluid.CPUPlace() for x in range(place_num)]
data = []
exe = fluid.Executor(fluid.CPUPlace())
exe.run(fluid.default_startup_program())
program = fluid.CompiledProgram(fluid.default_main_program()).with_data_parallel(places=places)
# 打印feed_parallel结果示例
# for item in list(feeder.feed_parallel([generate_reader(5, 0, 1), generate_reader(3, 10, 2)], 2)):
# print(item['x'])
# print(item['y'])
reader_list = [generate_reader(5, 0, 1), generate_reader(3, 10, 2)]
res = exe.run(program=program, feed=list(feeder.feed_parallel(reader_list, 2)), fetch_list=[z])
print(res)
.. py:method:: decorate_reader(reader, multi_devices, num_places=None, drop_last=True)
将reader返回的输入数据batch转换为多个mini-batch,之后每个mini-batch都会被输入进各个设备(CPU或GPU)中。
参数:
- **reader** (generator) – 一个用来自定义返回mini-batch的生成器,一个返回实例数据的reader可视为一个mini-batch(如下面例子中的 ``_mini_batch`` )
- **multi_devices** (bool) – 指明是否使用多个设备
- **num_places** (int,可选) – 如果 ``multi_devices`` 为 ``True`` , 可以使用此参数来设置设备数目。如果 ``num_places`` 为 ``None`` ,该函数默认使用当前训练机所有设备。默认为None。
- **drop_last** (bool, 可选) – 如果最后一组数据的数量比设备数要小,则可使用该参数来指明是否选择丢弃最后一个组数据。 默认为 ``True``
返回:一个装饰之后的生成器,该生成器会返回匹配num_places数量的tensor数据列表
返回类型:generator
异常情况: ValueError – 如果 ``drop_last`` 值为False并且最后一组数据的minibatch数目与设备数目不相等时,产生此异常
**代码示例**
.. code-block:: python
import numpy as np
import paddle
import paddle.fluid as fluid
import paddle.fluid.compiler as compiler
def reader():
def _mini_batch(batch_size):
for i in range(batch_size):
yield np.random.random([16]).astype('float32'), np.random.randint(10, size=[1])
for _ in range(10):
yield _mini_batch(np.random.randint(1, 10))
place_num = 3
places = [fluid.CPUPlace() for _ in range(place_num)]
data = fluid.layers.data(name='data', shape=[-1, 4, 4], dtype='float32')
label = fluid.layers.data(name='label', shape=[-1, 1], dtype='int64')
hidden = fluid.layers.fc(input=data, size=10)
feeder = fluid.DataFeeder(place=places[0], feed_list=[data, label])
reader = feeder.decorate_reader(reader, multi_devices=True, num_places=3, drop_last=True)
exe = fluid.Executor(places[0])
exe.run(fluid.default_startup_program())
compiled_prog = compiler.CompiledProgram(
fluid.default_main_program()).with_data_parallel(places=places)
for i,data in enumerate(reader()):
ret = exe.run(compiled_prog, feed=data, fetch_list=[hidden])
print(ret)
......@@ -29,12 +29,14 @@ fluid.dygraph
dygraph_cn/NaturalExpDecay_cn.rst
dygraph_cn/NCE_cn.rst
dygraph_cn/NoamDecay_cn.rst
dygraph_cn/no_grad_cn.rst
dygraph_cn/no_grad_cn.rst
dygraph_cn/PiecewiseDecay_cn.rst
dygraph_cn/PolynomialDecay_cn.rst
dygraph_cn/Pool2D_cn.rst
dygraph_cn/PRelu_cn.rst
dygraph_cn/prepare_context_cn.rst
dygraph_cn/save_dygraph_cn.rst
dygraph_cn/SpectralNorm_cn.rst
dygraph_cn/to_variable_cn.rst
dygraph_cn/Tracer_cn.rst
dygraph_cn/TreeConv_cn.rst
......@@ -31,6 +31,9 @@ fluid
fluid_cn/global_scope_cn.rst
fluid_cn/gradients_cn.rst
fluid_cn/in_dygraph_mode_cn.rst
fluid_cn/is_compiled_with_cuda_cn.rst
fluid_cn/load_cn.rst
fluid_cn/load_op_library_cn.rst
fluid_cn/LoDTensor_cn.rst
fluid_cn/LoDTensorArray_cn.rst
fluid_cn/memory_optimize_cn.rst
......@@ -41,6 +44,8 @@ fluid
fluid_cn/Program_cn.rst
fluid_cn/program_guard_cn.rst
fluid_cn/release_memory_cn.rst
fluid_cn/require_version_cn.rst
fluid_cn/save_cn.rst
fluid_cn/scope_guard_cn.rst
fluid_cn/Tensor_cn.rst
fluid_cn/Variable_cn.rst
......
......@@ -14,7 +14,9 @@ fluid.io
io_cn/cache_cn.rst
io_cn/chain_cn.rst
io_cn/compose_cn.rst
io_cn/Fake_cn.rst
io_cn/ComposeNotAligned_cn.rst
io_cn/DataLoader_cn.rst
io_cn/Fake_cn.rst
io_cn/firstn_cn.rst
io_cn/load_cn.rst
io_cn/load_inference_model_cn.rst
......@@ -23,7 +25,6 @@ fluid.io
io_cn/load_vars_cn.rst
io_cn/map_readers_cn.rst
io_cn/multiprocess_reader_cn.rst
io_cn/PipeReader_cn.rst
io_cn/PyReader_cn.rst
io_cn/save_cn.rst
io_cn/save_inference_model_cn.rst
......
......@@ -74,7 +74,6 @@ fluid.layers
layers_cn/deformable_conv_cn.rst
layers_cn/deformable_roi_pooling_cn.rst
layers_cn/density_prior_box_cn.rst
layers_cn/detection_map_cn.rst
layers_cn/detection_output_cn.rst
layers_cn/diag_cn.rst
layers_cn/dice_loss_cn.rst
......@@ -102,6 +101,7 @@ fluid.layers
layers_cn/equal_cn.rst
layers_cn/exp_cn.rst
layers_cn/expand_cn.rst
layers_cn/expend_as_cn.rst
layers_cn/exponential_decay_cn.rst
layers_cn/eye_cn.rst
layers_cn/fc_cn.rst
......@@ -202,6 +202,7 @@ fluid.layers
layers_cn/prelu_cn.rst
layers_cn/Print_cn.rst
layers_cn/prior_box_cn.rst
layers_cn/prroi_pool_cn.rst
layers_cn/psroi_pool_cn.rst
layers_cn/py_func_cn.rst
layers_cn/py_reader_cn.rst
......
......@@ -19,18 +19,20 @@ fluid.optimizer
optimizer_cn/DecayedAdagrad_cn.rst
optimizer_cn/DecayedAdagradOptimizer_cn.rst
optimizer_cn/DGCMomentumOptimizer_cn.rst
optimizer_cn/Dpsgd_cn.rst
optimizer_cn/DpsgdOptimizer_cn.rst
optimizer_cn/ExponentialMovingAverage_cn.rst
optimizer_cn/Ftrl_cn.rst
optimizer_cn/FtrlOptimizer_cn.rst
optimizer_cn/LambOptimizer_cn.rst
optimizer_cn/LarsMomentum_cn.rst
optimizer_cn/LarsMomentumOptimizer_cn.rst
optimizer_cn/LookaheadOptimizer_cn.rst
optimizer_cn/ModelAverage_cn.rst
optimizer_cn/Momentum_cn.rst
optimizer_cn/MomentumOptimizer_cn.rst
optimizer_cn/PipelineOptimizer_cn.rst
optimizer_cn/RecomputeOptimizer_cn.rst
optimizer_cn/RMSPropOptimizer_cn.rst
optimizer_cn/SGD_cn.rst
optimizer_cn/SGDOptimizer_cn.rst
optimizer_cn/LookaheadOptimizer_cn.rst
optimizer_cn/RecomputeOptimizer_cn.rst
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册