Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleClas
提交
2e62e2e2
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看板
未验证
提交
2e62e2e2
编写于
4月 13, 2021
作者:
L
littletomatodonkey
提交者:
GitHub
4月 13, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix loss reduce from dict to list (#679)
* fix loss reduce from dict to list * remove note
上级
42d2962d
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
24 addition
and
19 deletion
+24
-19
tools/program.py
tools/program.py
+24
-19
未找到文件。
tools/program.py
浏览文件 @
2e62e2e2
...
...
@@ -143,8 +143,8 @@ def create_metric(out,
out
=
out
[
1
]
softmax_out
=
F
.
softmax
(
out
)
fetch
s
=
OrderedDict
()
metric_names
=
set
()
fetch
_list
=
[]
metric_names
=
[]
if
not
multilabel
:
softmax_out
=
F
.
softmax
(
out
)
...
...
@@ -154,12 +154,11 @@ def create_metric(out,
k
=
min
(
topk
,
classes_num
)
topk
=
paddle
.
metric
.
accuracy
(
softmax_out
,
label
=
label
,
k
=
k
)
metric_names
.
a
d
d
(
"top1"
)
metric_names
.
a
d
d
(
"top{}"
.
format
(
k
))
metric_names
.
a
ppen
d
(
"top1"
)
metric_names
.
a
ppen
d
(
"top{}"
.
format
(
k
))
fetchs
[
'top1'
]
=
top1
topk_name
=
"top{}"
.
format
(
k
)
fetchs
[
topk_name
]
=
topk
fetch_list
.
append
(
top1
)
fetch_list
.
append
(
topk
)
else
:
out
=
F
.
sigmoid
(
out
)
preds
=
multi_hot_encode
(
out
.
numpy
())
...
...
@@ -169,19 +168,22 @@ def create_metric(out,
ham_dist_name
=
"hamming_distance"
accuracy_name
=
"multilabel_accuracy"
metric_names
.
a
d
d
(
ham_dist_name
)
metric_names
.
a
d
d
(
accuracy_name
)
metric_names
.
a
ppen
d
(
ham_dist_name
)
metric_names
.
a
ppen
d
(
accuracy_name
)
fetch
s
[
accuracy_name
]
=
accuracy
fetch
s
[
ham_dist_name
]
=
ham_dist
fetch
_list
.
append
(
accuracy
)
fetch
_list
.
append
(
ham_dist
)
# multi cards' eval
if
mode
!=
"train"
and
paddle
.
distributed
.
get_world_size
()
>
1
:
for
metric_name
in
metric_names
:
fetch
s
[
metric_name
]
=
paddle
.
distributed
.
all_reduce
(
fetch
s
[
metric_name
]
,
op
=
paddle
.
distributed
.
ReduceOp
.
for
idx
,
fetch
in
enumerate
(
fetch_list
)
:
fetch
_list
[
idx
]
=
paddle
.
distributed
.
all_reduce
(
fetch
,
op
=
paddle
.
distributed
.
ReduceOp
.
SUM
)
/
paddle
.
distributed
.
get_world_size
()
fetchs
=
OrderedDict
()
for
idx
,
name
in
enumerate
(
metric_names
):
fetchs
[
name
]
=
fetch_list
[
idx
]
return
fetchs
...
...
@@ -282,7 +284,8 @@ def create_feeds(batch, use_mix, num_classes, multilabel=False):
if
not
multilabel
:
label
=
to_tensor
(
batch
[
1
].
numpy
().
astype
(
"int64"
).
reshape
(
-
1
,
1
))
else
:
label
=
to_tensor
(
batch
[
1
].
numpy
().
astype
(
'float32'
).
reshape
(
-
1
,
num_classes
))
label
=
to_tensor
(
batch
[
1
].
numpy
().
astype
(
'float32'
).
reshape
(
-
1
,
num_classes
))
feeds
=
{
"image"
:
image
,
"label"
:
label
}
return
feeds
...
...
@@ -336,10 +339,12 @@ def run(dataloader,
0
,
(
"top1"
,
AverageMeter
(
"top1"
,
'.5f'
,
postfix
=
","
)))
else
:
metric_list
.
insert
(
0
,
(
"multilabel_accuracy"
,
AverageMeter
(
"multilabel_accuracy"
,
'.5f'
,
postfix
=
","
)))
metric_list
.
insert
(
0
,
(
"hamming_distance"
,
AverageMeter
(
"hamming_distance"
,
'.5f'
,
postfix
=
","
)))
metric_list
.
insert
(
0
,
(
"multilabel_accuracy"
,
AverageMeter
(
"multilabel_accuracy"
,
'.5f'
,
postfix
=
","
)))
metric_list
.
insert
(
0
,
(
"hamming_distance"
,
AverageMeter
(
"hamming_distance"
,
'.5f'
,
postfix
=
","
)))
metric_list
=
OrderedDict
(
metric_list
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录