Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleClas
提交
442d8410
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看板
提交
442d8410
编写于
6月 28, 2020
作者:
W
wqz960
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix +
上级
2e2c01c2
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
22 addition
and
8 deletion
+22
-8
ppcls/modeling/architectures/ghostnet.py
ppcls/modeling/architectures/ghostnet.py
+22
-8
未找到文件。
ppcls/modeling/architectures/ghostnet.py
浏览文件 @
442d8410
...
...
@@ -119,19 +119,19 @@ class GhostNet():
param_attr
=
ParamAttr
(
initializer
=
fluid
.
initializer
.
MSRA
(),
name
=
name
+
"_weights"
),
bias_attr
=
False
)
bn_name
=
name
+
"_bn"
bn_name
=
name
+
"_bn"
x
=
fluid
.
layers
.
batch_norm
(
input
=
x
,
act
=
act
,
param_attr
=
ParamAttr
(
name
=
bn_name
+
"_scale"
,
name
=
bn_name
+
"_scale"
,
regularizer
=
fluid
.
regularizer
.
L2DecayRegularizer
(
regularization_coeff
=
0.0
)),
bias_attr
=
ParamAttr
(
name
=
bn_name
+
"_offset"
,
name
=
bn_name
+
"_offset"
,
regularizer
=
fluid
.
regularizer
.
L2DecayRegularizer
(
regularization_coeff
=
0.0
)),
moving_mean_name
=
bn_name
+
"_mean"
,
moving_variance_name
=
name
+
"_variance"
)
moving_mean_name
=
bn_name
+
"_mean"
,
moving_variance_name
=
name
+
"_variance"
)
return
x
def
se_block
(
self
,
input
,
num_channels
,
reduction_ratio
=
4
,
name
=
None
):
...
...
@@ -147,12 +147,13 @@ class GhostNet():
stdv
=
1.0
/
math
.
sqrt
(
squeeze
.
shape
[
1
]
*
1.0
)
excitation
=
fluid
.
layers
.
fc
(
input
=
squeeze
,
size
=
num_channels
,
act
=
None
,
act
=
"hard_sigmoid"
,
param_attr
=
fluid
.
param_attr
.
ParamAttr
(
initializer
=
fluid
.
initializer
.
Uniform
(
-
stdv
,
stdv
),
name
=
name
+
'_2_weights'
),
bias_attr
=
ParamAttr
(
name
=
name
+
'_2_offset'
))
excitation
=
fluid
.
layers
.
clip
(
x
=
excitation
,
min
=
0
,
max
=
1
)
#excitation = fluid.layers.clip(x=excitation, min=0, max=1)
print
(
"using hardsigmoid"
)
se_scale
=
fluid
.
layers
.
elementwise_mul
(
x
=
input
,
y
=
excitation
,
axis
=
0
)
return
se_scale
...
...
@@ -223,7 +224,7 @@ class GhostNet():
relu
=
False
,
name
=
name
+
"_depthwise"
)
if
use_se
:
x
=
self
.
se_block
(
input
=
x
,
num_channels
=
hidden_dim
,
name
=
name
+
"_se"
)
x
=
self
.
se_block
(
input
=
x
,
num_channels
=
hidden_dim
,
name
=
name
+
"_se"
)
x
=
self
.
ghost_module
(
input
=
x
,
output
=
output
,
kernel_size
=
1
,
...
...
@@ -264,3 +265,16 @@ def GhostNet_x1_3():
model
=
GhostNet
(
scale
=
1.3
)
return
model
if
__name__
==
"__main__"
:
image
=
fluid
.
data
(
name
=
'image'
,
shape
=
[
16
,
3
,
224
,
224
],
dtype
=
'float32'
)
model
=
GhostNet_x1_0
()
out
=
model
.
net
(
input
=
image
,
class_dim
=
1000
)
test_program
=
fluid
.
default_main_program
().
clone
(
for_test
=
True
)
place
=
fluid
.
CPUPlace
()
exe
=
fluid
.
Executor
(
place
)
exe
.
run
(
fluid
.
default_startup_program
())
#lltotal_flops_params, is_quantize = summary(test_program)
fluid
.
save
(
test_program
,
"ghostnet1_3"
)
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录