Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
s920243400
PaddleDetection
提交
f2029298
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看板
提交
f2029298
编写于
12月 21, 2016
作者:
G
gaoyuan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Change type float to real.
上级
6f8f468f
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
38 addition
and
38 deletion
+38
-38
paddle/gserver/layers/PriorBox.cpp
paddle/gserver/layers/PriorBox.cpp
+10
-10
paddle/gserver/tests/test_PriorBox.cpp
paddle/gserver/tests/test_PriorBox.cpp
+28
-28
未找到文件。
paddle/gserver/layers/PriorBox.cpp
浏览文件 @
f2029298
...
@@ -36,8 +36,8 @@ public:
...
@@ -36,8 +36,8 @@ public:
int
numPriors_
;
int
numPriors_
;
std
::
vector
<
int
>
minSize_
;
std
::
vector
<
int
>
minSize_
;
std
::
vector
<
int
>
maxSize_
;
std
::
vector
<
int
>
maxSize_
;
std
::
vector
<
float
>
aspectRatio_
;
std
::
vector
<
real
>
aspectRatio_
;
std
::
vector
<
float
>
variance_
;
std
::
vector
<
real
>
variance_
;
MatrixPtr
buffer_
;
MatrixPtr
buffer_
;
};
};
...
@@ -77,8 +77,8 @@ void PriorBoxLayer::forward(PassType passType) {
...
@@ -77,8 +77,8 @@ void PriorBoxLayer::forward(PassType passType) {
int
imageWidth
=
image
.
getFrameWidth
();
int
imageWidth
=
image
.
getFrameWidth
();
int
imageHeight
=
image
.
getFrameHeight
();
int
imageHeight
=
image
.
getFrameHeight
();
float
stepW
=
static_cast
<
float
>
(
imageWidth
)
/
layerWidth
;
real
stepW
=
static_cast
<
real
>
(
imageWidth
)
/
layerWidth
;
float
stepH
=
static_cast
<
float
>
(
imageHeight
)
/
layerHeight
;
real
stepH
=
static_cast
<
real
>
(
imageHeight
)
/
layerHeight
;
int
dim
=
layerHeight
*
layerWidth
*
numPriors_
*
4
;
int
dim
=
layerHeight
*
layerWidth
*
numPriors_
*
4
;
reserveOutput
(
1
,
dim
*
2
);
reserveOutput
(
1
,
dim
*
2
);
// use a cpu buffer to compute
// use a cpu buffer to compute
...
@@ -88,8 +88,8 @@ void PriorBoxLayer::forward(PassType passType) {
...
@@ -88,8 +88,8 @@ void PriorBoxLayer::forward(PassType passType) {
int
idx
=
0
;
int
idx
=
0
;
for
(
int
h
=
0
;
h
<
layerHeight
;
++
h
)
{
for
(
int
h
=
0
;
h
<
layerHeight
;
++
h
)
{
for
(
int
w
=
0
;
w
<
layerWidth
;
++
w
)
{
for
(
int
w
=
0
;
w
<
layerWidth
;
++
w
)
{
float
centerX
=
(
w
+
0.5
)
*
stepW
;
real
centerX
=
(
w
+
0.5
)
*
stepW
;
float
centerY
=
(
h
+
0.5
)
*
stepH
;
real
centerY
=
(
h
+
0.5
)
*
stepH
;
int
minSize
=
0
;
int
minSize
=
0
;
for
(
size_t
s
=
0
;
s
<
minSize_
.
size
();
s
++
)
{
for
(
size_t
s
=
0
;
s
<
minSize_
.
size
();
s
++
)
{
// first prior.
// first prior.
...
@@ -121,10 +121,10 @@ void PriorBoxLayer::forward(PassType passType) {
...
@@ -121,10 +121,10 @@ 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
];
real
ar
=
aspectRatio_
[
r
];
if
(
fabs
(
ar
-
1.
)
<
1e-6
)
continue
;
if
(
fabs
(
ar
-
1.
)
<
1e-6
)
continue
;
float
boxWidth
=
minSize
*
sqrt
(
ar
);
real
boxWidth
=
minSize
*
sqrt
(
ar
);
float
boxHeight
=
minSize
/
sqrt
(
ar
);
real
boxHeight
=
minSize
/
sqrt
(
ar
);
tmpPtr
[
idx
++
]
=
(
centerX
-
boxWidth
/
2.
)
/
imageWidth
;
tmpPtr
[
idx
++
]
=
(
centerX
-
boxWidth
/
2.
)
/
imageWidth
;
tmpPtr
[
idx
++
]
=
(
centerY
-
boxHeight
/
2.
)
/
imageHeight
;
tmpPtr
[
idx
++
]
=
(
centerY
-
boxHeight
/
2.
)
/
imageHeight
;
tmpPtr
[
idx
++
]
=
(
centerX
+
boxWidth
/
2.
)
/
imageWidth
;
tmpPtr
[
idx
++
]
=
(
centerX
+
boxWidth
/
2.
)
/
imageWidth
;
...
@@ -137,7 +137,7 @@ void PriorBoxLayer::forward(PassType passType) {
...
@@ -137,7 +137,7 @@ void PriorBoxLayer::forward(PassType passType) {
// clip the prior's coordidate such that it is within [0, 1]
// clip the prior's coordidate such that it is within [0, 1]
for
(
int
d
=
0
;
d
<
dim
*
2
;
++
d
)
for
(
int
d
=
0
;
d
<
dim
*
2
;
++
d
)
if
((
d
%
8
)
<
4
)
if
((
d
%
8
)
<
4
)
tmpPtr
[
d
]
=
std
::
min
(
std
::
max
(
tmpPtr
[
d
],
(
float
)
0.
),
(
float
)
1.
);
tmpPtr
[
d
]
=
std
::
min
(
std
::
max
(
tmpPtr
[
d
],
(
real
)
0.
),
(
real
)
1.
);
MatrixPtr
outV
=
getOutputValue
();
MatrixPtr
outV
=
getOutputValue
();
outV
->
copyFrom
(
buffer_
->
data_
,
dim
*
2
);
outV
->
copyFrom
(
buffer_
->
data_
,
dim
*
2
);
}
}
...
...
paddle/gserver/tests/test_PriorBox.cpp
浏览文件 @
f2029298
...
@@ -30,8 +30,8 @@ void doOnePriorBoxTest(size_t feature_map_width,
...
@@ -30,8 +30,8 @@ void doOnePriorBoxTest(size_t feature_map_width,
size_t
image_height
,
size_t
image_height
,
vector
<
int
>
min_size
,
vector
<
int
>
min_size
,
vector
<
int
>
max_size
,
vector
<
int
>
max_size
,
vector
<
float
>
aspect_ratio
,
vector
<
real
>
aspect_ratio
,
vector
<
float
>
variance
,
vector
<
real
>
variance
,
bool
use_gpu
,
bool
use_gpu
,
MatrixPtr
&
result
)
{
MatrixPtr
&
result
)
{
// Setting up the priorbox layer
// Setting up the priorbox layer
...
@@ -71,8 +71,8 @@ void doOnePriorBoxTest(size_t feature_map_width,
...
@@ -71,8 +71,8 @@ void doOnePriorBoxTest(size_t feature_map_width,
TEST
(
Layer
,
priorBoxLayerFwd
)
{
TEST
(
Layer
,
priorBoxLayerFwd
)
{
vector
<
int
>
minSize
;
vector
<
int
>
minSize
;
vector
<
int
>
maxSize
;
vector
<
int
>
maxSize
;
vector
<
float
>
aspectRatio
;
vector
<
real
>
aspectRatio
;
vector
<
float
>
variance
;
vector
<
real
>
variance
;
bool
useGpu
=
false
;
bool
useGpu
=
false
;
minSize
.
push_back
(
276
);
minSize
.
push_back
(
276
);
...
@@ -84,22 +84,22 @@ TEST(Layer, priorBoxLayerFwd) {
...
@@ -84,22 +84,22 @@ TEST(Layer, priorBoxLayerFwd) {
// CPU case 1.
// CPU case 1.
MatrixPtr
result
;
MatrixPtr
result
;
float
resultData
[]
=
{
0.04
,
real
resultData
[]
=
{
0.04
,
0.04
,
0.04
,
0.96
,
0.96
,
0.96
,
0.96
,
0.1
,
0.1
,
0.1
,
0.1
,
0.2
,
0.2
,
0.2
,
0.2
,
0
,
0
,
0
,
0
,
1
,
1
,
1
,
1
,
0.1
,
0.1
,
0.1
,
0.1
,
0.2
,
0.2
,
0.2
};
0.2
};
result
=
Matrix
::
create
(
1
,
2
*
8
,
false
,
useGpu
);
result
=
Matrix
::
create
(
1
,
2
*
8
,
false
,
useGpu
);
result
->
setData
(
resultData
);
result
->
setData
(
resultData
);
doOnePriorBoxTest
(
/* feature_map_width */
1
,
doOnePriorBoxTest
(
/* feature_map_width */
1
,
...
@@ -116,10 +116,10 @@ TEST(Layer, priorBoxLayerFwd) {
...
@@ -116,10 +116,10 @@ TEST(Layer, priorBoxLayerFwd) {
variance
[
1
]
=
0.2
;
variance
[
1
]
=
0.2
;
variance
[
3
]
=
0.1
;
variance
[
3
]
=
0.1
;
maxSize
.
pop_back
();
maxSize
.
pop_back
();
float
resultData2
[]
=
{
0
,
0
,
0.595
,
0.595
,
0.1
,
0.2
,
0.2
,
0.1
,
real
resultData2
[]
=
{
0
,
0
,
0.595
,
0.595
,
0.1
,
0.2
,
0.2
,
0.1
,
0.405
,
0
,
1
,
0.595
,
0.1
,
0.2
,
0.2
,
0.1
,
0.405
,
0
,
1
,
0.595
,
0.1
,
0.2
,
0.2
,
0.1
,
0
,
0.405
,
0.595
,
1
,
0.1
,
0.2
,
0.2
,
0.1
,
0
,
0.405
,
0.595
,
1
,
0.1
,
0.2
,
0.2
,
0.1
,
0.405
,
0.405
,
1
,
1
,
0.1
,
0.2
,
0.2
,
0.1
};
0.405
,
0.405
,
1
,
1
,
0.1
,
0.2
,
0.2
,
0.1
};
Matrix
::
resizeOrCreate
(
result
,
1
,
4
*
8
,
false
,
useGpu
);
Matrix
::
resizeOrCreate
(
result
,
1
,
4
*
8
,
false
,
useGpu
);
result
->
setData
(
resultData2
);
result
->
setData
(
resultData2
);
doOnePriorBoxTest
(
/* feature_map_width */
2
,
doOnePriorBoxTest
(
/* feature_map_width */
2
,
...
@@ -134,10 +134,10 @@ TEST(Layer, priorBoxLayerFwd) {
...
@@ -134,10 +134,10 @@ TEST(Layer, priorBoxLayerFwd) {
result
);
result
);
// CPU case 3.
// CPU case 3.
aspectRatio
.
push_back
(
2
);
aspectRatio
.
push_back
(
2
);
float
resultData3
[]
=
{
0.04
,
0.04
,
0.96
,
0.96
,
0.1
,
0.2
,
real
resultData3
[]
=
{
0.04
,
0.04
,
0.96
,
0.96
,
0.1
,
0.2
,
0.2
,
0.1
,
0
,
0.17473088
,
1
,
0.825269
,
0.2
,
0.1
,
0
,
0.17473088
,
1
,
0.825269
,
0.1
,
0.2
,
0.2
,
0.1
,
0.17473088
,
0
,
0.1
,
0.2
,
0.2
,
0.1
,
0.17473088
,
0
,
0.825269
,
1
,
0.1
,
0.2
,
0.2
,
0.1
};
0.825269
,
1
,
0.1
,
0.2
,
0.2
,
0.1
};
Matrix
::
resizeOrCreate
(
result
,
1
,
3
*
8
,
false
,
useGpu
);
Matrix
::
resizeOrCreate
(
result
,
1
,
3
*
8
,
false
,
useGpu
);
result
->
setData
(
resultData3
);
result
->
setData
(
resultData3
);
doOnePriorBoxTest
(
/* feature_map_width */
1
,
doOnePriorBoxTest
(
/* feature_map_width */
1
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录