Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleClas
提交
edf1129e
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看板
提交
edf1129e
编写于
5月 23, 2022
作者:
Z
zhiboniu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
match new eval function
上级
699c10aa
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
12 addition
and
9 deletion
+12
-9
ppcls/configs/Attr/StrongBaselineAttr.yaml
ppcls/configs/Attr/StrongBaselineAttr.yaml
+1
-1
ppcls/engine/evaluation/classification.py
ppcls/engine/evaluation/classification.py
+3
-7
ppcls/metric/__init__.py
ppcls/metric/__init__.py
+3
-0
ppcls/metric/metrics.py
ppcls/metric/metrics.py
+5
-1
未找到文件。
ppcls/configs/Attr/StrongBaselineAttr.yaml
浏览文件 @
edf1129e
...
@@ -5,7 +5,7 @@ Global:
...
@@ -5,7 +5,7 @@ Global:
output_dir
:
"
./output/"
output_dir
:
"
./output/"
device
:
"
gpu"
device
:
"
gpu"
save_interval
:
5
save_interval
:
5
eval_during_train
:
Fals
e
eval_during_train
:
Tru
e
eval_interval
:
1
eval_interval
:
1
epochs
:
30
epochs
:
30
print_batch_step
:
20
print_batch_step
:
20
...
...
ppcls/engine/evaluation/classification.py
浏览文件 @
edf1129e
...
@@ -18,7 +18,7 @@ import time
...
@@ -18,7 +18,7 @@ import time
import
platform
import
platform
import
paddle
import
paddle
from
ppcls.utils.misc
import
AverageMeter
,
AttrMeter
from
ppcls.utils.misc
import
AverageMeter
from
ppcls.utils
import
logger
from
ppcls.utils
import
logger
...
@@ -34,10 +34,6 @@ def classification_eval(engine, epoch_id=0):
...
@@ -34,10 +34,6 @@ def classification_eval(engine, epoch_id=0):
}
}
print_batch_step
=
engine
.
config
[
"Global"
][
"print_batch_step"
]
print_batch_step
=
engine
.
config
[
"Global"
][
"print_batch_step"
]
if
engine
.
eval_metric_func
is
not
None
and
"ATTRMetric"
in
engine
.
config
[
"Metric"
][
"Eval"
][
0
]:
output_info
[
"attr"
]
=
AttrMeter
(
threshold
=
0.5
)
metric_key
=
None
metric_key
=
None
tic
=
time
.
time
()
tic
=
time
.
time
()
accum_samples
=
0
accum_samples
=
0
...
@@ -162,7 +158,7 @@ def classification_eval(engine, epoch_id=0):
...
@@ -162,7 +158,7 @@ def classification_eval(engine, epoch_id=0):
if
"ATTRMetric"
in
engine
.
config
[
"Metric"
][
"Eval"
][
0
]:
if
"ATTRMetric"
in
engine
.
config
[
"Metric"
][
"Eval"
][
0
]:
metric_msg
=
", "
.
join
([
metric_msg
=
", "
.
join
([
"evalres: ma: {:.5f} label_f1: {:.5f} label_pos_recall: {:.5f} label_neg_recall: {:.5f} instance_f1: {:.5f} instance_acc: {:.5f} instance_prec: {:.5f} instance_recall: {:.5f}"
.
"evalres: ma: {:.5f} label_f1: {:.5f} label_pos_recall: {:.5f} label_neg_recall: {:.5f} instance_f1: {:.5f} instance_acc: {:.5f} instance_prec: {:.5f} instance_recall: {:.5f}"
.
format
(
*
output_info
[
"attr"
].
res
())
format
(
*
engine
.
eval_metric_func
.
attr_
res
())
])
])
logger
.
info
(
"[Eval][Epoch {}][Avg]{}"
.
format
(
epoch_id
,
metric_msg
))
logger
.
info
(
"[Eval][Epoch {}][Avg]{}"
.
format
(
epoch_id
,
metric_msg
))
...
@@ -170,7 +166,7 @@ def classification_eval(engine, epoch_id=0):
...
@@ -170,7 +166,7 @@ def classification_eval(engine, epoch_id=0):
if
engine
.
eval_metric_func
is
None
:
if
engine
.
eval_metric_func
is
None
:
return
-
1
return
-
1
# return 1st metric in the dict
# return 1st metric in the dict
return
output_info
[
"attr"
].
res
()[
0
]
return
engine
.
eval_metric_func
.
attr_
res
()[
0
]
else
:
else
:
metric_msg
=
", "
.
join
([
metric_msg
=
", "
.
join
([
"{}: {:.5f}"
.
format
(
key
,
output_info
[
key
].
avg
)
"{}: {:.5f}"
.
format
(
key
,
output_info
[
key
].
avg
)
...
...
ppcls/metric/__init__.py
浏览文件 @
edf1129e
...
@@ -56,6 +56,9 @@ class CombinedMetrics(AvgMetrics):
...
@@ -56,6 +56,9 @@ class CombinedMetrics(AvgMetrics):
def
avg
(
self
):
def
avg
(
self
):
return
self
.
metric_func_list
[
0
].
avg
return
self
.
metric_func_list
[
0
].
avg
def
attr_res
(
self
):
return
self
.
metric_func_list
[
0
].
attrmeter
.
res
()
def
reset
(
self
):
def
reset
(
self
):
for
metric
in
self
.
metric_func_list
:
for
metric
in
self
.
metric_func_list
:
if
hasattr
(
metric
,
"reset"
):
if
hasattr
(
metric
,
"reset"
):
...
...
ppcls/metric/metrics.py
浏览文件 @
edf1129e
...
@@ -25,7 +25,7 @@ from sklearn.preprocessing import binarize
...
@@ -25,7 +25,7 @@ from sklearn.preprocessing import binarize
from
easydict
import
EasyDict
from
easydict
import
EasyDict
from
ppcls.metric.avg_metrics
import
AvgMetrics
from
ppcls.metric.avg_metrics
import
AvgMetrics
from
ppcls.utils.misc
import
AverageMeter
from
ppcls.utils.misc
import
AverageMeter
,
AttrMeter
class
TopkAcc
(
AvgMetrics
):
class
TopkAcc
(
AvgMetrics
):
...
@@ -438,7 +438,11 @@ class ATTRMetric(nn.Layer):
...
@@ -438,7 +438,11 @@ class ATTRMetric(nn.Layer):
super
().
__init__
()
super
().
__init__
()
self
.
threshold
=
threshold
self
.
threshold
=
threshold
def
reset
(
self
):
self
.
attrmeter
=
AttrMeter
(
threshold
=
0.5
)
def
forward
(
self
,
output
,
target
):
def
forward
(
self
,
output
,
target
):
metric_dict
=
get_attr_metrics
(
target
[:,
0
,
:].
numpy
(),
metric_dict
=
get_attr_metrics
(
target
[:,
0
,
:].
numpy
(),
output
.
numpy
(),
self
.
threshold
)
output
.
numpy
(),
self
.
threshold
)
self
.
attrmeter
.
update
(
metric_dict
)
return
metric_dict
return
metric_dict
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录