Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleClas
提交
515c9c99
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看板
提交
515c9c99
编写于
9月 13, 2020
作者:
littletomatodonkey
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix mv1
上级
de4ebabf
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
17 addition
and
20 deletion
+17
-20
ppcls/modeling/architectures/alexnet.py
ppcls/modeling/architectures/alexnet.py
+2
-2
ppcls/modeling/architectures/mobilenet_v1.py
ppcls/modeling/architectures/mobilenet_v1.py
+15
-18
未找到文件。
ppcls/modeling/architectures/alexnet.py
浏览文件 @
515c9c99
...
...
@@ -11,7 +11,7 @@ __all__ = ["AlexNet"]
class
ConvPoolLayer
(
nn
.
Layer
):
def
__init__
(
self
,
input
c
_channels
,
input_channels
,
output_channels
,
filter_size
,
stride
,
...
...
@@ -25,7 +25,7 @@ class ConvPoolLayer(nn.Layer):
self
.
relu
=
ReLU
()
if
act
==
"relu"
else
None
self
.
_conv
=
Conv2d
(
in_channels
=
input
c
_channels
,
in_channels
=
input_channels
,
out_channels
=
output_channels
,
kernel_size
=
filter_size
,
stride
=
stride
,
...
...
ppcls/modeling/architectures/mobilenet_v1.py
浏览文件 @
515c9c99
...
...
@@ -18,10 +18,11 @@ from __future__ import print_function
import
numpy
as
np
import
paddle
import
paddle.fluid
as
fluid
from
paddle.fluid.param_attr
import
ParamAttr
from
paddle.fluid.dygraph.nn
import
Conv2D
,
Pool2D
,
BatchNorm
,
Linear
,
Dropout
from
paddle.fluid.initializer
import
MSRA
from
paddle
import
ParamAttr
import
paddle.nn
as
nn
import
paddle.nn.functional
as
F
from
paddle.nn
import
Conv2d
,
Pool2D
,
BatchNorm
,
Linear
,
Dropout
from
paddle.nn.initializer
import
MSRA
import
math
__all__
=
[
...
...
@@ -29,7 +30,7 @@ __all__ = [
]
class
ConvBNLayer
(
fluid
.
dygraph
.
Layer
):
class
ConvBNLayer
(
nn
.
Layer
):
def
__init__
(
self
,
num_channels
,
filter_size
,
...
...
@@ -39,20 +40,17 @@ class ConvBNLayer(fluid.dygraph.Layer):
channels
=
None
,
num_groups
=
1
,
act
=
'relu'
,
use_cudnn
=
True
,
name
=
None
):
super
(
ConvBNLayer
,
self
).
__init__
()
self
.
_conv
=
Conv2
D
(
num
_channels
=
num_channels
,
num_filter
s
=
num_filters
,
filter
_size
=
filter_size
,
self
.
_conv
=
Conv2
d
(
in
_channels
=
num_channels
,
out_channel
s
=
num_filters
,
kernel
_size
=
filter_size
,
stride
=
stride
,
padding
=
padding
,
groups
=
num_groups
,
act
=
None
,
use_cudnn
=
use_cudnn
,
param_attr
=
ParamAttr
(
weight_attr
=
ParamAttr
(
initializer
=
MSRA
(),
name
=
name
+
"_weights"
),
bias_attr
=
False
)
...
...
@@ -70,7 +68,7 @@ class ConvBNLayer(fluid.dygraph.Layer):
return
y
class
DepthwiseSeparable
(
fluid
.
dygraph
.
Layer
):
class
DepthwiseSeparable
(
nn
.
Layer
):
def
__init__
(
self
,
num_channels
,
num_filters1
,
...
...
@@ -88,7 +86,6 @@ class DepthwiseSeparable(fluid.dygraph.Layer):
stride
=
stride
,
padding
=
1
,
num_groups
=
int
(
num_groups
*
scale
),
use_cudnn
=
False
,
name
=
name
+
"_dw"
)
self
.
_pointwise_conv
=
ConvBNLayer
(
...
...
@@ -105,7 +102,7 @@ class DepthwiseSeparable(fluid.dygraph.Layer):
return
y
class
MobileNet
(
fluid
.
dygraph
.
Layer
):
class
MobileNet
(
nn
.
Layer
):
def
__init__
(
self
,
scale
=
1.0
,
class_dim
=
1000
):
super
(
MobileNet
,
self
).
__init__
()
self
.
scale
=
scale
...
...
@@ -234,7 +231,7 @@ class MobileNet(fluid.dygraph.Layer):
self
.
out
=
Linear
(
int
(
1024
*
scale
),
class_dim
,
param
_attr
=
ParamAttr
(
weight
_attr
=
ParamAttr
(
initializer
=
MSRA
(),
name
=
"fc7_weights"
),
bias_attr
=
ParamAttr
(
name
=
"fc7_offset"
))
...
...
@@ -243,7 +240,7 @@ class MobileNet(fluid.dygraph.Layer):
for
block
in
self
.
block_list
:
y
=
block
(
y
)
y
=
self
.
pool2d_avg
(
y
)
y
=
fluid
.
layers
.
reshape
(
y
,
shape
=
[
-
1
,
int
(
1024
*
self
.
scale
)])
y
=
paddle
.
reshape
(
y
,
shape
=
[
-
1
,
int
(
1024
*
self
.
scale
)])
y
=
self
.
out
(
y
)
return
y
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录