Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleClas
提交
9984080a
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看板
提交
9984080a
编写于
8月 10, 2023
作者:
H
HydrogenSulfate
提交者:
Tingquan Gao
8月 10, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
change *.numpy()[0] to float(*) for correct usage of 0-D tensor
上级
e877e6a9
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
16 addition
and
20 deletion
+16
-20
ppcls/arch/backbone/model_zoo/gvt.py
ppcls/arch/backbone/model_zoo/gvt.py
+2
-4
ppcls/engine/evaluation/classification.py
ppcls/engine/evaluation/classification.py
+1
-2
ppcls/engine/train/utils.py
ppcls/engine/train/utils.py
+7
-8
ppcls/metric/metrics.py
ppcls/metric/metrics.py
+5
-5
ppcls/utils/misc.py
ppcls/utils/misc.py
+1
-1
未找到文件。
ppcls/arch/backbone/model_zoo/gvt.py
浏览文件 @
9984080a
...
@@ -324,8 +324,7 @@ class PyramidVisionTransformer(nn.Layer):
...
@@ -324,8 +324,7 @@ class PyramidVisionTransformer(nn.Layer):
self
.
pos_drops
.
append
(
nn
.
Dropout
(
p
=
drop_rate
))
self
.
pos_drops
.
append
(
nn
.
Dropout
(
p
=
drop_rate
))
dpr
=
[
dpr
=
[
x
.
numpy
()[
0
]
float
(
x
)
for
x
in
paddle
.
linspace
(
0
,
drop_path_rate
,
sum
(
depths
))
for
x
in
paddle
.
linspace
(
0
,
drop_path_rate
,
sum
(
depths
))
]
# stochastic depth decay rule
]
# stochastic depth decay rule
cur
=
0
cur
=
0
...
@@ -551,8 +550,7 @@ class ALTGVT(PCPVT):
...
@@ -551,8 +550,7 @@ class ALTGVT(PCPVT):
self
.
wss
=
wss
self
.
wss
=
wss
# transformer encoder
# transformer encoder
dpr
=
[
dpr
=
[
x
.
numpy
()[
0
]
float
(
x
)
for
x
in
paddle
.
linspace
(
0
,
drop_path_rate
,
sum
(
depths
))
for
x
in
paddle
.
linspace
(
0
,
drop_path_rate
,
sum
(
depths
))
]
# stochastic depth decay rule
]
# stochastic depth decay rule
cur
=
0
cur
=
0
self
.
blocks
=
nn
.
LayerList
()
self
.
blocks
=
nn
.
LayerList
()
...
...
ppcls/engine/evaluation/classification.py
浏览文件 @
9984080a
...
@@ -130,8 +130,7 @@ def classification_eval(engine, epoch_id=0):
...
@@ -130,8 +130,7 @@ def classification_eval(engine, epoch_id=0):
for
key
in
loss_dict
:
for
key
in
loss_dict
:
if
key
not
in
output_info
:
if
key
not
in
output_info
:
output_info
[
key
]
=
AverageMeter
(
key
,
'7.5f'
)
output_info
[
key
]
=
AverageMeter
(
key
,
'7.5f'
)
output_info
[
key
].
update
(
loss_dict
[
key
].
numpy
()[
0
],
output_info
[
key
].
update
(
float
(
loss_dict
[
key
]),
current_samples
)
current_samples
)
# calc metric
# calc metric
if
engine
.
eval_metric_func
is
not
None
:
if
engine
.
eval_metric_func
is
not
None
:
...
...
ppcls/engine/train/utils.py
浏览文件 @
9984080a
...
@@ -25,8 +25,8 @@ def update_metric(trainer, out, batch, batch_size):
...
@@ -25,8 +25,8 @@ def update_metric(trainer, out, batch, batch_size):
for
key
in
metric_dict
:
for
key
in
metric_dict
:
if
key
not
in
trainer
.
output_info
:
if
key
not
in
trainer
.
output_info
:
trainer
.
output_info
[
key
]
=
AverageMeter
(
key
,
'7.5f'
)
trainer
.
output_info
[
key
]
=
AverageMeter
(
key
,
'7.5f'
)
trainer
.
output_info
[
key
].
update
(
metric_dict
[
key
].
numpy
()[
0
],
trainer
.
output_info
[
key
].
update
(
batch_size
)
float
(
metric_dict
[
key
]),
batch_size
)
def
update_loss
(
trainer
,
loss_dict
,
batch_size
):
def
update_loss
(
trainer
,
loss_dict
,
batch_size
):
...
@@ -34,7 +34,7 @@ def update_loss(trainer, loss_dict, batch_size):
...
@@ -34,7 +34,7 @@ def update_loss(trainer, loss_dict, batch_size):
for
key
in
loss_dict
:
for
key
in
loss_dict
:
if
key
not
in
trainer
.
output_info
:
if
key
not
in
trainer
.
output_info
:
trainer
.
output_info
[
key
]
=
AverageMeter
(
key
,
'7.5f'
)
trainer
.
output_info
[
key
]
=
AverageMeter
(
key
,
'7.5f'
)
trainer
.
output_info
[
key
].
update
(
loss_dict
[
key
].
numpy
()[
0
]
,
batch_size
)
trainer
.
output_info
[
key
].
update
(
float
(
loss_dict
[
key
])
,
batch_size
)
def
log_info
(
trainer
,
batch_size
,
epoch_id
,
iter_id
):
def
log_info
(
trainer
,
batch_size
,
epoch_id
,
iter_id
):
...
@@ -53,14 +53,13 @@ def log_info(trainer, batch_size, epoch_id, iter_id):
...
@@ -53,14 +53,13 @@ def log_info(trainer, batch_size, epoch_id, iter_id):
ips_msg
=
"ips: {:.5f} samples/s"
.
format
(
ips_msg
=
"ips: {:.5f} samples/s"
.
format
(
batch_size
/
trainer
.
time_info
[
"batch_cost"
].
avg
)
batch_size
/
trainer
.
time_info
[
"batch_cost"
].
avg
)
eta_sec
=
(
(
trainer
.
config
[
"Global"
][
"epochs"
]
-
epoch_id
+
1
eta_sec
=
(
)
*
trainer
.
max_iter
-
iter_id
(
trainer
.
config
[
"Global"
][
"epochs"
]
-
epoch_id
+
1
)
*
trainer
.
time_info
[
"batch_cost"
].
avg
)
*
trainer
.
max_iter
-
iter_id
)
*
trainer
.
time_info
[
"batch_cost"
].
avg
eta_msg
=
"eta: {:s}"
.
format
(
str
(
datetime
.
timedelta
(
seconds
=
int
(
eta_sec
))))
eta_msg
=
"eta: {:s}"
.
format
(
str
(
datetime
.
timedelta
(
seconds
=
int
(
eta_sec
))))
logger
.
info
(
"[Train][Epoch {}/{}][Iter: {}/{}]{}, {}, {}, {}, {}"
.
format
(
logger
.
info
(
"[Train][Epoch {}/{}][Iter: {}/{}]{}, {}, {}, {}, {}"
.
format
(
epoch_id
,
trainer
.
config
[
"Global"
][
"epochs"
],
iter_id
,
epoch_id
,
trainer
.
config
[
"Global"
][
"epochs"
],
iter_id
,
trainer
.
max_iter
,
lr_msg
,
metric_msg
,
time_msg
,
ips_msg
,
trainer
.
max_iter
,
lr_msg
,
metric_msg
,
time_msg
,
ips_msg
,
eta_msg
))
eta_msg
))
for
i
,
lr
in
enumerate
(
trainer
.
lr_sch
):
for
i
,
lr
in
enumerate
(
trainer
.
lr_sch
):
logger
.
scaler
(
logger
.
scaler
(
...
...
ppcls/metric/metrics.py
浏览文件 @
9984080a
...
@@ -113,7 +113,7 @@ class mAP(nn.Layer):
...
@@ -113,7 +113,7 @@ class mAP(nn.Layer):
precision_mask
=
paddle
.
multiply
(
equal_flag
,
precision
)
precision_mask
=
paddle
.
multiply
(
equal_flag
,
precision
)
ap
=
paddle
.
sum
(
precision_mask
,
axis
=
1
)
/
paddle
.
sum
(
equal_flag
,
ap
=
paddle
.
sum
(
precision_mask
,
axis
=
1
)
/
paddle
.
sum
(
equal_flag
,
axis
=
1
)
axis
=
1
)
metric_dict
[
"mAP"
]
=
paddle
.
mean
(
ap
).
numpy
()[
0
]
metric_dict
[
"mAP"
]
=
float
(
paddle
.
mean
(
ap
))
return
metric_dict
return
metric_dict
...
@@ -157,7 +157,7 @@ class mINP(nn.Layer):
...
@@ -157,7 +157,7 @@ class mINP(nn.Layer):
hard_index
=
paddle
.
argmax
(
auxilary
,
axis
=
1
).
astype
(
"float32"
)
hard_index
=
paddle
.
argmax
(
auxilary
,
axis
=
1
).
astype
(
"float32"
)
all_INP
=
paddle
.
divide
(
paddle
.
sum
(
equal_flag
,
axis
=
1
),
hard_index
)
all_INP
=
paddle
.
divide
(
paddle
.
sum
(
equal_flag
,
axis
=
1
),
hard_index
)
mINP
=
paddle
.
mean
(
all_INP
)
mINP
=
paddle
.
mean
(
all_INP
)
metric_dict
[
"mINP"
]
=
mINP
.
numpy
()[
0
]
metric_dict
[
"mINP"
]
=
float
(
mINP
)
return
metric_dict
return
metric_dict
...
@@ -362,7 +362,7 @@ class HammingDistance(MultiLabelMetric):
...
@@ -362,7 +362,7 @@ class HammingDistance(MultiLabelMetric):
metric_dict
[
"HammingDistance"
]
=
paddle
.
to_tensor
(
metric_dict
[
"HammingDistance"
]
=
paddle
.
to_tensor
(
hamming_loss
(
target
,
preds
))
hamming_loss
(
target
,
preds
))
self
.
avg_meters
[
"HammingDistance"
].
update
(
self
.
avg_meters
[
"HammingDistance"
].
update
(
metric_dict
[
"HammingDistance"
].
numpy
()[
0
]
,
output
.
shape
[
0
])
float
(
metric_dict
[
"HammingDistance"
])
,
output
.
shape
[
0
])
return
metric_dict
return
metric_dict
...
@@ -402,7 +402,7 @@ class AccuracyScore(MultiLabelMetric):
...
@@ -402,7 +402,7 @@ class AccuracyScore(MultiLabelMetric):
sum
(
tps
)
+
sum
(
tns
)
+
sum
(
fns
)
+
sum
(
fps
))
sum
(
tps
)
+
sum
(
tns
)
+
sum
(
fns
)
+
sum
(
fps
))
metric_dict
[
"AccuracyScore"
]
=
paddle
.
to_tensor
(
accuracy
)
metric_dict
[
"AccuracyScore"
]
=
paddle
.
to_tensor
(
accuracy
)
self
.
avg_meters
[
"AccuracyScore"
].
update
(
self
.
avg_meters
[
"AccuracyScore"
].
update
(
metric_dict
[
"AccuracyScore"
].
numpy
()[
0
]
,
output
.
shape
[
0
])
float
(
metric_dict
[
"AccuracyScore"
])
,
output
.
shape
[
0
])
return
metric_dict
return
metric_dict
...
...
ppcls/utils/misc.py
浏览文件 @
9984080a
...
@@ -47,7 +47,7 @@ class AverageMeter(object):
...
@@ -47,7 +47,7 @@ class AverageMeter(object):
@
property
@
property
def
avg_info
(
self
):
def
avg_info
(
self
):
if
isinstance
(
self
.
avg
,
paddle
.
Tensor
):
if
isinstance
(
self
.
avg
,
paddle
.
Tensor
):
self
.
avg
=
self
.
avg
.
numpy
()[
0
]
self
.
avg
=
float
(
self
.
avg
)
return
"{}: {:.5f}"
.
format
(
self
.
name
,
self
.
avg
)
return
"{}: {:.5f}"
.
format
(
self
.
name
,
self
.
avg
)
@
property
@
property
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录