Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleClas
提交
9ecd3834
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看板
提交
9ecd3834
编写于
5月 15, 2020
作者:
littletomatodonkey
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add mish interface for cspnet
上级
008d7eb1
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
36 addition
and
13 deletion
+36
-13
configs/CSPNet/CSPResNet50.yaml
configs/CSPNet/CSPResNet50.yaml
+1
-1
ppcls/modeling/architectures/csp_resnet.py
ppcls/modeling/architectures/csp_resnet.py
+35
-12
未找到文件。
configs/CSPNet/CSPResNet50.yaml
浏览文件 @
9ecd3834
mode
:
'
train'
ARCHITECTURE
:
name
:
'
CSPResNet50'
name
:
'
CSPResNet50
_leaky
'
pretrained_model
:
"
"
model_save_dir
:
"
./output/"
...
...
ppcls/modeling/architectures/csp_resnet.py
浏览文件 @
9ecd3834
...
...
@@ -21,12 +21,16 @@ import math
import
paddle.fluid
as
fluid
from
paddle.fluid.param_attr
import
ParamAttr
__all__
=
[
"CSPResNet50"
,
"CSPResNet101"
]
__all__
=
[
"CSPResNet50_leaky"
,
"CSPResNet50_mish"
,
"CSPResNet101_leaky"
,
"CSPResNet101_mish"
]
class
CSPResNet
():
def
__init__
(
self
,
layers
=
50
):
def
__init__
(
self
,
layers
=
50
,
act
=
"leaky_relu"
):
self
.
layers
=
layers
self
.
act
=
act
def
net
(
self
,
input
,
class_dim
=
1000
,
data_format
=
"NCHW"
):
layers
=
self
.
layers
...
...
@@ -47,7 +51,7 @@ class CSPResNet():
num_filters
=
64
,
filter_size
=
7
,
stride
=
2
,
act
=
'leaky'
,
act
=
self
.
act
,
name
=
"conv1"
,
data_format
=
data_format
)
conv
=
fluid
.
layers
.
pool2d
(
...
...
@@ -66,7 +70,7 @@ class CSPResNet():
num_filters
=
num_filters
[
block
],
filter_size
=
3
,
stride
=
2
,
act
=
"leaky_relu"
,
act
=
self
.
act
,
name
=
conv_name
+
"_downsample"
,
data_format
=
data_format
)
...
...
@@ -81,7 +85,7 @@ class CSPResNet():
input
=
right
,
num_filters
=
ch
,
filter_size
=
1
,
act
=
"leaky_relu"
,
act
=
self
.
act
,
name
=
conv_name
+
"_right_first_route"
,
data_format
=
data_format
)
...
...
@@ -100,14 +104,14 @@ class CSPResNet():
input
=
left
,
num_filters
=
num_filters
[
block
]
*
2
,
filter_size
=
1
,
act
=
"leaky_relu"
,
act
=
self
.
act
,
name
=
conv_name
+
"_left_route"
,
data_format
=
data_format
)
right
=
self
.
conv_bn_layer
(
input
=
right
,
num_filters
=
num_filters
[
block
]
*
2
,
filter_size
=
1
,
act
=
"leaky_relu"
,
act
=
self
.
act
,
name
=
conv_name
+
"_right_route"
,
data_format
=
data_format
)
conv
=
fluid
.
layers
.
concat
([
left
,
right
],
axis
=
1
)
...
...
@@ -117,7 +121,7 @@ class CSPResNet():
num_filters
=
num_filters
[
block
]
*
2
,
filter_size
=
1
,
stride
=
1
,
act
=
"leaky_relu"
,
act
=
self
.
act
,
name
=
conv_name
+
"_merged_transition"
,
data_format
=
data_format
)
...
...
@@ -175,8 +179,17 @@ class CSPResNet():
bn
=
fluid
.
layers
.
relu
(
bn
)
elif
act
==
"leaky_relu"
:
bn
=
fluid
.
layers
.
leaky_relu
(
bn
)
elif
act
==
"mish"
:
bn
=
self
.
_mish
(
bn
)
return
bn
def
_mish
(
self
,
input
):
return
input
*
fluid
.
layers
.
tanh
(
self
.
_softplus
(
input
))
def
_softplus
(
self
,
input
):
expf
=
fluid
.
layers
.
exp
(
fluid
.
layers
.
clip
(
input
,
-
200
,
50
))
return
fluid
.
layers
.
log
(
1
+
expf
)
def
shortcut
(
self
,
input
,
ch_out
,
stride
,
is_first
,
name
,
data_format
):
if
data_format
==
'NCHW'
:
ch_in
=
input
.
shape
[
1
]
...
...
@@ -225,11 +238,21 @@ class CSPResNet():
return
ret
def
CSPResNet50
():
model
=
CSPResNet
(
layers
=
50
)
def
CSPResNet50_leaky
():
model
=
CSPResNet
(
layers
=
50
,
act
=
"leaky_relu"
)
return
model
def
CSPResNet50_mish
():
model
=
CSPResNet
(
layers
=
50
,
act
=
"mish"
)
return
model
def
CSPResNet101_leaky
():
model
=
CSPResNet
(
layers
=
101
,
act
=
"leaky_relu"
)
return
model
def
CSPResNet101
():
model
=
CSPResNet
(
layers
=
101
)
def
CSPResNet101
_mish
():
model
=
CSPResNet
(
layers
=
101
,
act
=
"mish"
)
return
model
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录