Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleClas
提交
f04b5234
P
PaddleClas
项目概览
PaddlePaddle
/
PaddleClas
接近 2 年 前同步成功
通知
116
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看板
提交
f04b5234
编写于
5月 13, 2022
作者:
G
gaotingquan
提交者:
Tingquan Gao
5月 14, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: unable to export rep net
上级
03142ea3
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
11 addition
and
12 deletion
+11
-12
ppcls/arch/backbone/legendary_models/pp_lcnet_v2.py
ppcls/arch/backbone/legendary_models/pp_lcnet_v2.py
+3
-5
ppcls/arch/backbone/model_zoo/repvgg.py
ppcls/arch/backbone/model_zoo/repvgg.py
+2
-7
ppcls/engine/engine.py
ppcls/engine/engine.py
+6
-0
未找到文件。
ppcls/arch/backbone/legendary_models/pp_lcnet_v2.py
浏览文件 @
f04b5234
...
...
@@ -188,7 +188,7 @@ class RepDepthwiseSeparable(TheseusLayer):
def
forward
(
self
,
x
):
if
self
.
use_rep
:
input_x
=
x
if
not
self
.
training
:
if
self
.
is_repped
:
x
=
self
.
act
(
self
.
dw_conv
(
x
))
else
:
y
=
self
.
dw_conv_list
[
0
](
x
)
...
...
@@ -209,14 +209,12 @@ class RepDepthwiseSeparable(TheseusLayer):
x
=
x
+
input_x
return
x
def
eval
(
self
):
def
rep
(
self
):
if
self
.
use_rep
:
self
.
is_repped
=
True
kernel
,
bias
=
self
.
_get_equivalent_kernel_bias
()
self
.
dw_conv
.
weight
.
set_value
(
kernel
)
self
.
dw_conv
.
bias
.
set_value
(
bias
)
self
.
training
=
False
for
layer
in
self
.
sublayers
():
layer
.
eval
()
def
_get_equivalent_kernel_bias
(
self
):
kernel_sum
=
0
...
...
ppcls/arch/backbone/model_zoo/repvgg.py
浏览文件 @
f04b5234
...
...
@@ -124,13 +124,7 @@ class RepVGGBlock(nn.Layer):
groups
=
groups
)
def
forward
(
self
,
inputs
):
if
not
self
.
training
and
not
self
.
is_repped
:
self
.
rep
()
self
.
is_repped
=
True
if
self
.
training
and
self
.
is_repped
:
self
.
is_repped
=
False
if
not
self
.
training
:
if
self
.
is_repped
:
return
self
.
nonlinearity
(
self
.
rbr_reparam
(
inputs
))
if
self
.
rbr_identity
is
None
:
...
...
@@ -154,6 +148,7 @@ class RepVGGBlock(nn.Layer):
kernel
,
bias
=
self
.
get_equivalent_kernel_bias
()
self
.
rbr_reparam
.
weight
.
set_value
(
kernel
)
self
.
rbr_reparam
.
bias
.
set_value
(
bias
)
self
.
is_repped
=
True
def
get_equivalent_kernel_bias
(
self
):
kernel3x3
,
bias3x3
=
self
.
_fuse_bn_tensor
(
self
.
rbr_dense
)
...
...
ppcls/engine/engine.py
浏览文件 @
f04b5234
...
...
@@ -452,6 +452,12 @@ class Engine(object):
self
.
config
[
"Global"
][
"pretrained_model"
])
model
.
eval
()
# for rep nets
for
layer
in
self
.
model
.
sublayers
():
if
hasattr
(
layer
,
"rep"
):
layer
.
rep
()
save_path
=
os
.
path
.
join
(
self
.
config
[
"Global"
][
"save_inference_dir"
],
"inference"
)
if
model
.
quanter
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录