Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleDetection
提交
2fefaa1c
P
PaddleDetection
项目概览
PaddlePaddle
/
PaddleDetection
大约 1 年 前同步成功
通知
695
Star
11112
Fork
2696
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
184
列表
看板
标记
里程碑
合并请求
40
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleDetection
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
184
Issue
184
列表
看板
标记
里程碑
合并请求
40
合并请求
40
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
2fefaa1c
编写于
9月 09, 2017
作者:
C
chengduo
提交者:
GitHub
9月 09, 2017
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #3977 from PaddlePaddle/Adaptive_data_structure_for_SwitchOrderLayer
Adaptive data structure for switch order layer
上级
a225bfa3
91a0c11b
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
14 addition
and
4 deletion
+14
-4
paddle/gserver/layers/SwitchOrderLayer.cpp
paddle/gserver/layers/SwitchOrderLayer.cpp
+5
-2
proto/ModelConfig.proto
proto/ModelConfig.proto
+1
-0
python/paddle/trainer_config_helpers/layers.py
python/paddle/trainer_config_helpers/layers.py
+8
-2
未找到文件。
paddle/gserver/layers/SwitchOrderLayer.cpp
浏览文件 @
2fefaa1c
...
@@ -24,10 +24,12 @@ bool SwitchOrderLayer::init(const LayerMap& layerMap,
...
@@ -24,10 +24,12 @@ bool SwitchOrderLayer::init(const LayerMap& layerMap,
/* Initialize the basic parent class */
/* Initialize the basic parent class */
Layer
::
init
(
layerMap
,
parameterMap
);
Layer
::
init
(
layerMap
,
parameterMap
);
auto
&
img_conf
=
config_
.
inputs
(
0
).
image_conf
();
auto
&
img_conf
=
config_
.
inputs
(
0
).
image_conf
();
size_t
inD
=
img_conf
.
img_size_z
();
size_t
inH
=
size_t
inH
=
img_conf
.
has_img_size_y
()
?
img_conf
.
img_size_y
()
:
img_conf
.
img_size
();
img_conf
.
has_img_size_y
()
?
img_conf
.
img_size_y
()
:
img_conf
.
img_size
();
size_t
inW
=
img_conf
.
img_size
();
size_t
inW
=
img_conf
.
img_size
();
size_t
inC
=
img_conf
.
channels
();
size_t
inC
=
img_conf
.
channels
();
inH
=
inH
*
inD
;
inDims_
=
TensorShape
({
0
,
inC
,
inH
,
inW
});
inDims_
=
TensorShape
({
0
,
inC
,
inH
,
inW
});
outDims_
=
TensorShape
(
4
);
outDims_
=
TensorShape
(
4
);
...
@@ -64,9 +66,10 @@ void SwitchOrderLayer::setInDims() {
...
@@ -64,9 +66,10 @@ void SwitchOrderLayer::setInDims() {
MatrixPtr
input
=
inputLayers_
[
0
]
->
getOutputValue
();
MatrixPtr
input
=
inputLayers_
[
0
]
->
getOutputValue
();
size_t
batchSize
=
input
->
getHeight
();
size_t
batchSize
=
input
->
getHeight
();
inDims_
.
setDim
(
0
,
batchSize
);
inDims_
.
setDim
(
0
,
batchSize
);
int
d
=
inputLayers_
[
0
]
->
getOutput
().
getFrameDepth
();
d
=
(
d
==
0
?
1
:
d
);
int
h
=
inputLayers_
[
0
]
->
getOutput
().
getFrameHeight
();
int
h
=
inputLayers_
[
0
]
->
getOutput
().
getFrameHeight
();
if
(
h
!=
0
)
inDims_
.
setDim
(
2
,
h
);
if
(
h
!=
0
)
inDims_
.
setDim
(
2
,
h
*
d
);
int
w
=
inputLayers_
[
0
]
->
getOutput
().
getFrameWidth
();
int
w
=
inputLayers_
[
0
]
->
getOutput
().
getFrameWidth
();
if
(
w
!=
0
)
inDims_
.
setDim
(
3
,
w
);
if
(
w
!=
0
)
inDims_
.
setDim
(
3
,
w
);
int
totalCount
=
input
->
getElementCnt
();
int
totalCount
=
input
->
getElementCnt
();
...
...
proto/ModelConfig.proto
浏览文件 @
2fefaa1c
...
@@ -271,6 +271,7 @@ message ImageConfig {
...
@@ -271,6 +271,7 @@ message ImageConfig {
// The size of input feature map.
// The size of input feature map.
required
uint32
img_size
=
8
;
required
uint32
img_size
=
8
;
optional
uint32
img_size_y
=
9
;
optional
uint32
img_size_y
=
9
;
optional
uint32
img_size_z
=
10
[
default
=
1
];
}
}
message
PriorBoxConfig
{
message
PriorBoxConfig
{
...
...
python/paddle/trainer_config_helpers/layers.py
浏览文件 @
2fefaa1c
...
@@ -6414,7 +6414,7 @@ def gated_unit_layer(input,
...
@@ -6414,7 +6414,7 @@ def gated_unit_layer(input,
@
wrap_name_default
(
'switch_order'
)
@
wrap_name_default
(
'switch_order'
)
def
switch_order_layer
(
input
,
def
switch_order_layer
(
input
,
name
=
None
,
name
=
None
,
reshape
=
None
,
reshape
_axis
=
None
,
act
=
None
,
act
=
None
,
layer_attr
=
None
):
layer_attr
=
None
):
"""
"""
...
@@ -6425,8 +6425,9 @@ def switch_order_layer(input,
...
@@ -6425,8 +6425,9 @@ def switch_order_layer(input,
The example usage is:
The example usage is:
.. code-block:: python
.. code-block:: python
reshape_axis = 3
switch = switch_order(input=layer, name='switch', reshape_axis=reshape_axis)
reshape = {'height':[ 0, 1, 2], 'width':[3]}
reshape = {'height':[ 0, 1, 2], 'width':[3]}
switch = switch_order(input=layer, name='switch', reshape=reshape)
:param input: The input layer.
:param input: The input layer.
:type input: LayerOutput
:type input: LayerOutput
...
@@ -6438,6 +6439,11 @@ def switch_order_layer(input,
...
@@ -6438,6 +6439,11 @@ def switch_order_layer(input,
:rtype: LayerOutput
:rtype: LayerOutput
"""
"""
assert
isinstance
(
input
,
LayerOutput
)
assert
isinstance
(
input
,
LayerOutput
)
assert
reshape_axis
!=
None
and
(
reshape_axis
>
0
and
reshape_axis
<
4
)
height
=
[
ele
for
ele
in
xrange
(
reshape_axis
)]
width
=
[
ele
for
ele
in
range
(
reshape_axis
,
4
)]
reshape
=
{
'height'
:
height
,
'width'
:
width
}
l
=
Layer
(
l
=
Layer
(
name
=
name
,
name
=
name
,
inputs
=
input
.
name
,
inputs
=
input
.
name
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录