Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
s920243400
PaddleDetection
提交
5d98b6f2
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看板
提交
5d98b6f2
编写于
8月 21, 2017
作者:
C
chengduoZH
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Adapting to the BatchNorm structure to support 3D data
上级
0f3a3e98
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
75 addition
and
4 deletion
+75
-4
paddle/gserver/layers/BatchNormBaseLayer.cpp
paddle/gserver/layers/BatchNormBaseLayer.cpp
+5
-1
paddle/gserver/layers/BatchNormBaseLayer.h
paddle/gserver/layers/BatchNormBaseLayer.h
+1
-0
paddle/gserver/tests/test_LayerGrad.cpp
paddle/gserver/tests/test_LayerGrad.cpp
+49
-0
paddle/parameter/Argument.cpp
paddle/parameter/Argument.cpp
+2
-0
paddle/parameter/Argument.h
paddle/parameter/Argument.h
+5
-3
proto/ModelConfig.proto
proto/ModelConfig.proto
+13
-0
未找到文件。
paddle/gserver/layers/BatchNormBaseLayer.cpp
浏览文件 @
5d98b6f2
...
...
@@ -62,14 +62,18 @@ void BatchNormBaseLayer::calFeatureMapSize() {
const
ImageConfig
&
conf
=
config_
.
inputs
(
0
).
image_conf
();
imageH_
=
inputLayers_
[
0
]
->
getOutput
().
getFrameHeight
();
imageW_
=
inputLayers_
[
0
]
->
getOutput
().
getFrameWidth
();
imageD_
=
inputLayers_
[
0
]
->
getOutput
().
getFrameDepth
();
if
(
0
==
imageD_
)
imageD_
=
conf
.
img_size_z
();
if
(
imageH_
==
0
&&
imageW_
==
0
)
{
imageH_
=
conf
.
has_img_size_y
()
?
conf
.
img_size_y
()
:
conf
.
img_size
();
imageW_
=
conf
.
img_size
();
}
else
{
getOutput
().
setFrameHeight
(
imageH_
);
getOutput
().
setFrameWidth
(
imageW_
);
getOutput
().
setFrameDepth
(
imageD_
);
}
imgPixels_
=
imageH_
*
imageW_
;
imgPixels_
=
imageH_
*
imageW_
*
imageD_
;
}
}
// namespace paddle
paddle/gserver/layers/BatchNormBaseLayer.h
浏览文件 @
5d98b6f2
...
...
@@ -80,6 +80,7 @@ protected:
/// Height or width of input image feature.
/// Both of them are 1 if the input is fully-connected layer.
int
imageD_
;
int
imageH_
;
int
imageW_
;
/// Height * Width.
...
...
paddle/gserver/tests/test_LayerGrad.cpp
浏览文件 @
5d98b6f2
...
...
@@ -1594,6 +1594,55 @@ TEST(Layer, BatchNormalizationLayer) {
#endif
}
void
testBatchNorm3DLayer
(
const
string
&
type
,
bool
trans
,
bool
useGpu
)
{
TestConfig
config
;
const
int
CHANNELS
=
10
;
const
int
IMG_SIZE
=
16
;
const
int
IMG_SIZE_Y
=
8
;
const
int
IMG_SIZE_Z
=
8
;
size_t
size
=
CHANNELS
*
IMG_SIZE
*
IMG_SIZE_Y
*
IMG_SIZE_Z
;
config
.
layerConfig
.
set_type
(
type
);
config
.
layerConfig
.
set_size
(
size
);
config
.
layerConfig
.
set_active_type
(
"sigmoid"
);
config
.
biasSize
=
CHANNELS
;
config
.
inputDefs
.
push_back
({
INPUT_DATA
,
"layer_0"
,
/* dim= */
size
,
/* paraSize= */
CHANNELS
});
config
.
inputDefs
.
push_back
({
INPUT_DATA
,
"layer_1_running_mean"
,
1
,
CHANNELS
});
config
.
inputDefs
.
back
().
isStatic
=
true
;
config
.
inputDefs
.
push_back
({
INPUT_DATA
,
"layer_2_running_var"
,
1
,
CHANNELS
});
config
.
inputDefs
.
back
().
isStatic
=
true
;
LayerInputConfig
*
input
=
config
.
layerConfig
.
add_inputs
();
config
.
layerConfig
.
add_inputs
();
config
.
layerConfig
.
add_inputs
();
ImageConfig
*
img_conf
=
input
->
mutable_image_conf
();
img_conf
->
set_channels
(
CHANNELS
);
img_conf
->
set_img_size
(
IMG_SIZE
);
img_conf
->
set_img_size_y
(
IMG_SIZE_Y
);
img_conf
->
set_img_size_z
(
IMG_SIZE_Z
);
testLayerGrad
(
config
,
"batch_norm"
,
64
,
/* trans= */
trans
,
useGpu
,
/* useWeight */
true
);
}
TEST
(
Layer
,
testBatchNorm3DLayer
)
{
testBatchNorm3DLayer
(
"batch_norm"
,
false
,
false
);
#ifndef PADDLE_ONLY_CPU
testBatchNorm3DLayer
(
"batch_norm"
,
false
,
true
);
if
(
hl_get_cudnn_lib_version
()
>=
int
(
4000
))
{
testBatchNorm3DLayer
(
"cudnn_batch_norm"
,
false
,
true
);
}
#endif
}
void
testConvOperator
(
bool
isDeconv
)
{
TestConfig
config
;
const
int
NUM_FILTERS
=
16
;
...
...
paddle/parameter/Argument.cpp
浏览文件 @
5d98b6f2
...
...
@@ -186,6 +186,7 @@ void Argument::resizeAndCopyFrom(const Argument& src,
resizeAndCopy
(
strs
,
src
.
strs
,
useGpu
,
stream
);
frameWidth
=
src
.
frameWidth
;
frameHeight
=
src
.
frameHeight
;
frameDepth
=
src
.
frameDepth
;
}
int32_t
Argument
::
resizeAndCopyFrom
(
const
Argument
&
src
,
...
...
@@ -206,6 +207,7 @@ int32_t Argument::resizeAndCopyFrom(const Argument& src,
dataId
=
src
.
dataId
;
frameWidth
=
src
.
frameWidth
;
frameHeight
=
src
.
frameHeight
;
frameDepth
=
src
.
frameDepth
;
if
(
!
src
.
sequenceStartPositions
)
{
// non-sequence input, copy samples directly
...
...
paddle/parameter/Argument.h
浏览文件 @
5d98b6f2
/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve.
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.
...
...
@@ -35,6 +32,7 @@ struct Argument {
strs
(
nullptr
),
frameHeight
(
0
),
frameWidth
(
0
),
frameDepth
(
0
),
sequenceStartPositions
(
nullptr
),
subSequenceStartPositions
(
nullptr
),
cpuSequenceDims
(
nullptr
),
...
...
@@ -64,6 +62,7 @@ struct Argument {
allCount
=
argument
.
allCount
;
frameHeight
=
argument
.
frameHeight
;
frameWidth
=
argument
.
frameWidth
;
frameDepth
=
argument
.
frameDepth
;
dataId
=
argument
.
dataId
;
}
...
...
@@ -76,6 +75,7 @@ struct Argument {
// A dataBatch includes batchSize frames, one frame maybe not only vector
size_t
frameHeight
;
size_t
frameWidth
;
size_t
frameDepth
;
// If NULL, each position is treated independently.
// Otherwise, its size should be #NumberOfSequences + 1.
...
...
@@ -136,8 +136,10 @@ struct Argument {
}
size_t
getFrameHeight
()
const
{
return
frameHeight
;
}
size_t
getFrameWidth
()
const
{
return
frameWidth
;
}
size_t
getFrameDepth
()
const
{
return
frameDepth
;
}
void
setFrameHeight
(
size_t
h
)
{
frameHeight
=
h
;
}
void
setFrameWidth
(
size_t
w
)
{
frameWidth
=
w
;
}
void
setFrameDepth
(
size_t
d
)
{
frameDepth
=
d
;
}
int64_t
getNumSequences
()
const
{
return
sequenceStartPositions
?
sequenceStartPositions
->
getSize
()
-
1
...
...
proto/ModelConfig.proto
浏览文件 @
5d98b6f2
...
...
@@ -82,6 +82,12 @@ message ConvConfig {
// if not set, use img_size
optional
uint32
img_size_y
=
14
;
optional
uint32
filter_size_z
=
15
[
default
=
1
];
optional
uint32
padding_z
=
16
[
default
=
1
];
optional
uint32
stride_z
=
17
[
default
=
1
];
optional
uint32
output_z
=
18
[
default
=
1
];
optional
uint32
img_size_z
=
19
[
default
=
1
];
}
message
PoolConfig
{
...
...
@@ -124,6 +130,12 @@ message PoolConfig {
// if not set, use padding
optional
uint32
padding_y
=
13
;
optional
uint32
size_z
=
14
[
default
=
1
];
optional
uint32
stride_z
=
15
[
default
=
1
];
optional
uint32
output_z
=
16
[
default
=
1
];
optional
uint32
img_size_z
=
17
[
default
=
1
];
optional
uint32
padding_z
=
18
[
default
=
1
];
}
message
SppConfig
{
...
...
@@ -256,6 +268,7 @@ message ImageConfig {
// The size of input feature map.
required
uint32
img_size
=
8
;
optional
uint32
img_size_y
=
9
;
optional
uint32
img_size_z
=
10
[
default
=
1
];
}
message
PriorBoxConfig
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录