Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleClas
提交
8fd56a45
P
PaddleClas
项目概览
PaddlePaddle
/
PaddleClas
1 年多 前同步成功
通知
115
Star
4999
Fork
1114
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
19
列表
看板
标记
里程碑
合并请求
6
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleClas
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
19
Issue
19
列表
看板
标记
里程碑
合并请求
6
合并请求
6
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
8fd56a45
编写于
12月 15, 2020
作者:
L
littletomatodonkey
提交者:
GitHub
12月 15, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix static train (#478)
上级
29b305d2
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
22 addition
and
15 deletion
+22
-15
tools/static/program.py
tools/static/program.py
+20
-10
tools/static/train.py
tools/static/train.py
+2
-5
未找到文件。
tools/static/program.py
浏览文件 @
8fd56a45
...
...
@@ -86,16 +86,21 @@ def create_model(architecture, image, classes_num, config, is_train):
use_pure_fp16
=
config
.
get
(
"use_pure_fp16"
,
False
)
name
=
architecture
[
"name"
]
params
=
architecture
.
get
(
"params"
,
{})
data_format
=
config
.
get
(
"data_format"
,
"NCHW"
)
data_format
=
"NCHW"
if
"data_format"
in
config
:
params
[
"data_format"
]
=
config
[
"data_format"
]
data_format
=
config
[
"data_format"
]
input_image_channel
=
config
.
get
(
'image_shape'
,
[
3
,
224
,
224
])[
0
]
if
input_image_channel
!=
3
:
logger
.
warning
(
"Input image channel is changed to {}, maybe for better speed-up"
.
format
(
input_image_channel
))
params
[
"input_image_channel"
]
=
input_image_channel
if
"is_test"
in
params
:
params
[
'is_test'
]
=
not
is_train
model
=
architectures
.
__dict__
[
name
](
class_dim
=
classes_num
,
input_image_channel
=
input_image_channel
,
data_format
=
data_format
,
**
params
)
model
=
architectures
.
__dict__
[
name
](
class_dim
=
classes_num
,
**
params
)
if
use_pure_fp16
and
not
config
.
get
(
"use_dali"
,
False
):
image
=
image
.
astype
(
'float16'
)
if
data_format
==
"NHWC"
:
...
...
@@ -352,7 +357,10 @@ def build(config, main_prog, startup_prog, is_train=True, is_distributed=True):
and
config
.
get
(
"use_dali"
,
False
):
image_dtype
=
"float16"
feeds
=
create_feeds
(
config
.
image_shape
,
use_mix
=
use_mix
,
use_dali
=
use_dali
,
dtype
=
image_dtype
)
config
.
image_shape
,
use_mix
=
use_mix
,
use_dali
=
use_dali
,
dtype
=
image_dtype
)
if
use_dali
and
use_mix
:
import
dali
feeds
=
dali
.
mix
(
feeds
,
config
,
is_train
)
...
...
@@ -395,9 +403,11 @@ def compile(config, program, loss_name=None, share_prog=None):
exec_strategy
=
paddle
.
static
.
ExecutionStrategy
()
exec_strategy
.
num_threads
=
1
exec_strategy
.
num_iteration_per_drop_scope
=
10000
if
config
.
get
(
'use_pure_fp16'
,
False
)
else
10
exec_strategy
.
num_iteration_per_drop_scope
=
10000
if
config
.
get
(
'use_pure_fp16'
,
False
)
else
10
fuse_op
=
config
.
get
(
'use_amp'
,
False
)
or
config
.
get
(
'use_pure_fp16'
,
False
)
fuse_op
=
config
.
get
(
'use_amp'
,
False
)
or
config
.
get
(
'use_pure_fp16'
,
False
)
fuse_bn_act_ops
=
config
.
get
(
'fuse_bn_act_ops'
,
fuse_op
)
fuse_elewise_add_act_ops
=
config
.
get
(
'fuse_elewise_add_act_ops'
,
fuse_op
)
fuse_bn_add_act_ops
=
config
.
get
(
'fuse_bn_add_act_ops'
,
fuse_op
)
...
...
tools/static/train.py
浏览文件 @
8fd56a45
...
...
@@ -65,10 +65,7 @@ def main(args):
if
config
.
get
(
"is_distributed"
,
True
):
fleet
.
init
(
is_collective
=
True
)
# assign the place
use_gpu
=
config
.
get
(
"use_gpu"
,
False
)
assert
use_gpu
is
True
,
"gpu must be true in static mode!"
place
=
paddle
.
set_device
(
"gpu"
)
use_gpu
=
config
.
get
(
"use_gpu"
,
True
)
# amp related config
use_amp
=
config
.
get
(
'use_amp'
,
False
)
use_pure_fp16
=
config
.
get
(
'use_pure_fp16'
,
False
)
...
...
@@ -122,7 +119,7 @@ def main(args):
exe
=
paddle
.
static
.
Executor
(
place
)
# Parameter initialization
exe
.
run
(
startup_prog
)
if
config
.
get
(
"use_pure_fp16"
,
False
):
if
config
.
get
(
"use_pure_fp16"
,
False
):
cast_parameters_to_fp16
(
place
,
train_prog
,
fluid
.
global_scope
())
# load pretrained models or checkpoints
init_model
(
config
,
train_prog
,
exe
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录