Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleClas
提交
cd039a7b
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看板
提交
cd039a7b
编写于
1月 10, 2022
作者:
Z
zhangbo9674
提交者:
Tingquan Gao
1月 10, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add save_dtype
上级
d437bb0a
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
1 addition
and
36 deletion
+1
-36
ppcls/engine/engine.py
ppcls/engine/engine.py
+1
-1
ppcls/engine/evaluation/classification.py
ppcls/engine/evaluation/classification.py
+0
-35
未找到文件。
ppcls/engine/engine.py
浏览文件 @
cd039a7b
...
...
@@ -218,7 +218,7 @@ class Engine(object):
init_loss_scaling
=
self
.
scale_loss
,
use_dynamic_loss_scaling
=
self
.
use_dynamic_loss_scaling
)
if
self
.
config
[
'AMP'
][
'use_pure_fp16'
]
is
True
:
self
.
model
=
paddle
.
amp
.
decorate
(
models
=
self
.
model
,
level
=
'O2'
)
self
.
model
=
paddle
.
amp
.
decorate
(
models
=
self
.
model
,
level
=
'O2'
,
save_dtype
=
'float32'
)
# for distributed
self
.
config
[
"Global"
][
...
...
ppcls/engine/evaluation/classification.py
浏览文件 @
cd039a7b
...
...
@@ -40,17 +40,6 @@ def classification_eval(engine, epoch_id=0):
dataset
)
if
not
engine
.
use_dali
else
engine
.
eval_dataloader
.
size
max_iter
=
len
(
engine
.
eval_dataloader
)
-
1
if
platform
.
system
(
)
==
"Windows"
else
len
(
engine
.
eval_dataloader
)
# print("========================fp16 layer")
# for layer in engine.model.sublayers(include_self=True):
# print(type(layer), layer._dtype)
# 用fp32做eval
engine
.
model
.
to
(
dtype
=
'float32'
)
# print("========================to fp32 layer")
# for layer in engine.model.sublayers(include_self=True):
# print(type(layer), layer._dtype)
for
iter_id
,
batch
in
enumerate
(
engine
.
eval_dataloader
):
if
iter_id
>=
max_iter
:
break
...
...
@@ -68,7 +57,6 @@ def classification_eval(engine, epoch_id=0):
if
not
engine
.
config
[
"Global"
].
get
(
"use_multilabel"
,
False
):
batch
[
1
]
=
batch
[
1
].
reshape
([
-
1
,
1
]).
astype
(
"int64"
)
'''
# image input
if
engine
.
amp
:
amp_level
=
'O1'
...
...
@@ -92,19 +80,6 @@ def classification_eval(engine, epoch_id=0):
if
key
not
in
output_info
:
output_info
[
key
]
=
AverageMeter
(
key
,
'7.5f'
)
output_info
[
key
].
update
(
loss_dict
[
key
].
numpy
()[
0
],
batch_size
)
'''
#========================================================
out
=
engine
.
model
(
batch
[
0
])
# calc loss
if
engine
.
eval_loss_func
is
not
None
:
loss_dict
=
engine
.
eval_loss_func
(
out
,
batch
[
1
])
for
key
in
loss_dict
:
if
key
not
in
output_info
:
output_info
[
key
]
=
AverageMeter
(
key
,
'7.5f'
)
output_info
[
key
].
update
(
loss_dict
[
key
].
numpy
()[
0
],
batch_size
)
#========================================================
# just for DistributedBatchSampler issue: repeat sampling
current_samples
=
batch_size
*
paddle
.
distributed
.
get_world_size
()
...
...
@@ -176,16 +151,6 @@ def classification_eval(engine, epoch_id=0):
len
(
engine
.
eval_dataloader
),
metric_msg
,
time_msg
,
ips_msg
))
tic
=
time
.
time
()
#如果是amp-o2做eval后再将模型转回amp-o2的模式
if
engine
.
amp
:
if
engine
.
config
[
'AMP'
][
'use_pure_fp16'
]
is
True
:
paddle
.
fluid
.
dygraph
.
amp
.
auto_cast
.
pure_fp16_initialize
([
engine
.
model
])
# print("========================to fp16 layer")
# for layer in engine.model.sublayers(include_self=True):
# print(type(layer), layer._dtype)
# import sys
# sys.exit()
if
engine
.
use_dali
:
engine
.
eval_dataloader
.
reset
()
metric_msg
=
", "
.
join
([
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录