Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
a742bb0f
P
Paddle
项目概览
BaiXuePrincess
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
a742bb0f
编写于
4月 16, 2019
作者:
G
guru4elephant
提交者:
xjqbest
4月 16, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Merge pull request #16746 from xjqbest/dataset_merge_develop
move split filelist from trainer.py to fleet & fix error
上级
1237dfa6
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
57 addition
and
1 deletion
+57
-1
python/paddle/fluid/dataset.py
python/paddle/fluid/dataset.py
+21
-0
python/paddle/fluid/incubate/fleet/base/role_maker.py
python/paddle/fluid/incubate/fleet/base/role_maker.py
+1
-1
python/paddle/fluid/incubate/fleet/parameter_server/__init__.py
.../paddle/fluid/incubate/fleet/parameter_server/__init__.py
+35
-0
未找到文件。
python/paddle/fluid/dataset.py
浏览文件 @
a742bb0f
...
@@ -213,6 +213,7 @@ class InMemoryDataset(DatasetBase):
...
@@ -213,6 +213,7 @@ class InMemoryDataset(DatasetBase):
>>> dataset = fluid.DatasetFactory.create_dataset("InMemoryDataset")
>>> dataset = fluid.DatasetFactory.create_dataset("InMemoryDataset")
>>> filelist = ["a.txt", "b.txt"]
>>> filelist = ["a.txt", "b.txt"]
>>> dataset.set_filelist(filelist)
>>> dataset.set_filelist(filelist)
>>> dataset.load_into_memory()
>>> dataset.local_shuffle()
>>> dataset.local_shuffle()
"""
"""
self
.
dataset
.
local_shuffle
()
self
.
dataset
.
local_shuffle
()
...
@@ -230,6 +231,7 @@ class InMemoryDataset(DatasetBase):
...
@@ -230,6 +231,7 @@ class InMemoryDataset(DatasetBase):
>>> dataset = fluid.DatasetFactory.create_dataset("InMemoryDataset")
>>> dataset = fluid.DatasetFactory.create_dataset("InMemoryDataset")
>>> filelist = ["a.txt", "b.txt"]
>>> filelist = ["a.txt", "b.txt"]
>>> dataset.set_filelist(filelist)
>>> dataset.set_filelist(filelist)
>>> dataset.load_into_memory()
>>> dataset.global_shuffle(fleet)
>>> dataset.global_shuffle(fleet)
Args:
Args:
...
@@ -247,6 +249,25 @@ class InMemoryDataset(DatasetBase):
...
@@ -247,6 +249,25 @@ class InMemoryDataset(DatasetBase):
if
fleet
is
not
None
:
if
fleet
is
not
None
:
fleet
.
fleet_instance
.
role_maker_
.
_barrier_worker
()
fleet
.
fleet_instance
.
role_maker_
.
_barrier_worker
()
def
release_memory
(
self
):
"""
Release InMemoryDataset memory data, when data will not be used again.
Example:
>>> import paddle.fluid as fluid
>>> import paddle.fluid.incubate.fleet.parameter_server as fleet
>>> dataset = fluid.DatasetFactory.create_dataset("InMemoryDataset")
>>> filelist = ["a.txt", "b.txt"]
>>> dataset.set_filelist(filelist)
>>> dataset.load_into_memory()
>>> dataset.global_shuffle(fleet)
>>> exe = fluid.Executor(fluid.CPUPlace())
>>> exe.run(fluid.default_startup_program())
>>> exe.train_from_dataset(fluid.default_main_program(), dataset)
>>> dataset.release_memory()
"""
self
.
dataset
.
release_memory
()
class
QueueDataset
(
DatasetBase
):
class
QueueDataset
(
DatasetBase
):
"""
"""
...
...
python/paddle/fluid/incubate/fleet/base/role_maker.py
浏览文件 @
a742bb0f
...
@@ -128,7 +128,7 @@ class MPIRoleMaker(RoleMakerBase):
...
@@ -128,7 +128,7 @@ class MPIRoleMaker(RoleMakerBase):
"""
"""
finalize the current MPI instance.
finalize the current MPI instance.
"""
"""
self
.
comm_
.
finalize
()
pass
class
MPISymetricRoleMaker
(
MPIRoleMaker
):
class
MPISymetricRoleMaker
(
MPIRoleMaker
):
...
...
python/paddle/fluid/incubate/fleet/parameter_server/__init__.py
浏览文件 @
a742bb0f
...
@@ -228,6 +228,40 @@ class Fleet(object):
...
@@ -228,6 +228,40 @@ class Fleet(object):
"""
"""
self
.
_fleet_ptr
.
save_model
(
save_path
)
self
.
_fleet_ptr
.
save_model
(
save_path
)
def
split_filelist
(
self
,
filelist
):
"""
split filelist before distributed training,
for example, filelist is [a, b, c ,d, e] and trainer_num = 2,
then trainer 0 gets [a, b, c] and trainer 1 gets [d, e]
Example:
>>> all_filelist = ["a.txt", "b.txt", "c.txt"]
>>> my_filelist = fleet.split_filelist(all_filelist)
>>> dataset = fluid.DatasetFactory().create_dataset()
>>> dataset.set_filelist(my_filelist)
Args:
filelist(list): list of filename, can be local or hdfs/afs.
Returns:
list of filename which belongs to this trainer.
"""
file_num
=
len
(
filelist
)
trainer_id
=
self
.
get_worker_index
()
trainer_num
=
self
.
get_worker_num
()
if
trainer_num
>
file_num
:
raise
ValueError
(
"trainer_num should be <= file_num : "
"%s > %s"
%
(
trainer_num
,
file_num
))
# get interval of filelist, it's [ )
start
=
0
end
=
0
for
i
in
range
(
0
,
trainer_id
+
1
):
length
=
file_num
/
trainer_num
+
(
i
<
(
file_num
%
trainer_num
))
start
=
end
end
+=
length
my_filelist
=
filelist
[
start
:
end
]
return
my_filelist
def
_set_opt_info
(
self
,
opt_info
):
def
_set_opt_info
(
self
,
opt_info
):
"""
"""
this function saves the result from DistributedOptimizer.minimize()
this function saves the result from DistributedOptimizer.minimize()
...
@@ -324,3 +358,4 @@ save_pserver_model = fleet_instance.save_pserver_model
...
@@ -324,3 +358,4 @@ save_pserver_model = fleet_instance.save_pserver_model
worker_num
=
fleet_instance
.
get_worker_num
worker_num
=
fleet_instance
.
get_worker_num
server_num
=
fleet_instance
.
get_server_num
server_num
=
fleet_instance
.
get_server_num
worker_index
=
fleet_instance
.
get_worker_index
worker_index
=
fleet_instance
.
get_worker_index
split_filelist
=
fleet_instance
.
split_filelist
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录