Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
s920243400
PaddleDetection
提交
78dc9343
P
PaddleDetection
项目概览
s920243400
/
PaddleDetection
与 Fork 源项目一致
Fork自
PaddlePaddle / PaddleDetection
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleDetection
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
78dc9343
编写于
1月 15, 2018
作者:
C
chengduoZH
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
expose use_cudnn
上级
5ad1aef0
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
34 addition
and
12 deletion
+34
-12
python/paddle/v2/fluid/layers/nn.py
python/paddle/v2/fluid/layers/nn.py
+21
-6
python/paddle/v2/fluid/nets.py
python/paddle/v2/fluid/nets.py
+13
-6
未找到文件。
python/paddle/v2/fluid/layers/nn.py
浏览文件 @
78dc9343
...
...
@@ -660,6 +660,7 @@ def conv2d(input,
groups
=
None
,
param_attr
=
None
,
bias_attr
=
None
,
use_cudnn
=
False
,
act
=
None
):
"""
**Convlution2D Layer**
...
...
@@ -758,6 +759,8 @@ def conv2d(input,
stride
=
[
stride
,
stride
]
if
isinstance
(
padding
,
int
):
padding
=
[
padding
,
padding
]
if
not
isinstance
(
use_cudnn
,
bool
):
raise
ValueError
(
"use_cudnn should be True or False"
)
input_shape
=
input
.
shape
filter_shape
=
[
num_filters
,
num_filter_channels
]
+
filter_size
...
...
@@ -781,9 +784,12 @@ def conv2d(input,
'Filter'
:
filter_param
,
},
outputs
=
{
"Output"
:
pre_bias
},
attrs
=
{
'strides'
:
stride
,
'paddings'
:
padding
,
'groups'
:
groups
})
attrs
=
{
'strides'
:
stride
,
'paddings'
:
padding
,
'groups'
:
groups
,
'use_cudnn'
:
use_cudnn
})
pre_act
=
helper
.
append_bias_op
(
pre_bias
,
dim_start
=
1
,
dim_end
=
2
)
...
...
@@ -931,7 +937,8 @@ def pool2d(input,
pool_type
,
pool_stride
=
None
,
pool_padding
=
None
,
global_pooling
=
False
):
global_pooling
=
False
,
use_cudnn
=
False
):
"""
This function adds the operator for pooling in 2 dimensions, using the
pooling configurations mentioned in input parameters.
...
...
@@ -950,6 +957,8 @@ def pool2d(input,
pool_stride
=
[
pool_stride
,
pool_stride
]
if
isinstance
(
pool_padding
,
int
):
pool_padding
=
[
pool_padding
,
pool_padding
]
if
not
isinstance
(
use_cudnn
,
bool
):
raise
ValueError
(
"use_cudnn should be True or False"
)
helper
=
LayerHelper
(
'pool2d'
,
**
locals
())
dtype
=
helper
.
input_dtype
()
...
...
@@ -964,7 +973,8 @@ def pool2d(input,
"ksize"
:
pool_size
,
"global_pooling"
:
global_pooling
,
"strides"
:
pool_stride
,
"paddings"
:
pool_padding
"paddings"
:
pool_padding
,
"use_cudnn"
:
use_cudnn
})
return
pool_out
...
...
@@ -1077,7 +1087,8 @@ def conv2d_transpose(input,
padding
=
None
,
stride
=
None
,
dilation
=
None
,
param_attr
=
None
):
param_attr
=
None
,
use_cudnn
=
False
):
"""
The transpose of conv2d layer.
...
...
@@ -1132,6 +1143,10 @@ def conv2d_transpose(input,
elif
dilation
is
not
None
:
op_attr
[
'dilations'
]
=
dilation
if
not
isinstance
(
use_cudnn
,
bool
):
raise
ValueError
(
"use_cudnn should be True or False"
)
op_attr
[
'use_cudnn'
]
=
use_cudnn
if
filter_size
is
None
:
if
output_size
is
None
:
raise
ValueError
(
"output_size must be set when filter_size is None"
)
...
...
python/paddle/v2/fluid/nets.py
浏览文件 @
78dc9343
...
...
@@ -13,19 +13,22 @@ def simple_img_conv_pool(input,
pool_stride
,
act
,
param_attr
=
None
,
pool_type
=
'max'
):
pool_type
=
'max'
,
use_cudnn
=
False
):
conv_out
=
layers
.
conv2d
(
input
=
input
,
num_filters
=
num_filters
,
filter_size
=
filter_size
,
param_attr
=
param_attr
,
act
=
act
)
act
=
act
,
use_cudnn
=
use_cudnn
)
pool_out
=
layers
.
pool2d
(
input
=
conv_out
,
pool_size
=
pool_size
,
pool_type
=
pool_type
,
pool_stride
=
pool_stride
)
pool_stride
=
pool_stride
,
use_cudnn
=
use_cudnn
)
return
pool_out
...
...
@@ -38,8 +41,10 @@ def img_conv_group(input,
param_attr
=
None
,
conv_with_batchnorm
=
False
,
conv_batchnorm_drop_rate
=
None
,
conv_use_cudnn
=
False
,
pool_stride
=
1
,
pool_type
=
None
):
pool_type
=
None
,
pool_use_cudnn
=
False
):
"""
Image Convolution Group, Used for vgg net.
"""
...
...
@@ -70,7 +75,8 @@ def img_conv_group(input,
filter_size
=
conv_filter_size
[
i
],
padding
=
conv_padding
[
i
],
param_attr
=
param_attr
[
i
],
act
=
local_conv_act
)
act
=
local_conv_act
,
use_cudnn
=
conv_use_cudnn
)
if
conv_with_batchnorm
[
i
]:
tmp
=
layers
.
batch_norm
(
input
=
tmp
,
act
=
conv_act
)
...
...
@@ -82,7 +88,8 @@ def img_conv_group(input,
input
=
tmp
,
pool_size
=
pool_size
,
pool_type
=
pool_type
,
pool_stride
=
pool_stride
)
pool_stride
=
pool_stride
,
use_cudnn
=
pool_use_cudnn
)
return
pool_out
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录