Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
871b0e68
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2298
Star
20931
Fork
5422
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1423
列表
看板
标记
里程碑
合并请求
543
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1,423
Issue
1,423
列表
看板
标记
里程碑
合并请求
543
合并请求
543
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
871b0e68
编写于
1月 20, 2018
作者:
W
wangmeng28
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Simplify priorbox layer
上级
e22039f8
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
19 addition
and
25 deletion
+19
-25
paddle/gserver/layers/PriorBox.cpp
paddle/gserver/layers/PriorBox.cpp
+19
-25
未找到文件。
paddle/gserver/layers/PriorBox.cpp
浏览文件 @
871b0e68
...
@@ -65,6 +65,9 @@ bool PriorBoxLayer::init(const LayerMap& layerMap,
...
@@ -65,6 +65,9 @@ bool PriorBoxLayer::init(const LayerMap& layerMap,
std
::
copy
(
pbConf
.
aspect_ratio
().
begin
(),
std
::
copy
(
pbConf
.
aspect_ratio
().
begin
(),
pbConf
.
aspect_ratio
().
end
(),
pbConf
.
aspect_ratio
().
end
(),
std
::
back_inserter
(
tmp
));
std
::
back_inserter
(
tmp
));
if
(
maxSize_
.
size
()
>
0
)
CHECK_EQ
(
minSize_
.
size
(),
maxSize_
.
size
());
// flip aspect ratios
// flip aspect ratios
for
(
int
index
=
0
;
index
<
tmp
.
size
();
index
++
)
{
for
(
int
index
=
0
;
index
<
tmp
.
size
();
index
++
)
{
real
ar
=
tmp
[
index
];
real
ar
=
tmp
[
index
];
...
@@ -72,8 +75,9 @@ bool PriorBoxLayer::init(const LayerMap& layerMap,
...
@@ -72,8 +75,9 @@ bool PriorBoxLayer::init(const LayerMap& layerMap,
aspectRatio_
.
push_back
(
ar
);
aspectRatio_
.
push_back
(
ar
);
aspectRatio_
.
push_back
(
1.
/
ar
);
aspectRatio_
.
push_back
(
1.
/
ar
);
}
}
numPriors_
=
aspectRatio_
.
size
()
*
minSize_
.
size
();
if
(
maxSize_
.
size
()
>
0
)
numPriors_
+=
maxSize_
.
size
()
*
minSize_
.
size
();
numPriors_
=
aspectRatio_
.
size
()
*
minSize_
.
size
()
+
maxSize_
.
size
();
return
true
;
return
true
;
}
}
...
@@ -101,32 +105,9 @@ void PriorBoxLayer::forward(PassType passType) {
...
@@ -101,32 +105,9 @@ void PriorBoxLayer::forward(PassType passType) {
real
centerX
=
(
w
+
0.5
)
*
stepW
;
real
centerX
=
(
w
+
0.5
)
*
stepW
;
real
centerY
=
(
h
+
0.5
)
*
stepH
;
real
centerY
=
(
h
+
0.5
)
*
stepH
;
for
(
size_t
s
=
0
;
s
<
minSize_
.
size
();
s
++
)
{
for
(
size_t
s
=
0
;
s
<
minSize_
.
size
();
s
++
)
{
// square prior with size minSize
real
minSize
=
minSize_
[
s
];
real
minSize
=
minSize_
[
s
];
real
boxWidth
=
minSize
;
real
boxWidth
=
minSize
;
real
boxHeight
=
minSize
;
real
boxHeight
=
minSize
;
// xmin, ymin, xmax, ymax
tmpPtr
[
idx
++
]
=
(
centerX
-
boxWidth
/
2.
)
/
imageWidth
;
tmpPtr
[
idx
++
]
=
(
centerY
-
boxHeight
/
2.
)
/
imageHeight
;
tmpPtr
[
idx
++
]
=
(
centerX
+
boxWidth
/
2.
)
/
imageWidth
;
tmpPtr
[
idx
++
]
=
(
centerY
+
boxHeight
/
2.
)
/
imageHeight
;
// set the variance.
for
(
int
t
=
0
;
t
<
4
;
t
++
)
tmpPtr
[
idx
++
]
=
variance_
[
t
];
if
(
maxSize_
.
size
()
>
0
)
{
CHECK_EQ
(
minSize_
.
size
(),
maxSize_
.
size
());
// square prior with size sqrt(minSize * maxSize)
for
(
size_t
s
=
0
;
s
<
maxSize_
.
size
();
s
++
)
{
real
maxSize
=
maxSize_
[
s
];
boxWidth
=
boxHeight
=
sqrt
(
minSize
*
maxSize
);
tmpPtr
[
idx
++
]
=
(
centerX
-
boxWidth
/
2.
)
/
imageWidth
;
tmpPtr
[
idx
++
]
=
(
centerY
-
boxHeight
/
2.
)
/
imageHeight
;
tmpPtr
[
idx
++
]
=
(
centerX
+
boxWidth
/
2.
)
/
imageWidth
;
tmpPtr
[
idx
++
]
=
(
centerY
+
boxHeight
/
2.
)
/
imageHeight
;
// set the variance.
for
(
int
t
=
0
;
t
<
4
;
t
++
)
tmpPtr
[
idx
++
]
=
variance_
[
t
];
}
}
// priors with different aspect ratios
// priors with different aspect ratios
for
(
size_t
r
=
0
;
r
<
aspectRatio_
.
size
();
r
++
)
{
for
(
size_t
r
=
0
;
r
<
aspectRatio_
.
size
();
r
++
)
{
...
@@ -140,9 +121,22 @@ void PriorBoxLayer::forward(PassType passType) {
...
@@ -140,9 +121,22 @@ void PriorBoxLayer::forward(PassType passType) {
// set the variance.
// set the variance.
for
(
int
t
=
0
;
t
<
4
;
t
++
)
tmpPtr
[
idx
++
]
=
variance_
[
t
];
for
(
int
t
=
0
;
t
<
4
;
t
++
)
tmpPtr
[
idx
++
]
=
variance_
[
t
];
}
}
if
(
maxSize_
.
size
()
>
0
)
{
// square prior with size sqrt(minSize * maxSize)
real
maxSize
=
maxSize_
[
s
];
boxWidth
=
boxHeight
=
sqrt
(
minSize
*
maxSize
);
tmpPtr
[
idx
++
]
=
(
centerX
-
boxWidth
/
2.
)
/
imageWidth
;
tmpPtr
[
idx
++
]
=
(
centerY
-
boxHeight
/
2.
)
/
imageHeight
;
tmpPtr
[
idx
++
]
=
(
centerX
+
boxWidth
/
2.
)
/
imageWidth
;
tmpPtr
[
idx
++
]
=
(
centerY
+
boxHeight
/
2.
)
/
imageHeight
;
// set the variance.
for
(
int
t
=
0
;
t
<
4
;
t
++
)
tmpPtr
[
idx
++
]
=
variance_
[
t
];
}
}
}
}
}
}
}
// 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
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录