Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleClas
提交
a40d348e
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看板
未验证
提交
a40d348e
编写于
1月 26, 2021
作者:
L
littletomatodonkey
提交者:
GitHub
1月 26, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Update mobilenet_v3.py
上级
9ebbd78b
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
25 addition
and
25 deletion
+25
-25
ppcls/modeling/architectures/mobilenet_v3.py
ppcls/modeling/architectures/mobilenet_v3.py
+25
-25
未找到文件。
ppcls/modeling/architectures/mobilenet_v3.py
浏览文件 @
a40d348e
...
@@ -21,7 +21,7 @@ import paddle
...
@@ -21,7 +21,7 @@ import paddle
from
paddle
import
ParamAttr
from
paddle
import
ParamAttr
import
paddle.nn
as
nn
import
paddle.nn
as
nn
import
paddle.nn.functional
as
F
import
paddle.nn.functional
as
F
from
paddle.nn.functional
.activation
import
hard_sigmoid
,
hard_swish
from
paddle.nn.functional
import
hardswish
,
hardsigmoid
from
paddle.nn
import
Conv2D
,
BatchNorm
,
Linear
,
Dropout
from
paddle.nn
import
Conv2D
,
BatchNorm
,
Linear
,
Dropout
from
paddle.nn
import
AdaptiveAvgPool2D
,
MaxPool2D
,
AvgPool2D
from
paddle.nn
import
AdaptiveAvgPool2D
,
MaxPool2D
,
AvgPool2D
from
paddle.regularizer
import
L2Decay
from
paddle.regularizer
import
L2Decay
...
@@ -64,15 +64,15 @@ class MobileNetV3(nn.Layer):
...
@@ -64,15 +64,15 @@ class MobileNetV3(nn.Layer):
[
5
,
72
,
40
,
True
,
"relu"
,
2
],
[
5
,
72
,
40
,
True
,
"relu"
,
2
],
[
5
,
120
,
40
,
True
,
"relu"
,
1
],
[
5
,
120
,
40
,
True
,
"relu"
,
1
],
[
5
,
120
,
40
,
True
,
"relu"
,
1
],
[
5
,
120
,
40
,
True
,
"relu"
,
1
],
[
3
,
240
,
80
,
False
,
"hard
_
swish"
,
2
],
[
3
,
240
,
80
,
False
,
"hardswish"
,
2
],
[
3
,
200
,
80
,
False
,
"hard
_
swish"
,
1
],
[
3
,
200
,
80
,
False
,
"hardswish"
,
1
],
[
3
,
184
,
80
,
False
,
"hard
_
swish"
,
1
],
[
3
,
184
,
80
,
False
,
"hardswish"
,
1
],
[
3
,
184
,
80
,
False
,
"hard
_
swish"
,
1
],
[
3
,
184
,
80
,
False
,
"hardswish"
,
1
],
[
3
,
480
,
112
,
True
,
"hard
_
swish"
,
1
],
[
3
,
480
,
112
,
True
,
"hardswish"
,
1
],
[
3
,
672
,
112
,
True
,
"hard
_
swish"
,
1
],
[
3
,
672
,
112
,
True
,
"hardswish"
,
1
],
[
5
,
672
,
160
,
True
,
"hard
_
swish"
,
2
],
[
5
,
672
,
160
,
True
,
"hardswish"
,
2
],
[
5
,
960
,
160
,
True
,
"hard
_
swish"
,
1
],
[
5
,
960
,
160
,
True
,
"hardswish"
,
1
],
[
5
,
960
,
160
,
True
,
"hard
_
swish"
,
1
],
[
5
,
960
,
160
,
True
,
"hardswish"
,
1
],
]
]
self
.
cls_ch_squeeze
=
960
self
.
cls_ch_squeeze
=
960
self
.
cls_ch_expand
=
1280
self
.
cls_ch_expand
=
1280
...
@@ -82,14 +82,14 @@ class MobileNetV3(nn.Layer):
...
@@ -82,14 +82,14 @@ class MobileNetV3(nn.Layer):
[
3
,
16
,
16
,
True
,
"relu"
,
2
],
[
3
,
16
,
16
,
True
,
"relu"
,
2
],
[
3
,
72
,
24
,
False
,
"relu"
,
2
],
[
3
,
72
,
24
,
False
,
"relu"
,
2
],
[
3
,
88
,
24
,
False
,
"relu"
,
1
],
[
3
,
88
,
24
,
False
,
"relu"
,
1
],
[
5
,
96
,
40
,
True
,
"hard
_
swish"
,
2
],
[
5
,
96
,
40
,
True
,
"hardswish"
,
2
],
[
5
,
240
,
40
,
True
,
"hard
_
swish"
,
1
],
[
5
,
240
,
40
,
True
,
"hardswish"
,
1
],
[
5
,
240
,
40
,
True
,
"hard
_
swish"
,
1
],
[
5
,
240
,
40
,
True
,
"hardswish"
,
1
],
[
5
,
120
,
48
,
True
,
"hard
_
swish"
,
1
],
[
5
,
120
,
48
,
True
,
"hardswish"
,
1
],
[
5
,
144
,
48
,
True
,
"hard
_
swish"
,
1
],
[
5
,
144
,
48
,
True
,
"hardswish"
,
1
],
[
5
,
288
,
96
,
True
,
"hard
_
swish"
,
2
],
[
5
,
288
,
96
,
True
,
"hardswish"
,
2
],
[
5
,
576
,
96
,
True
,
"hard
_
swish"
,
1
],
[
5
,
576
,
96
,
True
,
"hardswish"
,
1
],
[
5
,
576
,
96
,
True
,
"hard
_
swish"
,
1
],
[
5
,
576
,
96
,
True
,
"hardswish"
,
1
],
]
]
self
.
cls_ch_squeeze
=
576
self
.
cls_ch_squeeze
=
576
self
.
cls_ch_expand
=
1280
self
.
cls_ch_expand
=
1280
...
@@ -105,7 +105,7 @@ class MobileNetV3(nn.Layer):
...
@@ -105,7 +105,7 @@ class MobileNetV3(nn.Layer):
padding
=
1
,
padding
=
1
,
num_groups
=
1
,
num_groups
=
1
,
if_act
=
True
,
if_act
=
True
,
act
=
"hard
_
swish"
,
act
=
"hardswish"
,
name
=
"conv1"
)
name
=
"conv1"
)
self
.
block_list
=
[]
self
.
block_list
=
[]
...
@@ -135,7 +135,7 @@ class MobileNetV3(nn.Layer):
...
@@ -135,7 +135,7 @@ class MobileNetV3(nn.Layer):
padding
=
0
,
padding
=
0
,
num_groups
=
1
,
num_groups
=
1
,
if_act
=
True
,
if_act
=
True
,
act
=
"hard
_
swish"
,
act
=
"hardswish"
,
name
=
"conv_last"
)
name
=
"conv_last"
)
self
.
pool
=
AdaptiveAvgPool2D
(
1
)
self
.
pool
=
AdaptiveAvgPool2D
(
1
)
...
@@ -167,9 +167,9 @@ class MobileNetV3(nn.Layer):
...
@@ -167,9 +167,9 @@ class MobileNetV3(nn.Layer):
x
=
self
.
pool
(
x
)
x
=
self
.
pool
(
x
)
x
=
self
.
last_conv
(
x
)
x
=
self
.
last_conv
(
x
)
x
=
hard
_
swish
(
x
)
x
=
hardswish
(
x
)
x
=
self
.
dropout
(
x
)
x
=
self
.
dropout
(
x
)
x
=
paddle
.
reshape
(
x
,
shape
=
[
x
.
shape
[
0
],
x
.
shape
[
1
]]
)
x
=
paddle
.
flatten
(
x
,
start_axis
=
1
,
stop_axis
=-
1
)
x
=
self
.
out
(
x
)
x
=
self
.
out
(
x
)
return
x
return
x
...
@@ -215,8 +215,8 @@ class ConvBNLayer(nn.Layer):
...
@@ -215,8 +215,8 @@ class ConvBNLayer(nn.Layer):
if
self
.
if_act
:
if
self
.
if_act
:
if
self
.
act
==
"relu"
:
if
self
.
act
==
"relu"
:
x
=
F
.
relu
(
x
)
x
=
F
.
relu
(
x
)
elif
self
.
act
==
"hard
_
swish"
:
elif
self
.
act
==
"hardswish"
:
x
=
hard
_
swish
(
x
)
x
=
hardswish
(
x
)
else
:
else
:
print
(
"The activation function is selected incorrectly."
)
print
(
"The activation function is selected incorrectly."
)
exit
()
exit
()
...
@@ -305,7 +305,7 @@ class SEModule(nn.Layer):
...
@@ -305,7 +305,7 @@ class SEModule(nn.Layer):
outputs
=
self
.
conv1
(
outputs
)
outputs
=
self
.
conv1
(
outputs
)
outputs
=
F
.
relu
(
outputs
)
outputs
=
F
.
relu
(
outputs
)
outputs
=
self
.
conv2
(
outputs
)
outputs
=
self
.
conv2
(
outputs
)
outputs
=
hard
_sigmoid
(
outputs
)
outputs
=
hard
sigmoid
(
outputs
,
slope
=
0.2
,
offset
=
0.5
)
return
paddle
.
multiply
(
x
=
inputs
,
y
=
outputs
)
return
paddle
.
multiply
(
x
=
inputs
,
y
=
outputs
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录