Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleClas
提交
d3374e89
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看板
提交
d3374e89
编写于
3月 08, 2023
作者:
G
gaotingquan
提交者:
Wei Shengyu
3月 10, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
revert for running
上级
d3b7690f
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
23 addition
and
39 deletion
+23
-39
ppcls/data/__init__.py
ppcls/data/__init__.py
+0
-22
ppcls/engine/evaluation/classification.py
ppcls/engine/evaluation/classification.py
+1
-1
ppcls/engine/train/classification.py
ppcls/engine/train/classification.py
+13
-2
ppcls/metric/__init__.py
ppcls/metric/__init__.py
+9
-14
未找到文件。
ppcls/data/__init__.py
浏览文件 @
d3374e89
...
...
@@ -207,25 +207,3 @@ def build_dataloader(config, mode, seed=None):
logger
.
debug
(
"build data_loader({}) success..."
.
format
(
data_loader
))
return
data_loader
# # TODO(gaotingquan): the length of dataloader should be determined by sampler
# class DataIterator(object):
# def __init__(self, dataloader, use_dali=False):
# self.dataloader = dataloader
# self.use_dali = use_dali
# self.iterator = iter(dataloader)
# self.max_iter = dataloader.max_iter
# self.total_samples = dataloader.total_samples
# def get_batch(self):
# # fetch data batch from dataloader
# try:
# batch = next(self.iterator)
# except Exception:
# # NOTE: reset DALI dataloader manually
# if self.use_dali:
# self.dataloader.reset()
# self.iterator = iter(self.dataloader)
# batch = next(self.iterator)
# return batch
ppcls/engine/evaluation/classification.py
浏览文件 @
d3374e89
...
...
@@ -31,7 +31,7 @@ class ClassEval(object):
self
.
model
=
model
self
.
print_batch_step
=
self
.
config
[
"Global"
][
"print_batch_step"
]
self
.
use_dali
=
self
.
config
[
"Global"
].
get
(
"use_dali"
,
False
)
self
.
eval_metric_func
=
build_metrics
(
self
.
config
,
"
e
val"
)
self
.
eval_metric_func
=
build_metrics
(
self
.
config
,
"
E
val"
)
self
.
eval_dataloader
=
build_dataloader
(
self
.
config
,
"Eval"
)
self
.
eval_loss_func
=
build_loss
(
self
.
config
,
"Eval"
)
self
.
output_info
=
dict
()
...
...
ppcls/engine/train/classification.py
浏览文件 @
d3374e89
...
...
@@ -48,12 +48,13 @@ class ClassTrainer(object):
# build dataloader
self
.
use_dali
=
self
.
config
[
"Global"
].
get
(
"use_dali"
,
False
)
self
.
dataloader
=
build_dataloader
(
self
.
config
,
"Train"
)
self
.
dataloader_iter
=
iter
(
self
.
dataloader
)
# build loss
self
.
loss_func
=
build_loss
(
config
,
"Train"
)
# build metric
self
.
train_metric_func
=
build_metrics
(
config
,
"
t
rain"
)
self
.
train_metric_func
=
build_metrics
(
config
,
"
T
rain"
)
# build optimizer
self
.
optimizer
,
self
.
lr_sch
=
build_optimizer
(
...
...
@@ -174,7 +175,17 @@ class ClassTrainer(object):
self
.
model
.
train
()
tic
=
time
.
time
()
for
iter_id
,
batch
in
enumerate
(
self
.
dataloader
):
for
iter_id
in
range
(
self
.
dataloader
.
max_iter
):
# fetch data batch from dataloader
try
:
batch
=
next
(
self
.
dataloader_iter
)
except
Exception
:
# NOTE: reset DALI dataloader manually
if
self
.
use_dali
:
self
.
dataloader
.
reset
()
self
.
dataloader_iter
=
iter
(
self
.
dataloader
)
batch
=
next
(
self
.
dataloader_iter
)
profiler
.
add_profiler_step
(
self
.
config
[
"profiler_options"
])
if
iter_id
==
5
:
for
key
in
self
.
time_info
:
...
...
ppcls/metric/__init__.py
浏览文件 @
d3374e89
...
...
@@ -66,7 +66,7 @@ class CombinedMetrics(AvgMetrics):
def
build_metrics
(
config
,
mode
):
if
mode
==
'
t
rain'
and
"Metric"
in
config
and
"Train"
in
config
[
if
mode
==
'
T
rain'
and
"Metric"
in
config
and
"Train"
in
config
[
"Metric"
]
and
config
[
"Metric"
][
"Train"
]:
metric_config
=
config
[
"Metric"
][
"Train"
]
if
config
[
"DataLoader"
][
"Train"
][
"dataset"
].
get
(
"batch_transform_ops"
,
...
...
@@ -76,22 +76,17 @@ def build_metrics(config, mode):
msg
=
f
"Unable to calculate accuracy when using
\"
batch_transform_ops
\"
. The metric
\"
{
m
}
\"
has been removed."
logger
.
warning
(
msg
)
metric_config
.
pop
(
m_idx
)
train_metric_func
=
CombinedMetrics
(
copy
.
deepcopy
(
metric_config
))
return
train_metric_func
return
CombinedMetrics
(
copy
.
deepcopy
(
metric_config
))
if
mode
==
"
eval"
or
(
mode
==
"train"
and
config
[
"Global"
][
"eval_during_train"
]):
eval_mode
=
config
[
"Global"
].
get
(
"eval_mode"
,
"classification"
)
if
eval_mode
==
"classification"
:
if
mode
==
"
Eval"
:
task
=
config
[
"Global"
].
get
(
"task"
,
"classification"
)
assert
task
in
[
"classification"
,
"retrieval"
]
if
task
==
"classification"
:
if
"Metric"
in
config
and
"Eval"
in
config
[
"Metric"
]:
eval_metric_func
=
CombinedMetrics
(
copy
.
deepcopy
(
config
[
"Metric"
][
"Eval"
]))
else
:
eval_metric_func
=
None
elif
eval_mode
==
"retrieval"
:
return
CombinedMetrics
(
copy
.
deepcopy
(
config
[
"Metric"
][
"Eval"
]))
elif
task
==
"retrieval"
:
if
"Metric"
in
config
and
"Eval"
in
config
[
"Metric"
]:
metric_config
=
config
[
"Metric"
][
"Eval"
]
else
:
metric_config
=
[{
"name"
:
"Recallk"
,
"topk"
:
(
1
,
5
)}]
eval_metric_func
=
CombinedMetrics
(
copy
.
deepcopy
(
metric_config
))
return
eval_metric_func
return
CombinedMetrics
(
copy
.
deepcopy
(
metric_config
))
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录