Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
models
提交
d251bf70
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看板
提交
d251bf70
编写于
9月 11, 2020
作者:
Z
zhiqiu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
enable addto with amp
上级
a00c8afb
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
18 addition
and
3 deletion
+18
-3
PaddleCV/image_classification/scripts/train/ResNet50_fp16.sh
PaddleCV/image_classification/scripts/train/ResNet50_fp16.sh
+5
-2
PaddleCV/image_classification/train.py
PaddleCV/image_classification/train.py
+9
-1
PaddleCV/image_classification/utils/utility.py
PaddleCV/image_classification/utils/utility.py
+4
-0
未找到文件。
PaddleCV/image_classification/scripts/train/ResNet50_fp16.sh
浏览文件 @
d251bf70
...
...
@@ -3,8 +3,9 @@
export
FLAGS_conv_workspace_size_limit
=
4000
#MB
export
FLAGS_cudnn_exhaustive_search
=
1
export
FLAGS_cudnn_batchnorm_spatial_persistent
=
1
export
FLAGS_max_inplace_grad_add
=
8
DATA_DIR
=
"
Your image dataset path, e.g. /work/datasets
/ILSVRC2012/"
DATA_DIR
=
"
./data
/ILSVRC2012/"
DATA_FORMAT
=
"NHWC"
USE_FP16
=
true
#whether to use float16
...
...
@@ -17,7 +18,7 @@ fi
python train.py
\
--model
=
ResNet50
\
--data_dir
=
${
DATA_DIR
}
\
--batch_size
=
256
\
--batch_size
=
128
\
--total_images
=
1281167
\
--image_shape
3 224 224
\
--class_dim
=
1000
\
...
...
@@ -36,5 +37,7 @@ python train.py \
--reader_thread
=
10
\
--reader_buf_size
=
4000
\
--use_dali
=
${
USE_DALI
}
\
--fuse_all_optimizer_ops
=
true
\
--enable_addto
=
true
\
--lr
=
0.1
PaddleCV/image_classification/train.py
浏览文件 @
d251bf70
...
...
@@ -244,8 +244,16 @@ def train(args):
t1
=
time
.
time
()
for
batch
in
train_iter
:
#NOTE: this is for benchmark
if
args
.
max_iter
and
total_batch_num
==
args
.
max_iter
:
if
total_batch_num
==
200
:
#if args.max_iter and total_batch_num == args.max_iter:
print
(
"="
*
20
)
print
(
"total_batch_num: "
,
total_batch_num
,
"records_num: "
,
len
(
train_batch_time_record
))
avg_times
=
sum
(
train_batch_time_record
[
-
150
:])
/
150
avg_speed
=
args
.
batch_size
/
avg_times
print
(
"average time: %.5f s/batch, average speed: %.5f imgs/s"
%
(
avg_times
,
avg_speed
))
return
#if args.max_iter and total_batch_num == args.max_iter:
# return
train_batch_metrics
=
exe
.
run
(
compiled_train_prog
,
feed
=
batch
,
fetch_list
=
train_fetch_list
)
...
...
PaddleCV/image_classification/utils/utility.py
浏览文件 @
d251bf70
...
...
@@ -162,6 +162,8 @@ def parse_args():
add_arg
(
'profiler_path'
,
str
,
'./profilier_files'
,
"the profiler output file path"
)
add_arg
(
'max_iter'
,
int
,
0
,
"the max train batch num"
)
add_arg
(
'same_feed'
,
int
,
0
,
"whether to feed same images"
)
add_arg
(
'enable_addto'
,
bool
,
False
,
"whether to enable the addto strategy for gradient accumulation"
)
add_arg
(
'fuse_all_optimizer_ops'
,
bool
,
False
,
"whether to fuse all optimizer operators"
)
# yapf: enable
...
...
@@ -524,6 +526,8 @@ def best_strategy_compiled(args,
try
:
fluid
.
require_version
(
min_version
=
'1.7.0'
)
build_strategy
.
fuse_bn_act_ops
=
args
.
fuse_bn_act_ops
build_strategy
.
fuse_all_optimizer_ops
=
args
.
fuse_all_optimizer_ops
build_strategy
.
enable_addto
=
args
.
enable_addto
except
Exception
as
e
:
logger
.
info
(
"PaddlePaddle version 1.7.0 or higher is "
"required when you want to fuse batch_norm and activation_op."
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录