Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleX
提交
1ee6d162
P
PaddleX
项目概览
PaddlePaddle
/
PaddleX
通知
138
Star
4
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
43
列表
看板
标记
里程碑
合并请求
5
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleX
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
43
Issue
43
列表
看板
标记
里程碑
合并请求
5
合并请求
5
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
1ee6d162
编写于
5月 19, 2020
作者:
S
sunyanfang01
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fis the post quant
上级
0b9a4c4c
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
10 addition
and
17 deletion
+10
-17
paddlex/cv/models/base.py
paddlex/cv/models/base.py
+10
-17
未找到文件。
paddlex/cv/models/base.py
浏览文件 @
1ee6d162
...
@@ -15,6 +15,7 @@
...
@@ -15,6 +15,7 @@
from
__future__
import
absolute_import
from
__future__
import
absolute_import
import
paddle.fluid
as
fluid
import
paddle.fluid
as
fluid
import
os
import
os
import
sys
import
numpy
as
np
import
numpy
as
np
import
time
import
time
import
math
import
math
...
@@ -252,6 +253,9 @@ class BaseAPI:
...
@@ -252,6 +253,9 @@ class BaseAPI:
del
self
.
init_params
[
'self'
]
del
self
.
init_params
[
'self'
]
if
'__class__'
in
self
.
init_params
:
if
'__class__'
in
self
.
init_params
:
del
self
.
init_params
[
'__class__'
]
del
self
.
init_params
[
'__class__'
]
if
'model_name'
in
self
.
init_params
:
del
self
.
init_params
[
'model_name'
]
info
[
'_init_params'
]
=
self
.
init_params
info
[
'_init_params'
]
=
self
.
init_params
info
[
'_Attributes'
][
'num_classes'
]
=
self
.
num_classes
info
[
'_Attributes'
][
'num_classes'
]
=
self
.
num_classes
...
@@ -372,6 +376,8 @@ class BaseAPI:
...
@@ -372,6 +376,8 @@ class BaseAPI:
use_vdl
=
False
,
use_vdl
=
False
,
early_stop
=
False
,
early_stop
=
False
,
early_stop_patience
=
5
):
early_stop_patience
=
5
):
if
train_dataset
.
num_samples
<
train_batch_size
:
raise
Exception
(
'The amount of training datset must be larger than batch size.'
)
if
not
osp
.
isdir
(
save_dir
):
if
not
osp
.
isdir
(
save_dir
):
if
osp
.
exists
(
save_dir
):
if
osp
.
exists
(
save_dir
):
os
.
remove
(
save_dir
)
os
.
remove
(
save_dir
)
...
@@ -429,9 +435,7 @@ class BaseAPI:
...
@@ -429,9 +435,7 @@ class BaseAPI:
if
use_vdl
:
if
use_vdl
:
# VisualDL component
# VisualDL component
log_writer
=
LogWriter
(
vdl_logdir
,
sync_cycle
=
20
)
log_writer
=
LogWriter
(
vdl_logdir
)
train_step_component
=
OrderedDict
()
eval_component
=
OrderedDict
()
thresh
=
0.0001
thresh
=
0.0001
if
early_stop
:
if
early_stop
:
...
@@ -469,13 +473,7 @@ class BaseAPI:
...
@@ -469,13 +473,7 @@ class BaseAPI:
if
use_vdl
:
if
use_vdl
:
for
k
,
v
in
step_metrics
.
items
():
for
k
,
v
in
step_metrics
.
items
():
if
k
not
in
train_step_component
.
keys
():
log_writer
.
add_scalar
(
'Metrics/Training(Step): {}'
.
format
(
k
),
v
,
num_steps
)
with
log_writer
.
mode
(
'Each_Step_while_Training'
)
as
step_logger
:
train_step_component
[
k
]
=
step_logger
.
scalar
(
'Training: {}'
.
format
(
k
))
train_step_component
[
k
].
add_record
(
num_steps
,
v
)
# 估算剩余时间
# 估算剩余时间
avg_step_time
=
np
.
mean
(
time_stat
)
avg_step_time
=
np
.
mean
(
time_stat
)
...
@@ -536,12 +534,7 @@ class BaseAPI:
...
@@ -536,12 +534,7 @@ class BaseAPI:
if
isinstance
(
v
,
np
.
ndarray
):
if
isinstance
(
v
,
np
.
ndarray
):
if
v
.
size
>
1
:
if
v
.
size
>
1
:
continue
continue
if
k
not
in
eval_component
:
log_writer
.
add_scalar
(
"Metrics/Eval(Epoch): {}"
.
format
(
k
),
v
,
i
+
1
)
with
log_writer
.
mode
(
'Each_Epoch_on_Eval_Data'
)
as
eval_logger
:
eval_component
[
k
]
=
eval_logger
.
scalar
(
'Evaluation: {}'
.
format
(
k
))
eval_component
[
k
].
add_record
(
i
+
1
,
v
)
self
.
save_model
(
save_dir
=
current_save_dir
)
self
.
save_model
(
save_dir
=
current_save_dir
)
time_eval_one_epoch
=
time
.
time
()
-
eval_epoch_start_time
time_eval_one_epoch
=
time
.
time
()
-
eval_epoch_start_time
eval_epoch_start_time
=
time
.
time
()
eval_epoch_start_time
=
time
.
time
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录