Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleSlim
提交
82da1f14
P
PaddleSlim
项目概览
PaddlePaddle
/
PaddleSlim
1 年多 前同步成功
通知
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看板
未验证
提交
82da1f14
编写于
1月 17, 2023
作者:
C
ceci3
提交者:
GitHub
1月 17, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix unittest (#1633)
上级
cb57443e
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
25 addition
and
17 deletion
+25
-17
.pre-commit-config.yaml
.pre-commit-config.yaml
+3
-3
paddleslim/quant/quant_aware_with_infermodel.py
paddleslim/quant/quant_aware_with_infermodel.py
+22
-14
未找到文件。
.pre-commit-config.yaml
浏览文件 @
82da1f14
repos
:
-
repo
:
https://github.com/Lucas-C/pre-commit-hooks.git
sha
:
v1.0
.1
rev
:
v1.3
.1
hooks
:
-
id
:
remove-crlf
files
:
.∗
...
...
@@ -9,12 +9,12 @@ repos:
-
id
:
remove-tabs
files
:
\.(md|yml)$
-
repo
:
https://github.com/PaddlePaddle/mirrors-yapf.git
sha
:
0d79c0c469bab64f7229c9aca2b1186ef47f0e37
rev
:
v0.16.2
hooks
:
-
id
:
yapf
files
:
(.*\.(py|bzl)|BUILD|.*\.BUILD|WORKSPACE)$
-
repo
:
https://github.com/pre-commit/pre-commit-hooks
sha
:
5bf6c09bfa1297d3692cadd621ef95f1284e33c
0
rev
:
v4.4.
0
hooks
:
-
id
:
check-added-large-files
-
id
:
check-merge-conflict
...
...
paddleslim/quant/quant_aware_with_infermodel.py
浏览文件 @
82da1f14
...
...
@@ -37,25 +37,34 @@ _logger = get_logger(__name__, level=logging.INFO)
############################################################################################################
_train_config_default
=
{
# configs of training aware quantization with infermodel
"num_epoch"
:
1000
,
# training epoch num
"max_iter"
:
-
1
,
# max training iteration num
"num_epoch"
:
1000
,
# training epoch num
"max_iter"
:
-
1
,
# max training iteration num
"save_iter_step"
:
1000
,
# save quant model checkpoint every save_iter_step iteration
"learning_rate"
:
0.0001
,
# learning rate
"weight_decay"
:
0.0001
,
# weight decay
"use_pact"
:
False
,
# use pact quantization or not
"learning_rate"
:
0.0001
,
# learning rate
"weight_decay"
:
0.0001
,
# weight decay
"use_pact"
:
False
,
# use pact quantization or not
# quant model checkpoints save path
"quant_model_ckpt_path"
:
"./quant_model_checkpoints/"
,
"quant_model_ckpt_path"
:
"./quant_model_checkpoints/"
,
# storage directory of teacher model + teacher model name (excluding suffix)
"teacher_model_path_prefix"
:
None
,
"teacher_model_path_prefix"
:
None
,
# storage directory of model + model name (excluding suffix)
"model_path_prefix"
:
None
,
"model_path_prefix"
:
None
,
""" distillation node configuration:
the name of the distillation supervision nodes is configured as a list,
and the teacher node and student node are arranged in pairs.
for example, ["teacher_fc_0.tmp_0", "fc_0.tmp_0", "teacher_batch_norm_24.tmp_4", "batch_norm_24.tmp_4"]
"""
"node"
:
None
"node"
:
None
}
...
...
@@ -184,9 +193,9 @@ def quant_aware_with_infermodel(executor,
place
,
quant_config
,
scope
=
scope
,
act_preprocess_func
=
act_preprocess_func
,
optimizer_func
=
optimizer_func
,
executor
=
pact_executor
,
act_preprocess_func
=
None
,
optimizer_func
=
None
,
executor
=
None
,
for_test
=
True
)
train_program
=
quant_aware
(
train_program
,
...
...
@@ -225,8 +234,7 @@ def quant_aware_with_infermodel(executor,
test_callback
(
compiled_test_prog
,
test_feed_names
,
test_fetch_list
,
checkpoint_name
)
iter_sum
+=
1
if
train_config
[
"max_iter"
]
>=
0
and
iter_sum
>
train_config
[
"max_iter"
]:
if
train_config
[
"max_iter"
]
>=
0
and
iter_sum
>
train_config
[
"max_iter"
]:
return
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录