Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
af7a50c0
P
Paddle
项目概览
PaddlePaddle
/
Paddle
1 年多 前同步成功
通知
2302
Star
20931
Fork
5422
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1423
列表
看板
标记
里程碑
合并请求
543
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1,423
Issue
1,423
列表
看板
标记
里程碑
合并请求
543
合并请求
543
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
af7a50c0
编写于
11月 09, 2016
作者:
W
wangyang59
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
minor changes on deconv implementation and add protostr test for deconv layer
上级
44912099
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
43 addition
and
22 deletion
+43
-22
paddle/gserver/layers/ExpandConvLayer.cpp
paddle/gserver/layers/ExpandConvLayer.cpp
+1
-4
paddle/gserver/layers/ExpandConvTransLayer.cpp
paddle/gserver/layers/ExpandConvTransLayer.cpp
+0
-2
paddle/gserver/layers/ExpandConvTransLayer.h
paddle/gserver/layers/ExpandConvTransLayer.h
+1
-1
paddle/math/MathUtils.h
paddle/math/MathUtils.h
+4
-0
python/paddle/trainer/config_parser.py
python/paddle/trainer/config_parser.py
+14
-14
python/paddle/trainer_config_helpers/tests/configs/generate_protostr.sh
...trainer_config_helpers/tests/configs/generate_protostr.sh
+1
-1
python/paddle/trainer_config_helpers/tests/configs/img_trans_layers.py
.../trainer_config_helpers/tests/configs/img_trans_layers.py
+22
-0
未找到文件。
paddle/gserver/layers/ExpandConvLayer.cpp
浏览文件 @
af7a50c0
...
...
@@ -32,10 +32,7 @@ void ExpandConvLayer::forward(PassType passType) {
Layer
::
forward
(
passType
);
/* malloc memory for the output_ if necessary */
/* note: one sample correspond to one colum, and the
* transOutValue correspond sample to one row */
int
batchSize
=
inputLayers_
[
0
]
->
getOutputValue
()
->
getWidth
();
batchSize
=
inputLayers_
[
0
]
->
getOutputValue
()
->
getHeight
();
int
batchSize
=
inputLayers_
[
0
]
->
getOutputValue
()
->
getHeight
();
resetOutput
(
batchSize
,
getOutputSize
());
MatrixPtr
image
=
nullptr
;
...
...
paddle/gserver/layers/ExpandConvTransLayer.cpp
浏览文件 @
af7a50c0
...
...
@@ -38,8 +38,6 @@ void ExpandConvTransLayer::forward(PassType passType) {
Layer
::
forward
(
passType
);
/* malloc memory for the output_ if necessary */
/* note: one sample correspond to one colum, and the
* transOutValue correspond sample to one row */
int
batchSize
=
inputLayers_
[
0
]
->
getOutputValue
()
->
getHeight
();
resetOutput
(
batchSize
,
getOutputSize
());
...
...
paddle/gserver/layers/ExpandConvTransLayer.h
浏览文件 @
af7a50c0
...
...
@@ -26,7 +26,7 @@ namespace paddle {
* This layer expands input and use matrix multiplication to
* calculate convolution transpose (deconv) operation.
*
* The config file api is img_conv
Trans_layer
.
* The config file api is img_conv
_layer with flag trans=True
.
*/
class
ExpandConvTransLayer
:
public
ExpandConvBaseLayer
{
public:
...
...
paddle/math/MathUtils.h
浏览文件 @
af7a50c0
...
...
@@ -60,6 +60,10 @@ void sparseRand(int* major, int* minor, int nnz, int majorLen, int minorMax,
int
outputSize
(
int
imageSize
,
int
filterSize
,
int
padding
,
int
stride
,
bool
caffeMode
);
/**
* Calculate image size based on output size and caffeMode_.
* It is the reverse function of outputSize()
*/
int
imageSize
(
int
outputSize
,
int
filterSize
,
int
padding
,
int
stride
,
bool
caffeMode
);
...
...
python/paddle/trainer/config_parser.py
浏览文件 @
af7a50c0
...
...
@@ -1017,6 +1017,17 @@ def cnn_output_size(img_size, filter_size, padding, stride, caffe_mode):
else
:
return
1
+
int
(
math
.
ceil
(
output
))
'''
calcualte image_size based on output_size for convolution.
It is the reverse function of cnn_output_size
'''
def
cnn_image_size
(
output_size
,
filter_size
,
padding
,
stride
,
caffe_mode
):
if
caffe_mode
:
img_size
=
(
output_size
-
1
)
*
stride
+
filter_size
-
2
*
padding
else
:
img_size
=
(
output_size
-
2
)
*
stride
+
filter_size
-
2
*
padding
+
1
return
img_size
def
parse_pool
(
pool
,
input_layer_name
,
pool_conf
):
pool_conf
.
pool_type
=
pool
.
pool_type
config_assert
(
pool
.
pool_type
in
[
'max-projection'
,
'avg-projection'
,
...
...
@@ -1120,14 +1131,9 @@ def parse_conv(conv, input_layer_name, conv_conf, trans=False):
(
"Input layer %s: Incorrect input image size %d for input "
+
"image pixels %d"
)
%
(
input_layer_name
,
conv_conf
.
output_x
,
outputSize
))
if
conv
.
caffe_mode
:
conv_conf
.
img_size
=
\
(
conv_conf
.
output_x
-
1
)
*
conv
.
stride
\
+
conv
.
filter_size
-
2
*
conv
.
padding
else
:
conv_conf
.
img_size
=
\
(
conv_conf
.
output_x
-
2
)
*
conv
.
stride
\
+
conv
.
filter_size
-
2
*
conv
.
padding
+
1
conv_conf
.
img_size
=
cnn_image_size
(
conv_conf
.
output_x
,
conv_conf
.
filter_size
,
conv_conf
.
padding
,
conv_conf
.
stride
,
conv_conf
.
caffe_mode
)
def
parse_block_expand
(
block_expand
,
input_layer_name
,
block_expand_conf
):
block_expand_conf
.
channels
=
block_expand
.
channels
...
...
@@ -1656,12 +1662,6 @@ class ConvTransLayerBase(LayerBase):
use_gpu
=
int
(
g_command_config_args
.
get
(
"use_gpu"
,
0
))
parallel_nn
=
int
(
g_command_config_args
.
get
(
"parallel_nn"
,
0
))
# Automatically select cudnn_type for GPU and exconv for CPU
# if set type=conv, but still reserve the way user specify
# exconv or cudnn_conv manually.
if
self
.
layer_type
==
"cudnn_convt"
:
config_assert
(
use_gpu
,
"cudnn_convt only support GPU"
)
# cudnn_convt has not been implemented so use exconvt only
self
.
layer_type
=
"exconvt"
# need to specify layer in config
...
...
python/paddle/trainer_config_helpers/tests/configs/generate_protostr.sh
浏览文件 @
af7a50c0
...
...
@@ -9,7 +9,7 @@ protostr=$PWD/protostr
configs
=(
test_fc layer_activations projections test_print_layer
test_sequence_pooling test_lstmemory_layer test_grumemory_layer
last_first_seq test_expand_layer test_ntm_layers test_hsigmoid
img_layers util_layers simple_rnn_layers unused_layers test_cost_layers
img_layers
img_trans_layers
util_layers simple_rnn_layers unused_layers test_cost_layers
test_rnn_group shared_fc shared_lstm test_cost_layers_with_weight
test_maxout test_bi_grumemory math_ops
)
...
...
python/paddle/trainer_config_helpers/tests/configs/img_trans_layers.py
0 → 100644
浏览文件 @
af7a50c0
from
paddle.trainer_config_helpers
import
*
settings
(
learning_rate
=
1e-3
,
batch_size
=
1000
)
img
=
data_layer
(
name
=
'image'
,
size
=
227
*
227
)
# the parse_conv in config_parse.py is not strictly accurate when filter_size
# is not square. So here set square filter_size.
img_conv
=
img_conv_layer
(
input
=
img
,
num_channels
=
1
,
num_filters
=
64
,
filter_size
=
(
32
,
32
),
padding
=
(
1
,
1
),
stride
=
(
1
,
1
),
act
=
LinearActivation
(),
trans
=
True
)
img_bn
=
batch_norm_layer
(
input
=
img_conv
,
act
=
ReluActivation
())
img_norm
=
img_cmrnorm_layer
(
input
=
img_bn
,
size
=
32
)
img_pool
=
img_pool_layer
(
input
=
img_conv
,
pool_size
=
32
,
pool_type
=
MaxPooling
())
outputs
(
img_pool
,
img_norm
)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录