Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
39d689e2
P
Paddle
项目概览
BaiXuePrincess
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
39d689e2
编写于
12月 14, 2016
作者:
G
gaoyuan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Format the priorbox code
上级
0eac3992
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
16 addition
and
18 deletion
+16
-18
paddle/gserver/layers/PriorBox.cpp
paddle/gserver/layers/PriorBox.cpp
+16
-18
未找到文件。
paddle/gserver/layers/PriorBox.cpp
浏览文件 @
39d689e2
/* Copyright (c) 2016
Baidu, Inc
. All Rights Reserve.
/* Copyright (c) 2016
PaddlePaddle Authors
. All Rights Reserve.
Licensed under the Apache License, Version 2.0 (the "License");
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
you may not use this file except in compliance with the License.
...
@@ -33,28 +33,28 @@ public:
...
@@ -33,28 +33,28 @@ public:
};
};
bool
PriorBoxLayer
::
init
(
const
LayerMap
&
layerMap
,
bool
PriorBoxLayer
::
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
{
const
ParameterMap
&
parameterMap
)
{
Layer
::
init
(
layerMap
,
parameterMap
);
Layer
::
init
(
layerMap
,
parameterMap
);
std
::
copy
(
config_
.
inputs
(
0
).
priorbox_conf
().
min_size
().
begin
(),
auto
pb_conf
=
config_
.
inputs
(
0
).
priorbox_conf
();
config_
.
inputs
(
0
).
priorbox_conf
().
min_size
().
end
(),
std
::
copy
(
pb_conf
.
min_size
().
begin
(),
pb_conf
.
min_size
().
end
(),
std
::
back_inserter
(
minSize_
));
std
::
back_inserter
(
minSize_
));
std
::
copy
(
config_
.
inputs
(
0
).
priorbox_conf
()
.
max_size
().
begin
(),
std
::
copy
(
pb_conf
.
max_size
().
begin
(),
config_
.
inputs
(
0
).
priorbox_conf
()
.
max_size
().
end
(),
pb_conf
.
max_size
().
end
(),
std
::
back_inserter
(
maxSize_
));
std
::
back_inserter
(
maxSize_
));
std
::
copy
(
config_
.
inputs
(
0
).
priorbox_conf
()
.
aspect_ratio
().
begin
(),
std
::
copy
(
pb_conf
.
aspect_ratio
().
begin
(),
config_
.
inputs
(
0
).
priorbox_conf
()
.
aspect_ratio
().
end
(),
pb_conf
.
aspect_ratio
().
end
(),
std
::
back_inserter
(
aspectRatio_
));
std
::
back_inserter
(
aspectRatio_
));
std
::
copy
(
config_
.
inputs
(
0
).
priorbox_conf
()
.
variance
().
begin
(),
std
::
copy
(
pb_conf
.
variance
().
begin
(),
config_
.
inputs
(
0
).
priorbox_conf
()
.
variance
().
end
(),
pb_conf
.
variance
().
end
(),
std
::
back_inserter
(
variance_
));
std
::
back_inserter
(
variance_
));
// flip
// flip
int
input_ratio_length
=
aspectRatio_
.
size
();
int
input_ratio_length
=
aspectRatio_
.
size
();
for
(
int
index
=
0
;
index
<
input_ratio_length
;
index
++
)
for
(
int
index
=
0
;
index
<
input_ratio_length
;
index
++
)
aspectRatio_
.
push_back
(
1
/
aspectRatio_
[
index
]);
aspectRatio_
.
push_back
(
1
/
aspectRatio_
[
index
]);
aspectRatio_
.
push_back
(
1.
);
aspectRatio_
.
push_back
(
1.
);
numPriors_
=
aspectRatio_
.
size
();
numPriors_
=
aspectRatio_
.
size
();
if
(
maxSize_
.
size
()
>
0
)
if
(
maxSize_
.
size
()
>
0
)
numPriors_
++
;
numPriors_
++
;
buffer_
=
Matrix
::
create
(
1
,
1
,
false
,
false
);
buffer_
=
Matrix
::
create
(
1
,
1
,
false
,
false
);
return
true
;
return
true
;
}
}
...
@@ -79,7 +79,7 @@ void PriorBoxLayer::forward(PassType passType) {
...
@@ -79,7 +79,7 @@ void PriorBoxLayer::forward(PassType passType) {
int
idx
=
0
;
int
idx
=
0
;
for
(
int
h
=
0
;
h
<
layer_height
;
++
h
)
{
for
(
int
h
=
0
;
h
<
layer_height
;
++
h
)
{
for
(
int
w
=
0
;
w
<
layer_width
;
++
w
)
{
for
(
int
w
=
0
;
w
<
layer_width
;
++
w
)
{
float
center_x
=
(
w
+
0.5
)
*
step_w
;
float
center_x
=
(
w
+
0.5
)
*
step_w
;
float
center_y
=
(
h
+
0.5
)
*
step_h
;
float
center_y
=
(
h
+
0.5
)
*
step_h
;
int
min_size
=
0
;
int
min_size
=
0
;
for
(
size_t
s
=
0
;
s
<
minSize_
.
size
();
s
++
)
{
for
(
size_t
s
=
0
;
s
<
minSize_
.
size
();
s
++
)
{
...
@@ -109,8 +109,7 @@ void PriorBoxLayer::forward(PassType passType) {
...
@@ -109,8 +109,7 @@ void PriorBoxLayer::forward(PassType passType) {
// rest of priors.
// rest of priors.
for
(
size_t
r
=
0
;
r
<
aspectRatio_
.
size
();
r
++
)
{
for
(
size_t
r
=
0
;
r
<
aspectRatio_
.
size
();
r
++
)
{
float
ar
=
aspectRatio_
[
r
];
float
ar
=
aspectRatio_
[
r
];
if
(
fabs
(
ar
-
1.
)
<
1e-6
)
if
(
fabs
(
ar
-
1.
)
<
1e-6
)
continue
;
continue
;
float
box_width
=
min_size
*
sqrt
(
ar
);
float
box_width
=
min_size
*
sqrt
(
ar
);
float
box_height
=
min_size
/
sqrt
(
ar
);
float
box_height
=
min_size
/
sqrt
(
ar
);
tmp_ptr
[
idx
++
]
=
(
center_x
-
box_width
/
2.
)
/
image_width
;
tmp_ptr
[
idx
++
]
=
(
center_x
-
box_width
/
2.
)
/
image_width
;
...
@@ -127,8 +126,7 @@ void PriorBoxLayer::forward(PassType passType) {
...
@@ -127,8 +126,7 @@ void PriorBoxLayer::forward(PassType passType) {
for
(
int
h
=
0
;
h
<
layer_height
;
h
++
)
for
(
int
h
=
0
;
h
<
layer_height
;
h
++
)
for
(
int
w
=
0
;
w
<
layer_width
;
w
++
)
for
(
int
w
=
0
;
w
<
layer_width
;
w
++
)
for
(
int
i
=
0
;
i
<
numPriors_
;
i
++
)
for
(
int
i
=
0
;
i
<
numPriors_
;
i
++
)
for
(
int
j
=
0
;
j
<
4
;
j
++
)
for
(
int
j
=
0
;
j
<
4
;
j
++
)
tmp_ptr
[
idx
++
]
=
variance_
[
j
];
tmp_ptr
[
idx
++
]
=
variance_
[
j
];
MatrixPtr
outV
=
getOutputValue
();
MatrixPtr
outV
=
getOutputValue
();
outV
->
copyFrom
(
buffer_
->
data_
,
dim
*
2
);
outV
->
copyFrom
(
buffer_
->
data_
,
dim
*
2
);
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录