Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleClas
提交
e6feb68b
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看板
未验证
提交
e6feb68b
编写于
4月 20, 2022
作者:
W
Wei Shengyu
提交者:
GitHub
4月 20, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1824 from TingquanGao/dev/spt_amp_eval
fix: fp32 eval by default when enable amp
上级
43a03a0c
83ed5195
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
23 addition
and
7 deletion
+23
-7
ppcls/configs/ImageNet/SENet/SE_ResNeXt101_32x4d_amp_O2_ultra.yaml
...figs/ImageNet/SENet/SE_ResNeXt101_32x4d_amp_O2_ultra.yaml
+4
-4
ppcls/engine/evaluation/classification.py
ppcls/engine/evaluation/classification.py
+9
-2
ppcls/static/train.py
ppcls/static/train.py
+10
-1
未找到文件。
ppcls/configs/ImageNet/SENet/SE_ResNeXt101_32x4d_amp_O2_ultra.yaml
浏览文件 @
e6feb68b
...
...
@@ -34,10 +34,10 @@ Loss:
# mixed precision training
AMP
:
scale_loss
:
128.0
use_dynamic_loss_scaling
:
True
# O2: pure fp16
level
:
O2
scale_loss
:
128.0
use_dynamic_loss_scaling
:
True
# O2: pure fp16
level
:
O2
Optimizer
:
name
:
Momentum
...
...
ppcls/engine/evaluation/classification.py
浏览文件 @
e6feb68b
...
...
@@ -53,13 +53,20 @@ def classification_eval(engine, epoch_id=0):
]
time_info
[
"reader_cost"
].
update
(
time
.
time
()
-
tic
)
batch_size
=
batch
[
0
].
shape
[
0
]
batch
[
0
]
=
paddle
.
to_tensor
(
batch
[
0
])
.
astype
(
"float32"
)
batch
[
0
]
=
paddle
.
to_tensor
(
batch
[
0
])
if
not
engine
.
config
[
"Global"
].
get
(
"use_multilabel"
,
False
):
batch
[
1
]
=
batch
[
1
].
reshape
([
-
1
,
1
]).
astype
(
"int64"
)
# image input
if
engine
.
amp
and
engine
.
config
[
"AMP"
].
get
(
"use_fp16_test"
,
False
):
if
engine
.
amp
and
(
engine
.
config
[
'AMP'
].
get
(
"level"
,
"O1"
).
upper
()
==
"O2"
or
engine
.
config
[
"AMP"
].
get
(
"use_fp16_test"
,
False
)):
amp_level
=
engine
.
config
[
'AMP'
].
get
(
"level"
,
"O1"
).
upper
()
if
amp_level
==
"O2"
:
msg
=
"Only support FP16 evaluation when AMP O2 is enabled."
logger
.
warning
(
msg
)
with
paddle
.
amp
.
auto_cast
(
custom_black_list
=
{
"flatten_contiguous_range"
,
"greater_than"
...
...
ppcls/static/train.py
浏览文件 @
e6feb68b
...
...
@@ -162,12 +162,21 @@ def main(args):
init_model
(
global_config
,
train_prog
,
exe
)
if
'AMP'
in
config
:
if
config
[
"AMP"
].
get
(
"level"
,
"O1"
).
upper
()
==
"O2"
:
use_fp16_test
=
True
msg
=
"Only support FP16 evaluation when AMP O2 is enabled."
logger
.
warning
(
msg
)
elif
"use_fp16_test"
in
config
[
"AMP"
]:
use_fp16_test
=
config
[
"AMP"
].
get
[
"use_fp16_test"
]
else
:
use_fp16_test
=
False
optimizer
.
amp_init
(
device
,
scope
=
paddle
.
static
.
global_scope
(),
test_program
=
eval_prog
if
global_config
[
"eval_during_train"
]
else
None
,
use_fp16_test
=
config
[
"AMP"
].
get
(
"use_fp16_test"
,
False
)
)
use_fp16_test
=
use_fp16_test
)
if
not
global_config
.
get
(
"is_distributed"
,
True
):
compiled_train_prog
=
program
.
compile
(
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录