Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
01a14e1b
P
Paddle
项目概览
BaiXuePrincess
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
01a14e1b
编写于
11月 18, 2020
作者:
L
LielinJiang
提交者:
GitHub
11月 18, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add with_pool args for vgg (#28684)
* add arg for vgg
上级
532e4bbf
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
28 addition
and
16 deletion
+28
-16
python/paddle/vision/models/resnet.py
python/paddle/vision/models/resnet.py
+1
-1
python/paddle/vision/models/vgg.py
python/paddle/vision/models/vgg.py
+27
-15
未找到文件。
python/paddle/vision/models/resnet.py
浏览文件 @
01a14e1b
...
@@ -245,7 +245,7 @@ class ResNet(nn.Layer):
...
@@ -245,7 +245,7 @@ class ResNet(nn.Layer):
x
=
self
.
layer3
(
x
)
x
=
self
.
layer3
(
x
)
x
=
self
.
layer4
(
x
)
x
=
self
.
layer4
(
x
)
if
self
.
with_pool
>
0
:
if
self
.
with_pool
:
x
=
self
.
avgpool
(
x
)
x
=
self
.
avgpool
(
x
)
if
self
.
num_classes
>
0
:
if
self
.
num_classes
>
0
:
...
...
python/paddle/vision/models/vgg.py
浏览文件 @
01a14e1b
...
@@ -36,9 +36,10 @@ class VGG(nn.Layer):
...
@@ -36,9 +36,10 @@ class VGG(nn.Layer):
`"Very Deep Convolutional Networks For Large-Scale Image Recognition" <https://arxiv.org/pdf/1409.1556.pdf>`_
`"Very Deep Convolutional Networks For Large-Scale Image Recognition" <https://arxiv.org/pdf/1409.1556.pdf>`_
Args:
Args:
features (nn.Layer):
v
gg features create by function make_layers.
features (nn.Layer):
V
gg features create by function make_layers.
num_classes (int):
o
utput dim of last fc layer. If num_classes <=0, last fc layer
num_classes (int):
O
utput dim of last fc layer. If num_classes <=0, last fc layer
will not be defined. Default: 1000.
will not be defined. Default: 1000.
with_pool (bool): Use pool before the last three fc layer or not. Default: True.
Examples:
Examples:
.. code-block:: python
.. code-block:: python
...
@@ -54,24 +55,35 @@ class VGG(nn.Layer):
...
@@ -54,24 +55,35 @@ class VGG(nn.Layer):
"""
"""
def
__init__
(
self
,
features
,
num_classes
=
1000
):
def
__init__
(
self
,
features
,
num_classes
=
1000
,
with_pool
=
True
):
super
(
VGG
,
self
).
__init__
()
super
(
VGG
,
self
).
__init__
()
self
.
features
=
features
self
.
features
=
features
self
.
avgpool
=
nn
.
AdaptiveAvgPool2D
((
7
,
7
))
self
.
num_classes
=
num_classes
self
.
classifier
=
nn
.
Sequential
(
self
.
with_pool
=
with_pool
nn
.
Linear
(
512
*
7
*
7
,
4096
),
nn
.
ReLU
(),
if
with_pool
:
nn
.
Dropout
(),
self
.
avgpool
=
nn
.
AdaptiveAvgPool2D
((
7
,
7
))
nn
.
Linear
(
4096
,
4096
),
nn
.
ReLU
(),
if
num_classes
>
0
:
nn
.
Dropout
(),
self
.
classifier
=
nn
.
Sequential
(
nn
.
Linear
(
4096
,
num_classes
),
)
nn
.
Linear
(
512
*
7
*
7
,
4096
),
nn
.
ReLU
(),
nn
.
Dropout
(),
nn
.
Linear
(
4096
,
4096
),
nn
.
ReLU
(),
nn
.
Dropout
(),
nn
.
Linear
(
4096
,
num_classes
),
)
def
forward
(
self
,
x
):
def
forward
(
self
,
x
):
x
=
self
.
features
(
x
)
x
=
self
.
features
(
x
)
x
=
self
.
avgpool
(
x
)
x
=
paddle
.
flatten
(
x
,
1
)
if
self
.
with_pool
:
x
=
self
.
classifier
(
x
)
x
=
self
.
avgpool
(
x
)
if
self
.
num_classes
>
0
:
x
=
paddle
.
flatten
(
x
,
1
)
x
=
self
.
classifier
(
x
)
return
x
return
x
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录