提交 335f5cd5 编写于 作者: H Hao Wang 提交者: Cheerego

Translation of 16 new apis (#651)

上级 00fd7517
...@@ -128,9 +128,62 @@ BOOL类型。如果设置为True, GPU操作中的一些锁将被释放,Paralle ...@@ -128,9 +128,62 @@ BOOL类型。如果设置为True, GPU操作中的一些锁将被释放,Paralle
.. _cn_api_fluid_CompiledProgram:
CompiledProgram
-------------------------------
.. py:class:: paddle.fluid.CompiledProgram(program)
编译一个接着用来执行的Program。
1. 首先使用layers(网络层)创建程序。
2. (可选)可使用CompiledProgram来在运行之前优化程序。
3. 定义的程序或CompiledProgram由Executor运行。
CompiledProgram用于转换程序以进行各种优化。例如,
- 预先计算一些逻辑,以便每次运行更快。
- 转换Program,使其可以在多个设备中运行。
- 转换Program以进行优化预测或分布式训练。
**代码示例**
.. code-block:: python
place = fluid.CUDAPlace(0) if use_cuda else fluid.CPUPlace()
exe = fluid.Executor(place)
exe.run(startup)
compiled_prog = compiler.CompiledProgram(main).with_data_parallel(
loss_name=loss.name)
for i in range(5):
test_loss, = exe.run(compiled_prog,
feed=feed_dict,
fetch_list=[loss.name])
参数:
- **program** : 一个Program对象,承载着用户定义的模型计算逻辑
.. py:method:: with_data_parallel(loss_name=None, build_strategy=None, exec_strategy=None, share_vars_from=None)
配置Program使其以数据并行方式运行。
参数:
- **loss_name** (str) - 损失函数名称必须在训练过程中设置。 默认None。
- **build_strategy** (BuildStrategy) - build_strategy用于构建图,因此它可以在具有优化拓扑的多个设备/核上运行。 有关更多信息,请参阅 ``fluid.BuildStrategy`` 。 默认None。
- **exec_strategy** (ExecutionStrategy) - exec_strategy用于选择执行图的方式,例如使用多少线程,每次清理临时变量之前进行的迭代次数。 有关更多信息,请参阅 ``fluid.ExecutionStrategy`` 。 默认None。
- **share_vars_from** (CompiledProgram) - 如果有,此CompiledProgram将共享来自share_vars_from的变量。 share_vars_from指定的Program必须由此CompiledProgram之前的Executor运行,以便vars准备就绪。
返回: self
.. py:method:: with_inference_optimize(config)
添加预测优化。
参数:
- **config** - 用于创建预测器的NativeConfig或AnalysisConfig的实例
返回: self
...@@ -1512,56 +1565,6 @@ release_memory ...@@ -1512,56 +1565,6 @@ release_memory
.. _cn_api_fluid_Scope:
Scope
-------------------------------
.. py:class:: paddle.fluid.scope(scope)
(作用域)Scope为变量名的联合。所有变量都属于Scope。
从本地作用域中可以拉取到其双亲作用域的变量。
要想运行一个网络,需要指明它运行所在的域,确切的说: exe.Run(&scope) 。
一个网络可以在不同域上运行,并且更新该域的各类变量。
在作用域上创建一个变量,并在域中获取。
**代码示例**
.. code-block:: python
# create tensor from a scope and set value to it.
param = scope.var('Param').get_tensor()
param_array = np.full((height, row_numel), 5.0).astype("float32")
param.set(param_array, place)
.. py:method:: drop_kids(self: paddle.fluid.core.Scope) → None
.. py:method:: find_var(self: paddle.fluid.core.Scope, arg0: unicode) → paddle.fluid.core.Variable
.. py:method:: new_scope(self: paddle.fluid.core.Scope) → paddle.fluid.core.Scope
.. py:method:: var(self: paddle.fluid.core.Scope, arg0: unicode) → paddle.fluid.core.Variable
.. _cn_api_fluid_scope_guard: .. _cn_api_fluid_scope_guard:
scope_guard scope_guard
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
.. _cn_api_fluid_initializer_Bilinear: .. _cn_api_fluid_initializer_Bilinear:
Bilinear Bilinear
>>>>>>>>>>> -------------------------------
.. py:attribute:: paddle.fluid.initializer.Bilinear .. py:attribute:: paddle.fluid.initializer.Bilinear
...@@ -16,7 +16,7 @@ Bilinear ...@@ -16,7 +16,7 @@ Bilinear
.. _cn_api_fluid_initializer_BilinearInitializer: .. _cn_api_fluid_initializer_BilinearInitializer:
BilinearInitializer BilinearInitializer
>>>>>>>>>>>>>>>>>>>>> -------------------------------
.. py:class:: paddle.fluid.initializer.BilinearInitializer .. py:class:: paddle.fluid.initializer.BilinearInitializer
...@@ -49,7 +49,7 @@ num_filters = C和groups = C 表示这是按通道转置的卷积函数。滤波 ...@@ -49,7 +49,7 @@ num_filters = C和groups = C 表示这是按通道转置的卷积函数。滤波
.. _cn_api_fluid_initializer_Constant: .. _cn_api_fluid_initializer_Constant:
Constant Constant
>>>>>>>>>> -------------------------------
.. py:attribute:: paddle.fluid.initializer.Constant .. py:attribute:: paddle.fluid.initializer.Constant
...@@ -59,7 +59,7 @@ Constant ...@@ -59,7 +59,7 @@ Constant
.. _cn_api_fluid_initializer_ConstantInitializer: .. _cn_api_fluid_initializer_ConstantInitializer:
ConstantInitializer ConstantInitializer
>>>>>>>>>>>> -------------------------------
.. py:class:: paddle.fluid.initializer.ConstantInitializer(value=0.0, force_cpu=False) .. py:class:: paddle.fluid.initializer.ConstantInitializer(value=0.0, force_cpu=False)
...@@ -84,7 +84,7 @@ ConstantInitializer ...@@ -84,7 +84,7 @@ ConstantInitializer
.. _cn_api_fluid_initializer_force_init_on_cpu: .. _cn_api_fluid_initializer_force_init_on_cpu:
force_init_on_cpu force_init_on_cpu
>>>>>>>>>>>>>>>>>>> -------------------------------
.. py:function:: paddle.fluid.initializer.force_init_on_cpu() .. py:function:: paddle.fluid.initializer.force_init_on_cpu()
...@@ -114,7 +114,7 @@ force_init_on_cpu ...@@ -114,7 +114,7 @@ force_init_on_cpu
.. _cn_api_fluid_initializer_init_on_cpu: .. _cn_api_fluid_initializer_init_on_cpu:
init_on_cpu init_on_cpu
>>>>>>>>>>>> -------------------------------
.. py:function:: paddle.fluid.initializer.init_on_cpu(*args, **kwds) .. py:function:: paddle.fluid.initializer.init_on_cpu(*args, **kwds)
...@@ -135,7 +135,7 @@ init_on_cpu ...@@ -135,7 +135,7 @@ init_on_cpu
.. _cn_api_fluid_initializer_MSRA: .. _cn_api_fluid_initializer_MSRA:
MSRA MSRA
>>>>>> -------------------------------
.. py:attribute:: paddle.fluid.initializer.MSRA .. py:attribute:: paddle.fluid.initializer.MSRA
...@@ -144,7 +144,7 @@ MSRA ...@@ -144,7 +144,7 @@ MSRA
.. _cn_api_fluid_initializer_MSRAInitializer: .. _cn_api_fluid_initializer_MSRAInitializer:
MSRAInitializer MSRAInitializer
>>>>>>>>>>>>>>>>> -------------------------------
.. py:class:: paddle.fluid.initializer.MSRAInitializer(uniform=True, fan_in=None, seed=0) .. py:class:: paddle.fluid.initializer.MSRAInitializer(uniform=True, fan_in=None, seed=0)
...@@ -189,7 +189,7 @@ MSRAInitializer ...@@ -189,7 +189,7 @@ MSRAInitializer
.. _cn_api_fluid_initializer_Normal: .. _cn_api_fluid_initializer_Normal:
Normal Normal
>>>>>>>> -------------------------------
.. py:attribute:: paddle.fluid.initializer.Normal .. py:attribute:: paddle.fluid.initializer.Normal
...@@ -199,7 +199,7 @@ Normal ...@@ -199,7 +199,7 @@ Normal
.. _cn_api_fluid_initializer_NormalInitializer: .. _cn_api_fluid_initializer_NormalInitializer:
NormalInitializer NormalInitializer
>>>>>>>>>>>> -------------------------------
.. py:class:: paddle.fluid.initializer.NormalInitializer(loc=0.0, scale=1.0, seed=0) .. py:class:: paddle.fluid.initializer.NormalInitializer(loc=0.0, scale=1.0, seed=0)
...@@ -218,15 +218,30 @@ NormalInitializer ...@@ -218,15 +218,30 @@ NormalInitializer
param_attr=fluid.initializer.Normal(loc=0.0, scale=2.0) param_attr=fluid.initializer.Normal(loc=0.0, scale=2.0)
.. _cn_api_fluid_initializer_NumpyArrayInitializer:
NumpyArrayInitializer
-------------------------------
.. py:class:: paddle.fluid.initializer.NumpyArrayInitializer(value)
使用Numpy型数组来初始化参数变量。
参数:
- **value** (numpy) - 用于初始化变量的一个Numpy型数组。
**代码示例**
.. code-block:: python
fc = fluid.layers.fc(input=x, size=10,
param_attr=fluid.initializer.NumpyArrayInitializer(numpy.array([1,2])))
.. _cn_api_fluid_initializer_TruncatedNormal: .. _cn_api_fluid_initializer_TruncatedNormal:
TruncatedNormal TruncatedNormal
>>>>>>>>>>>>>>>>> -------------------------------
.. py:attribute:: paddle.fluid.initializer.TruncatedNormal .. py:attribute:: paddle.fluid.initializer.TruncatedNormal
...@@ -236,7 +251,7 @@ TruncatedNormal ...@@ -236,7 +251,7 @@ TruncatedNormal
.. _cn_api_fluid_initializer_TruncatedNormalInitializer: .. _cn_api_fluid_initializer_TruncatedNormalInitializer:
TruncatedNormalInitializer TruncatedNormalInitializer
>>>>>>>>>>>> -------------------------------
.. py:class:: paddle.fluid.initializer.TruncatedNormalInitializer(loc=0.0, scale=1.0, seed=0) .. py:class:: paddle.fluid.initializer.TruncatedNormalInitializer(loc=0.0, scale=1.0, seed=0)
...@@ -265,7 +280,7 @@ Random Truncated Normal(高斯)分布初始化器 ...@@ -265,7 +280,7 @@ Random Truncated Normal(高斯)分布初始化器
.. _cn_api_fluid_initializer_Uniform: .. _cn_api_fluid_initializer_Uniform:
Uniform Uniform
>>>>>>>>> -------------------------------
.. py:attribute:: paddle.fluid.initializer.Uniform .. py:attribute:: paddle.fluid.initializer.Uniform
...@@ -276,7 +291,7 @@ Uniform ...@@ -276,7 +291,7 @@ Uniform
.. _cn_api_fluid_initializer_UniformInitializer: .. _cn_api_fluid_initializer_UniformInitializer:
UniformInitializer UniformInitializer
>>>>>>>>>>>> -------------------------------
.. py:class:: paddle.fluid.initializer.UniformInitializer(low=-1.0, high=1.0, seed=0) .. py:class:: paddle.fluid.initializer.UniformInitializer(low=-1.0, high=1.0, seed=0)
...@@ -305,7 +320,7 @@ UniformInitializer ...@@ -305,7 +320,7 @@ UniformInitializer
.. _cn_api_fluid_initializer_Xavier: .. _cn_api_fluid_initializer_Xavier:
Xavier Xavier
>>>>>>>>> -------------------------------
.. py:attribute:: paddle.fluid.initializer.Xavier .. py:attribute:: paddle.fluid.initializer.Xavier
...@@ -319,7 +334,8 @@ Xavier ...@@ -319,7 +334,8 @@ Xavier
.. _cn_api_fluid_initializer_XavierInitializer: .. _cn_api_fluid_initializer_XavierInitializer:
XavierInitializer XavierInitializer
>>>>>>>>>>>>>>>>>>> -------------------------------
.. py:class:: paddle.fluid.initializer.XavierInitializer(uniform=True, fan_in=None, fan_out=None, seed=0) .. py:class:: paddle.fluid.initializer.XavierInitializer(uniform=True, fan_in=None, fan_out=None, seed=0)
该类实现Xavier权重初始化方法( Xavier weight initializer),Xavier权重初始化方法出自Xavier Glorot和Yoshua Bengio的论文 `Understanding the difficulty of training deep feedforward neural networks <http://proceedings.mlr.press/v9/glorot10a/glorot10a.pdf>`_ 该类实现Xavier权重初始化方法( Xavier weight initializer),Xavier权重初始化方法出自Xavier Glorot和Yoshua Bengio的论文 `Understanding the difficulty of training deep feedforward neural networks <http://proceedings.mlr.press/v9/glorot10a/glorot10a.pdf>`_
......
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册