未验证 提交 a64ab913 编写于 作者: H hutuxian 提交者: GitHub

Remove pipeline_optimizer and RoundRobin (#2258)

上级 4bbd6efc
......@@ -28,7 +28,6 @@ paddle.optimizer
optimizer/ModelAverage.rst
optimizer/Momentum.rst
optimizer/MomentumOptimizer.rst
optimizer/PipelineOptimizer.rst
optimizer/RecomputeOptimizer.rst
optimizer/RMSPropOptimizer.rst
optimizer/SGD.rst
......
.. THIS FILE IS GENERATED BY `gen_doc.{py|sh}`
!DO NOT EDIT THIS FILE MANUALLY!
.. _api_fluid_optimizer_PipelineOptimizer:
PipelineOptimizer
-----------------
.. autoclass:: paddle.fluid.optimizer.PipelineOptimizer
:members:
:inherited-members:
:exclude-members: apply_gradients, apply_optimize, backward, load
:noindex:
......@@ -10,4 +10,3 @@ fluid.transpiler
transpiler/HashName.rst
transpiler/memory_optimize.rst
transpiler/release_memory.rst
transpiler/RoundRobin.rst
.. THIS FILE IS GENERATED BY `gen_doc.{py|sh}`
!DO NOT EDIT THIS FILE MANUALLY!
.. _api_fluid_transpiler_RoundRobin:
RoundRobin
----------
.. autoclass:: paddle.fluid.transpiler.RoundRobin
:members:
:inherited-members:
:noindex:
......@@ -31,7 +31,6 @@ paddle.optimizer
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
......
.. _cn_api_fluid_optimizer_PipelineOptimizer:
PipelineOptimizer
-------------------------------
.. py:class:: paddle.fluid.optimizer.PipelineOptimizer(optimizer, cut_list=None, place_list=None, concurrency_list=None, queue_size=30, sync_steps=1, start_cpu_core_id=0)
:api_attr: 声明式编程模式(静态图)
使用流水线模式进行训练。
Program会根据切分列表cut_list进行分割。如果cut_list的长度是k,则整个program(包括反向部分)将被分割为2*k-1个section。 所以place_list和concurrency_list的长度也必须是2*k-1。
.. note::
虽然我们在流水线训练模式中采用异步更新的方式来加速,但最终的效果会依赖于每条流水线的训练进程。我们将在未来尝试同步模式。
参数:
- **optimizer** (Optimizer) - 基础优化器,如SGD
- **cut_list** (list of Variable list) - main_program的cut变量列表
- **place_list** (list of Place) - 对应section运行所在的place
- **concurrency_list** (list of int) - 指定每个section的并发度列表
- **queue_size** (int) - 每个section都会消费其输入队列(in-scope queue)中的scope,并向输出队列(out-scope queue)产出scope。 此参数的作用就是指定队列的大小。 可选,默认值:30
- **sync_steps** (int) - 不同显卡之间的同步周期数。可选,默认值:1
- **start_cpu_core_id** (int) - 指定所使用的第一个CPU核的id。可选,默认值:0
**代码示例**
.. code-block:: python
import paddle.fluid as fluid
import paddle.fluid.layers as layers
x = fluid.layers.data(name='x', shape=[1], dtype='int64', lod_level=0)
y = fluid.layers.data(name='y', shape=[1], dtype='int64', lod_level=0)
emb_x = layers.embedding(input=x, param_attr=fluid.ParamAttr(name="embx"), size=[10,2], is_sparse=False)
emb_y = layers.embedding(input=y, param_attr=fluid.ParamAttr(name="emby",learning_rate=0.9), size=[10,2], is_sparse=False)
concat = layers.concat([emb_x, emb_y], axis=1)
fc = layers.fc(input=concat, name="fc", size=1, num_flatten_dims=1, bias_attr=False)
loss = layers.reduce_mean(fc)
optimizer = fluid.optimizer.SGD(learning_rate=0.5)
optimizer = fluid.optimizer.PipelineOptimizer(optimizer,
cut_list=[[emb_x, emb_y], [loss]],
place_list=[fluid.CPUPlace(), fluid.CUDAPlace(0), fluid.CPUPlace()],
concurrency_list=[1, 1, 4],
queue_size=2,
sync_steps=1,
)
optimizer.minimize(loss)
place = fluid.CPUPlace()
exe = fluid.Executor(place)
exe.run(fluid.default_startup_program())
filelist = [] # you should set your own filelist, e.g. filelist = ["dataA.txt"]
dataset = fluid.DatasetFactory().create_dataset("FileInstantDataset")
dataset.set_use_var([x,y])
dataset.set_batch_size(batch_size)
dataset.set_filelist(filelist)
exe.train_from_dataset(
fluid.default_main_program(),
dataset,
thread=2,
debug=False,
fetch_list=[],
fetch_info=[],
print_period=1)
......@@ -13,4 +13,3 @@ fluid.transpiler
transpiler_cn/HashName_cn.rst
transpiler_cn/memory_optimize_cn.rst
transpiler_cn/release_memory_cn.rst
transpiler_cn/RoundRobin_cn.rst
.. _cn_api_fluid_transpiler_RoundRobin:
RoundRobin
-------------------------------
.. py:class:: paddle.fluid.transpiler.RoundRobin(pserver_endpoints)
:api_attr: 声明式编程模式(静态图)
该方法使用 ``RoundRobin`` 的方式将变量散列到多个parameter server终端。
`RondRobin <https://en.wikipedia.org/wiki/Round-robin_scheduling>`_
参数:
- **pserver_endpoints** (list) - endpoint (ip:port)的 list
返回:实例化后的RoundRobin的对象
返回类型:RoundRobin
**代码示例**
.. code-block:: python
import paddle.fluid.transpiler.RoundRobin as RoundRobin
pserver_endpoints = [“127.0.0.1:6007”, “127.0.0.1:6008”]
vars = [“var1”,”var2”,”var3”,”var4”,”var5”]
rr = RoundRobin(pserver_endpoints)
rr.dispatch(vars)
.. py:method:: dispatch(varlist)
该方法使用RoundRobin的方式将多个参数散列到多个parameter Server终端。
参数:
- **varlist** (list) - 参数 (var1, var2, var3) 的 list
返回:基于varlist中var的顺序,返回参数服务器(ip:port)的列表, 列表中的数据量和varlist的数据量一致。
返回类型:list
**代码示例**
.. code-block:: python
pserver_endpoints = [“127.0.0.1:6007”, “127.0.0.1:6008”]
vars = [“var1”,”var2”,”var3”,”var4”,”var5”]
rr = RoundRobin(pserver_endpoints)
rr.dispatch(vars)
.. py:method:: reset()
该方法将重置RoundRobin内置的计数, 计数将重置为0。
返回:无。
**代码示例**
.. code-block:: python
pserver_endpoints = [“127.0.0.1:6007”, “127.0.0.1:6008”]
vars = [“var1”,”var2”,”var3”,”var4”,”var5”]
rr = RoundRobin(pserver_endpoints)
rr.reset()
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册