Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Crayon鑫
Paddle
提交
86543f7f
P
Paddle
项目概览
Crayon鑫
/
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看板
提交
86543f7f
编写于
7月 04, 2017
作者:
Y
yangyaming
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Follow comments.
上级
3a0919ba
变更
7
显示空白变更内容
内联
并排
Showing
7 changed file
with
164 addition
and
19 deletion
+164
-19
doc/api/v2/config/layer.rst
doc/api/v2/config/layer.rst
+1
-1
paddle/gserver/layers/DetectionOutputLayer.h
paddle/gserver/layers/DetectionOutputLayer.h
+4
-4
paddle/gserver/layers/MultiBoxLossLayer.cpp
paddle/gserver/layers/MultiBoxLossLayer.cpp
+4
-2
paddle/gserver/layers/MultiBoxLossLayer.h
paddle/gserver/layers/MultiBoxLossLayer.h
+1
-1
python/paddle/trainer_config_helpers/layers.py
python/paddle/trainer_config_helpers/layers.py
+9
-11
python/paddle/trainer_config_helpers/tests/configs/protostr/test_detection_output_layer.protostr
...sts/configs/protostr/test_detection_output_layer.protostr
+66
-0
python/paddle/trainer_config_helpers/tests/configs/protostr/test_multibox_loss_layer.protostr
.../tests/configs/protostr/test_multibox_loss_layer.protostr
+79
-0
未找到文件。
doc/api/v2/config/layer.rst
浏览文件 @
86543f7f
...
...
@@ -478,6 +478,6 @@ Detection output Layer
======================
detection_output
---
---
-------------
.. autoclass:: paddle.v2.layer.detection_output
:noindex:
paddle/gserver/layers/DetectionOutputLayer.h
浏览文件 @
86543f7f
...
...
@@ -22,14 +22,14 @@ limitations under the License. */
namespace
paddle
{
/**
* The detection output layer for a SSD detection task. This layer appl
y
the
* Non-maximum suppression to the all predicted bounding box and keep the
* The detection output layer for a SSD detection task. This layer appl
ies
the
* Non-maximum suppression to the all predicted bounding box and keep
s
the
* Top-K bounding boxes.
* - Input: This layer needs three input layers: Th
is
first input layer
* - Input: This layer needs three input layers: Th
e
first input layer
* is the priorbox layer. The rest two input layers are convolution
* layers for generating bbox location offset and the classification
* confidence.
* - Output: The predict bounding box location.
* - Output: The predict bounding box location
s
.
*/
class
DetectionOutputLayer
:
public
Layer
{
...
...
paddle/gserver/layers/MultiBoxLossLayer.cpp
浏览文件 @
86543f7f
...
...
@@ -258,8 +258,7 @@ void MultiBoxLossLayer::forward(PassType passType) {
}
real
loss
=
locLoss_
+
confLoss_
;
MatrixPtr
outV
=
getOutputValue
();
std
::
vector
<
real
>
tmp
(
batchSize
,
loss
);
outV
->
copyFrom
(
&
tmp
[
0
],
batchSize
);
outV
->
assign
(
loss
);
}
void
MultiBoxLossLayer
::
backward
(
const
UpdateCallback
&
callback
)
{
...
...
@@ -336,6 +335,9 @@ void MultiBoxLossLayer::backward(const UpdateCallback& callback) {
const
MatrixPtr
inLocG
=
getInputGrad
(
*
getLocInputLayer
(
n
));
const
MatrixPtr
inConfG
=
getInputGrad
(
*
getConfInputLayer
(
n
));
size_t
height
=
getInput
(
*
getLocInputLayer
(
n
)).
getFrameHeight
();
// only for unittest, there are no width and height information
// when constructing matrix in unittest, so we should
// set the shape in configuration
if
(
!
height
)
height
=
layerConf
.
height
();
size_t
width
=
getInput
(
*
getLocInputLayer
(
n
)).
getFrameWidth
();
if
(
!
width
)
width
=
layerConf
.
width
();
...
...
paddle/gserver/layers/MultiBoxLossLayer.h
浏览文件 @
86543f7f
...
...
@@ -30,7 +30,7 @@ namespace paddle {
* The loss is composed by the location loss and the confidence loss.
* The location loss is a smooth L1 loss and the confidence loss is
* a softmax loss.
* - Input: This layer need
four input layers: This
first input layer
* - Input: This layer need
s four input layers: The
first input layer
* is the priorbox layer and the second layer is a label layer.
* The rest two input layers are convolution layers for generating
* bbox location offset and the classification confidence.
...
...
python/paddle/trainer_config_helpers/layers.py
浏览文件 @
86543f7f
...
...
@@ -1072,10 +1072,10 @@ def multibox_loss_layer(input_loc,
:param name: The Layer Name.
:type name: basestring
:param input_loc: The input predict location.
:type input_loc: LayerOutput
:param input_loc: The input predict location
s
.
:type input_loc: LayerOutput
| List of LayerOutput
:param input_conf: The input priorbox confidence.
:type input_conf: LayerOutput
:type input_conf: LayerOutput
| List of LayerOutput
:param priorbox: The input priorbox location and the variance.
:type priorbox: LayerOutput
:param label: The input label.
...
...
@@ -1146,10 +1146,10 @@ def detection_output_layer(input_loc,
:param name: The Layer Name.
:type name: basestring
:param input_loc: The input predict location.
:type input_loc: LayerOutput
:param input_loc: The input predict location
s
.
:type input_loc: LayerOutput
| List of LayerOutput.
:param input_conf: The input priorbox confidence.
:type input_conf: LayerOutput
:type input_conf: LayerOutput
| List of LayerOutput.
:param priorbox: The input priorbox location and the variance.
:type priorbox: LayerOutput
:param num_classes: The number of the classification.
...
...
@@ -1166,22 +1166,20 @@ def detection_output_layer(input_loc,
:type background_id: int
:return: LayerOutput
"""
input_loc_num
=
0
input_conf_num
=
0
if
isinstance
(
input_loc
,
LayerOutput
):
input_loc
=
[
input_loc
]
assert
isinstance
(
input_loc
,
collections
.
Sequence
)
# list or tuple
for
each
in
input_loc
:
assert
isinstance
(
each
,
LayerOutput
)
input_loc_num
+=
1
input_loc_num
=
len
(
input_loc
)
if
isinstance
(
input_conf
,
LayerOutput
):
input_conf
=
[
input_conf
]
assert
isinstance
(
input_conf
,
collections
.
Sequence
)
# list or tuple
for
each
in
input_conf
:
assert
isinstance
(
each
,
LayerOutput
)
input_conf_num
+=
1
input_conf_num
=
len
(
input_conf
)
# Check the input layer number.
assert
input_loc_num
==
input_conf_num
...
...
python/paddle/trainer_config_helpers/tests/configs/protostr/test_detection_output_layer.protostr
0 → 100644
浏览文件 @
86543f7f
type: "nn"
layers {
name: "input_loc"
type: "data"
size: 16
active_type: ""
height: 16
width: 1
}
layers {
name: "input_conf"
type: "data"
size: 8
active_type: ""
height: 1
width: 8
}
layers {
name: "priorbox"
type: "data"
size: 32
active_type: ""
height: 4
width: 8
}
layers {
name: "test_detection_output"
type: "detection_output"
size: 1400
active_type: ""
inputs {
input_layer_name: "priorbox"
detection_output_conf {
num_classes: 21
nms_threshold: 0.45
nms_top_k: 400
background_id: 0
input_num: 1
keep_top_k: 200
confidence_threshold: 0.01
}
}
inputs {
input_layer_name: "input_loc"
}
inputs {
input_layer_name: "input_conf"
}
}
input_layer_names: "priorbox"
input_layer_names: "input_loc"
input_layer_names: "input_conf"
output_layer_names: "test_detection_output"
sub_models {
name: "root"
layer_names: "input_loc"
layer_names: "input_conf"
layer_names: "priorbox"
layer_names: "test_detection_output"
input_layer_names: "priorbox"
input_layer_names: "input_loc"
input_layer_names: "input_conf"
output_layer_names: "test_detection_output"
is_recurrent_layer_group: false
}
python/paddle/trainer_config_helpers/tests/configs/protostr/test_multibox_loss_layer.protostr
0 → 100644
浏览文件 @
86543f7f
type: "nn"
layers {
name: "input_loc"
type: "data"
size: 16
active_type: ""
height: 16
width: 1
}
layers {
name: "input_conf"
type: "data"
size: 8
active_type: ""
height: 1
width: 8
}
layers {
name: "priorbox"
type: "data"
size: 32
active_type: ""
height: 4
width: 8
}
layers {
name: "label"
type: "data"
size: 24
active_type: ""
height: 4
width: 6
}
layers {
name: "test_multibox_loss"
type: "multibox_loss"
size: 1
active_type: ""
inputs {
input_layer_name: "priorbox"
multibox_loss_conf {
num_classes: 21
overlap_threshold: 0.5
neg_pos_ratio: 3.0
neg_overlap: 0.5
background_id: 0
input_num: 1
}
}
inputs {
input_layer_name: "label"
}
inputs {
input_layer_name: "input_loc"
}
inputs {
input_layer_name: "input_conf"
}
}
input_layer_names: "priorbox"
input_layer_names: "label"
input_layer_names: "input_loc"
input_layer_names: "input_conf"
output_layer_names: "test_multibox_loss"
sub_models {
name: "root"
layer_names: "input_loc"
layer_names: "input_conf"
layer_names: "priorbox"
layer_names: "label"
layer_names: "test_multibox_loss"
input_layer_names: "priorbox"
input_layer_names: "label"
input_layer_names: "input_loc"
input_layer_names: "input_conf"
output_layer_names: "test_multibox_loss"
is_recurrent_layer_group: false
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录