Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleSlim
提交
3d0755b1
P
PaddleSlim
项目概览
PaddlePaddle
/
PaddleSlim
大约 2 年 前同步成功
通知
51
Star
1434
Fork
344
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
53
列表
看板
标记
里程碑
合并请求
16
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleSlim
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
53
Issue
53
列表
看板
标记
里程碑
合并请求
16
合并请求
16
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
“c12e970e274541e817aeac3d19024a09b1a46559”上不存在“dev/doc/tutorials/image_classification/index_en.html”
未验证
提交
3d0755b1
编写于
8月 18, 2022
作者:
C
Chang Xu
提交者:
GitHub
8月 18, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add Early Stop in AutoCompression (#1358)
上级
d6f9aafc
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
13 addition
and
2 deletion
+13
-2
paddleslim/auto_compression/compressor.py
paddleslim/auto_compression/compressor.py
+13
-2
未找到文件。
paddleslim/auto_compression/compressor.py
浏览文件 @
3d0755b1
...
@@ -714,7 +714,10 @@ class AutoCompression:
...
@@ -714,7 +714,10 @@ class AutoCompression:
best_metric
=
-
1.0
best_metric
=
-
1.0
total_epochs
=
train_config
.
epochs
if
train_config
.
epochs
else
100
total_epochs
=
train_config
.
epochs
if
train_config
.
epochs
else
100
total_train_iter
=
0
total_train_iter
=
0
stop_training
=
False
for
epoch_id
in
range
(
total_epochs
):
for
epoch_id
in
range
(
total_epochs
):
if
stop_training
:
break
for
batch_id
,
data
in
enumerate
(
self
.
train_dataloader
()):
for
batch_id
,
data
in
enumerate
(
self
.
train_dataloader
()):
np_probs_float
,
=
self
.
_exe
.
run
(
train_program_info
.
program
,
\
np_probs_float
,
=
self
.
_exe
.
run
(
train_program_info
.
program
,
\
feed
=
data
,
\
feed
=
data
,
\
...
@@ -760,6 +763,10 @@ class AutoCompression:
...
@@ -760,6 +763,10 @@ class AutoCompression:
abs
(
best_metric
-
abs
(
best_metric
-
self
.
metric_before_compressed
)
self
.
metric_before_compressed
)
)
/
self
.
metric_before_compressed
<=
0.005
:
)
/
self
.
metric_before_compressed
<=
0.005
:
_logger
.
info
(
"The error rate between the compressed model and original model is less than 5%. The training process ends."
)
stop_training
=
True
break
break
else
:
else
:
_logger
.
info
(
_logger
.
info
(
...
@@ -767,14 +774,18 @@ class AutoCompression:
...
@@ -767,14 +774,18 @@ class AutoCompression:
format
(
epoch_id
,
metric
,
best_metric
))
format
(
epoch_id
,
metric
,
best_metric
))
if
train_config
.
target_metric
is
not
None
:
if
train_config
.
target_metric
is
not
None
:
if
metric
>
float
(
train_config
.
target_metric
):
if
metric
>
float
(
train_config
.
target_metric
):
stop_training
=
True
_logger
.
info
(
"The metric of compressed model has reached the target metric. The training process ends."
)
break
break
else
:
else
:
_logger
.
warning
(
_logger
.
warning
(
"Not set eval function, so unable to test accuracy performance."
"Not set eval function, so unable to test accuracy performance."
)
)
if
train_config
.
train_iter
and
total_train_iter
>=
train_config
.
train_iter
:
if
(
train_config
.
train_iter
and
total_train_iter
>=
epoch_id
=
total_epochs
train_config
.
train_iter
)
or
stop_training
:
break
break
if
'unstructure'
in
self
.
_strategy
or
train_config
.
sparse_model
:
if
'unstructure'
in
self
.
_strategy
or
train_config
.
sparse_model
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录