Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
models
提交
f1e327e0
M
models
项目概览
PaddlePaddle
/
models
大约 1 年 前同步成功
通知
222
Star
6828
Fork
2962
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
602
列表
看板
标记
里程碑
合并请求
255
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
models
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
602
Issue
602
列表
看板
标记
里程碑
合并请求
255
合并请求
255
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
f1e327e0
编写于
1月 24, 2019
作者:
T
typhoonzero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add reader dist global shuffle
上级
2de73266
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
11 addition
and
5 deletion
+11
-5
fluid/PaddleCV/image_classification/dist_train/dist_train.py
fluid/PaddleCV/image_classification/dist_train/dist_train.py
+4
-2
fluid/PaddleCV/image_classification/reader.py
fluid/PaddleCV/image_classification/reader.py
+7
-3
未找到文件。
fluid/PaddleCV/image_classification/dist_train/dist_train.py
浏览文件 @
f1e327e0
...
...
@@ -80,9 +80,9 @@ def get_device_num():
device_num
=
subprocess
.
check_output
([
'nvidia-smi'
,
'-L'
]).
decode
().
count
(
'
\n
'
)
return
device_num
def
prepare_reader
(
is_train
,
pyreader
,
args
):
def
prepare_reader
(
is_train
,
pyreader
,
args
,
pass_id
=
0
):
if
is_train
:
reader
=
train
(
data_dir
=
args
.
data_dir
)
reader
=
train
(
data_dir
=
args
.
data_dir
,
pass_id_as_seed
=
pass_id
)
else
:
reader
=
val
(
data_dir
=
args
.
data_dir
)
if
is_train
:
...
...
@@ -262,6 +262,8 @@ def train_parallel(args):
num_samples
=
0
start_time
=
time
.
time
()
batch_id
=
1
# use pass_id+1 as per pass global shuffle for distributed training
prepare_reader
(
True
,
train_pyreader
,
args
,
pass_id
+
1
)
train_pyreader
.
start
()
while
True
:
try
:
...
...
fluid/PaddleCV/image_classification/reader.py
浏览文件 @
f1e327e0
...
...
@@ -130,11 +130,14 @@ def _reader_creator(file_list,
shuffle
=
False
,
color_jitter
=
False
,
rotate
=
False
,
data_dir
=
DATA_DIR
):
data_dir
=
DATA_DIR
,
pass_id_as_seed
=
0
):
def
reader
():
with
open
(
file_list
)
as
flist
:
full_lines
=
[
line
.
strip
()
for
line
in
flist
]
if
shuffle
:
if
pass_id_as_seed
:
np
.
random
.
seed
(
pass_id_as_seed
)
np
.
random
.
shuffle
(
full_lines
)
if
mode
==
'train'
and
os
.
getenv
(
'PADDLE_TRAINING_ROLE'
):
# distributed mode if the env var `PADDLE_TRAINING_ROLE` exits
...
...
@@ -166,7 +169,7 @@ def _reader_creator(file_list,
return
paddle
.
reader
.
xmap_readers
(
mapper
,
reader
,
THREAD
,
BUF_SIZE
)
def
train
(
data_dir
=
DATA_DIR
):
def
train
(
data_dir
=
DATA_DIR
,
pass_id_as_seed
=
0
):
file_list
=
os
.
path
.
join
(
data_dir
,
'train_list.txt'
)
return
_reader_creator
(
file_list
,
...
...
@@ -174,7 +177,8 @@ def train(data_dir=DATA_DIR):
shuffle
=
True
,
color_jitter
=
False
,
rotate
=
False
,
data_dir
=
data_dir
)
data_dir
=
data_dir
,
pass_id_as_seed
=
pass_id_as_seed
)
def
val
(
data_dir
=
DATA_DIR
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录