Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
机器未来
Paddle
提交
09a5b8bd
P
Paddle
项目概览
机器未来
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
09a5b8bd
编写于
11月 30, 2016
作者:
W
wangyang59
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
consolidate img_conv.conf in test_NetworkCompare
上级
0e781718
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
34 addition
and
101 deletion
+34
-101
paddle/gserver/tests/img_conv2_b.conf
paddle/gserver/tests/img_conv2_b.conf
+0
-36
paddle/gserver/tests/img_conv_a.conf
paddle/gserver/tests/img_conv_a.conf
+2
-1
paddle/gserver/tests/img_conv_b.conf
paddle/gserver/tests/img_conv_b.conf
+1
-1
paddle/gserver/tests/img_conv_c.conf
paddle/gserver/tests/img_conv_c.conf
+17
-10
paddle/gserver/tests/test_LayerGrad.cpp
paddle/gserver/tests/test_LayerGrad.cpp
+9
-50
paddle/gserver/tests/test_NetworkCompare.cpp
paddle/gserver/tests/test_NetworkCompare.cpp
+3
-2
python/paddle/trainer/config_parser.py
python/paddle/trainer/config_parser.py
+2
-1
未找到文件。
paddle/gserver/tests/img_conv2_b.conf
已删除
100644 → 0
浏览文件 @
0e781718
#edit-mode: -*- python -*-
# Copyright (c) 2016 Baidu, Inc. All Rights Reserved
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from
paddle
.
trainer_config_helpers
import
*
settings
(
batch_size
=
10
)
data
=
data_layer
(
name
=
"input"
,
size
=
8
*
16
*
16
)
conv
=
img_conv_layer
(
input
=
data
,
filter_size
=
2
,
filter_size_y
=
2
,
num_channels
=
8
,
num_filters
=
16
,
stride
=
1
,
bias_attr
=
True
,
act
=
LinearActivation
(),
layer_type
=
"cudnn_conv"
)
conv2
=
img_conv_layer
(
input
=
data
,
filter_size
=
3
,
filter_size_y
=
3
,
num_channels
=
8
,
num_filters
=
16
,
stride
=
2
,
bias_attr
=
True
,
act
=
LinearActivation
(),
groups
=
2
,
layer_type
=
"cudnn_conv"
)
outputs
(
conv
,
conv2
)
paddle/gserver/tests/img_conv_a.conf
浏览文件 @
09a5b8bd
...
@@ -34,6 +34,7 @@ conv = img_conv_layer(input=data, filter_size=1, filter_size_y=1,
...
@@ -34,6 +34,7 @@ conv = img_conv_layer(input=data, filter_size=1, filter_size_y=1,
num_channels
=
8
,
num_channels
=
8
,
num_filters
=
16
,
stride
=
1
,
num_filters
=
16
,
stride
=
1
,
bias_attr
=
True
,
bias_attr
=
True
,
act
=
LinearActivation
())
act
=
LinearActivation
(),
groups
=
2
)
outputs
(
concat
,
conv
)
outputs
(
concat
,
conv
)
paddle/gserver/tests/img_conv_b.conf
浏览文件 @
09a5b8bd
...
@@ -24,7 +24,7 @@ proj2 = conv_projection(input=data, filter_size=1, filter_size_y=1,
...
@@ -24,7 +24,7 @@ proj2 = conv_projection(input=data, filter_size=1, filter_size_y=1,
concat
=
concat_layer
(
input
=[
proj1
,
proj2
],
bias_attr
=
False
,
act
=
ReluActivation
())
concat
=
concat_layer
(
input
=[
proj1
,
proj2
],
bias_attr
=
False
,
act
=
ReluActivation
())
proj
=
conv_projection
(
input
=
data
,
filter_size
=
1
,
filter_size_y
=
1
,
proj
=
conv_projection
(
input
=
data
,
filter_size
=
1
,
filter_size_y
=
1
,
num_channels
=
8
,
num_filters
=
16
,
stride
=
1
)
num_channels
=
8
,
num_filters
=
16
,
stride
=
1
,
groups
=
2
)
with
mixed_layer
(
bias_attr
=
True
,
act
=
LinearActivation
())
as
conv
:
with
mixed_layer
(
bias_attr
=
True
,
act
=
LinearActivation
())
as
conv
:
conv
+=
proj
conv
+=
proj
...
...
paddle/gserver/tests/img_conv
2_a
.conf
→
paddle/gserver/tests/img_conv
_c
.conf
浏览文件 @
09a5b8bd
...
@@ -17,20 +17,27 @@ from paddle.trainer_config_helpers import *
...
@@ -17,20 +17,27 @@ from paddle.trainer_config_helpers import *
settings
(
batch_size
=
10
)
settings
(
batch_size
=
10
)
data
=
data_layer
(
name
=
"input"
,
size
=
8
*
16
*
16
)
data
=
data_layer
(
name
=
"input"
,
size
=
8
*
16
*
16
)
conv1
=
img_conv_layer
(
input
=
data
,
filter_size
=
1
,
filter_size_y
=
1
,
num_channels
=
8
,
num_filters
=
16
,
stride
=
1
,
bias_attr
=
False
,
act
=
ReluActivation
(),
layer_type
=
"exconv"
)
conv2
=
img_conv_layer
(
input
=
data
,
filter_size
=
1
,
filter_size_y
=
1
,
num_channels
=
8
,
num_filters
=
16
,
stride
=
1
,
bias_attr
=
False
,
act
=
ReluActivation
(),
layer_type
=
"exconv"
)
conv
=
img_conv_layer
(
input
=
data
,
filter_size
=
2
,
filter_size_y
=
2
,
concat
=
concat_layer
(
input
=[
conv1
,
conv2
])
num_channels
=
8
,
num_filters
=
16
,
stride
=
1
,
bias_attr
=
True
,
act
=
LinearActivation
(),
layer_type
=
"exconv"
)
conv
2
=
img_conv_layer
(
input
=
data
,
filter_size
=
3
,
filter_size_y
=
3
,
conv
=
img_conv_layer
(
input
=
data
,
filter_size
=
1
,
filter_size_y
=
1
,
num_channels
=
8
,
num_channels
=
8
,
num_filters
=
16
,
stride
=
2
,
num_filters
=
16
,
stride
=
1
,
bias_attr
=
True
,
bias_attr
=
True
,
act
=
LinearActivation
(),
act
=
LinearActivation
(),
groups
=
2
,
groups
=
2
,
layer_type
=
"exconv"
)
layer_type
=
"exconv"
)
outputs
(
con
v
,
conv2
)
outputs
(
con
cat
,
conv
)
paddle/gserver/tests/test_LayerGrad.cpp
浏览文件 @
09a5b8bd
...
@@ -166,9 +166,8 @@ TEST(Projection, scaling) {
...
@@ -166,9 +166,8 @@ TEST(Projection, scaling) {
}
}
}
}
#ifndef PADDLE_ONLY_CPU
void
testProjectionConv
(
size_t
groups
)
{
TEST
(
Projection
,
conv
)
{
const
int
NUM_FILTERS
=
18
;
const
int
NUM_FILTERS
=
16
;
const
int
FILTER_SIZE
=
2
;
const
int
FILTER_SIZE
=
2
;
const
int
FILTER_SIZE_Y
=
3
;
const
int
FILTER_SIZE_Y
=
3
;
const
int
CHANNELS
=
3
;
const
int
CHANNELS
=
3
;
...
@@ -186,7 +185,7 @@ TEST(Projection, conv) {
...
@@ -186,7 +185,7 @@ TEST(Projection, conv) {
conv
->
set_padding_y
(
1
);
conv
->
set_padding_y
(
1
);
conv
->
set_stride
(
2
);
conv
->
set_stride
(
2
);
conv
->
set_stride_y
(
2
);
conv
->
set_stride_y
(
2
);
conv
->
set_groups
(
1
);
conv
->
set_groups
(
groups
);
conv
->
set_filter_channels
(
conv
->
channels
()
/
conv
->
groups
());
conv
->
set_filter_channels
(
conv
->
channels
()
/
conv
->
groups
());
conv
->
set_img_size
(
IMAGE_SIZE
);
conv
->
set_img_size
(
IMAGE_SIZE
);
int
output_x
=
outputSize
(
conv
->
img_size
(),
int
output_x
=
outputSize
(
conv
->
img_size
(),
...
@@ -206,7 +205,8 @@ TEST(Projection, conv) {
...
@@ -206,7 +205,8 @@ TEST(Projection, conv) {
testProjectionGrad
(
testProjectionGrad
(
conf
,
conf
,
INPUT_DATA
,
INPUT_DATA
,
/* parameterSize */
NUM_FILTERS
*
CHANNELS
*
FILTER_SIZE
*
FILTER_SIZE_Y
,
/* parameterSize */
NUM_FILTERS
*
CHANNELS
*
FILTER_SIZE
*
FILTER_SIZE_Y
/
groups
,
/* batchSize */
100
,
/* batchSize */
100
,
true
,
true
,
false
,
false
,
...
@@ -214,51 +214,10 @@ TEST(Projection, conv) {
...
@@ -214,51 +214,10 @@ TEST(Projection, conv) {
true
);
true
);
}
}
TEST
(
Projection
,
conv2
)
{
#ifndef PADDLE_ONLY_CPU
const
int
NUM_FILTERS
=
18
;
TEST
(
Projection
,
conv
)
{
const
int
FILTER_SIZE
=
2
;
testProjectionConv
(
1
);
const
int
FILTER_SIZE_Y
=
3
;
testProjectionConv
(
3
);
const
int
CHANNELS
=
3
;
const
int
IMAGE_SIZE
=
16
;
ProjectionConfig
conf
;
conf
.
set_type
(
"conv"
);
conf
.
set_num_filters
(
NUM_FILTERS
);
ConvConfig
*
conv
=
conf
.
mutable_conv_conf
();
conv
->
set_filter_size
(
FILTER_SIZE
);
conv
->
set_filter_size_y
(
FILTER_SIZE_Y
);
conv
->
set_channels
(
CHANNELS
);
conv
->
set_padding
(
0
);
conv
->
set_padding_y
(
1
);
conv
->
set_stride
(
2
);
conv
->
set_stride_y
(
2
);
conv
->
set_groups
(
3
);
conv
->
set_filter_channels
(
conv
->
channels
()
/
conv
->
groups
());
conv
->
set_img_size
(
IMAGE_SIZE
);
int
output_x
=
outputSize
(
conv
->
img_size
(),
conv
->
filter_size
(),
conv
->
padding
(),
conv
->
stride
(),
/* caffeMode */
true
);
int
output_y
=
outputSize
(
conv
->
img_size
(),
conv
->
filter_size_y
(),
conv
->
padding_y
(),
conv
->
stride_y
(),
/* caffeMode */
true
);
conv
->
set_output_x
(
output_x
);
conf
.
set_input_size
(
IMAGE_SIZE
*
IMAGE_SIZE
*
CHANNELS
);
conf
.
set_output_size
(
output_x
*
output_y
*
NUM_FILTERS
);
testProjectionGrad
(
conf
,
INPUT_DATA
,
/* parameterSize */
NUM_FILTERS
*
FILTER_SIZE
*
FILTER_SIZE_Y
,
/* batchSize */
100
,
true
,
false
,
NUM_FILTERS
,
true
);
}
}
#endif
#endif
...
...
paddle/gserver/tests/test_NetworkCompare.cpp
浏览文件 @
09a5b8bd
...
@@ -256,9 +256,10 @@ TEST(Compare, img_conv) {
...
@@ -256,9 +256,10 @@ TEST(Compare, img_conv) {
FLAGS_use_gpu
=
useGpu
;
FLAGS_use_gpu
=
useGpu
;
}
}
// Test cudnn_conv and exconv give the same result
TEST
(
Compare
,
img_conv2
)
{
TEST
(
Compare
,
img_conv2
)
{
std
::
string
config_file_a
=
"./gserver/tests/img_conv
2
_a.conf"
;
std
::
string
config_file_a
=
"./gserver/tests/img_conv_a.conf"
;
std
::
string
config_file_b
=
"./gserver/tests/img_conv
2_b
.conf"
;
std
::
string
config_file_b
=
"./gserver/tests/img_conv
_c
.conf"
;
bool
useGpu
=
FLAGS_use_gpu
;
bool
useGpu
=
FLAGS_use_gpu
;
FLAGS_use_gpu
=
true
;
FLAGS_use_gpu
=
true
;
compareNetwork
(
config_file_a
,
config_file_b
);
compareNetwork
(
config_file_a
,
config_file_b
);
...
...
python/paddle/trainer/config_parser.py
浏览文件 @
09a5b8bd
...
@@ -698,7 +698,8 @@ class ConvProjection(Projection):
...
@@ -698,7 +698,8 @@ class ConvProjection(Projection):
ci
=
self
.
proj_conf
.
conv_conf
.
channels
ci
=
self
.
proj_conf
.
conv_conf
.
channels
fh
=
self
.
proj_conf
.
conv_conf
.
filter_size
fh
=
self
.
proj_conf
.
conv_conf
.
filter_size
fw
=
self
.
proj_conf
.
conv_conf
.
filter_size_y
fw
=
self
.
proj_conf
.
conv_conf
.
filter_size_y
return
co
*
ci
*
fh
*
fw
gr
=
self
.
proj_conf
.
conv_conf
.
groups
return
co
*
ci
*
fh
*
fw
/
gr
def
calc_bias_size
(
self
):
def
calc_bias_size
(
self
):
return
self
.
proj_conf
.
num_filters
return
self
.
proj_conf
.
num_filters
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录