Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
机器未来
Paddle
提交
93734a79
P
Paddle
项目概览
机器未来
/
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
93734a79
编写于
2月 05, 2018
作者:
C
chengduoZH
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix bug
上级
be815dd0
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
40 addition
and
29 deletion
+40
-29
paddle/operators/prior_box_op.cc
paddle/operators/prior_box_op.cc
+40
-29
未找到文件。
paddle/operators/prior_box_op.cc
浏览文件 @
93734a79
...
...
@@ -44,12 +44,6 @@ class PriorBoxOp : public framework::OperatorWithKernel {
auto
aspect_ratios
=
ctx
->
Attrs
().
Get
<
std
::
vector
<
float
>>
(
"aspect_ratios"
);
bool
flip
=
ctx
->
Attrs
().
Get
<
bool
>
(
"flip"
);
PADDLE_ENFORCE_GT
(
min_sizes
.
size
(),
0
,
"Size of min_sizes must be at least 1."
);
for
(
size_t
i
=
0
;
i
<
min_sizes
.
size
();
++
i
)
{
PADDLE_ENFORCE_GT
(
min_sizes
[
i
],
0
,
"min_sizes[%d] must be positive."
,
i
);
}
std
::
vector
<
float
>
aspect_ratios_vec
;
ExpandAspectRatios
(
aspect_ratios
,
flip
,
aspect_ratios_vec
);
...
...
@@ -65,17 +59,6 @@ class PriorBoxOp : public framework::OperatorWithKernel {
}
}
PADDLE_ENFORCE_EQ
(
variances
.
size
(),
4
,
"Must and only provide 4 variance."
);
for
(
size_t
i
=
0
;
i
<
variances
.
size
();
++
i
)
{
PADDLE_ENFORCE_GT
(
variances
[
i
],
0.0
,
"variance[%d] must be greater than 0."
,
i
);
}
const
float
step_h
=
ctx
->
Attrs
().
Get
<
float
>
(
"step_h"
);
PADDLE_ENFORCE_GT
(
step_h
,
0.0
,
"step_h should be larger than 0."
);
const
float
step_w
=
ctx
->
Attrs
().
Get
<
float
>
(
"step_w"
);
PADDLE_ENFORCE_GT
(
step_w
,
0.0
,
"step_w should be larger than 0."
);
std
::
vector
<
int64_t
>
dim_vec
(
4
);
dim_vec
[
0
]
=
input_dims
[
2
];
dim_vec
[
1
]
=
input_dims
[
3
];
...
...
@@ -106,26 +89,54 @@ class PriorBoxOpMaker : public framework::OpProtoAndCheckerMaker {
"PriorBoxOp. The layout is [H, W, num_priors, 4]. "
"H is the height of input, W is the width of input, num_priors "
"is the box count of each position."
);
AddAttr
<
std
::
vector
<
int
>>
(
"min_sizes"
,
"(vector<int>) "
,
"List of min sizes of generated prior boxes."
);
AddAttr
<
std
::
vector
<
int
>>
(
"max_sizes"
,
"(vector<int>) "
,
"List of max sizes of generated prior boxes."
);
AddAttr
<
std
::
vector
<
int
>>
(
"min_sizes"
,
"(vector<int>) List of min sizes "
"of generated prior boxes."
)
.
AddCustomChecker
([](
const
std
::
vector
<
int
>&
min_sizes
)
{
PADDLE_ENFORCE_GT
(
min_sizes
.
size
(),
0
,
"Size of min_sizes must be at least 1."
);
for
(
size_t
i
=
0
;
i
<
min_sizes
.
size
();
++
i
)
{
PADDLE_ENFORCE_GT
(
min_sizes
[
i
],
0
,
"min_sizes[%d] must be positive."
,
i
);
}
});
AddAttr
<
std
::
vector
<
int
>>
(
"max_sizes"
,
"(vector<int>) List of max sizes of generated prior boxes."
);
AddAttr
<
std
::
vector
<
float
>>
(
"aspect_ratios"
,
"(vector<float>) "
,
"List of aspect ratios of generated prior boxes."
);
"aspect_ratios"
,
"(vector<float>) List of aspect ratios of generated prior boxes."
);
AddAttr
<
std
::
vector
<
float
>>
(
"variances"
,
"(vector<float>) "
,
"List of variances to be encoded in prior boxes."
);
AddAttr
<
bool
>
(
"flip"
,
"(bool) "
,
"Whether to flip aspect ratios."
)
"variances"
,
"(vector<float>) List of variances to be encoded in prior boxes."
)
.
AddCustomChecker
([](
const
std
::
vector
<
float
>&
variances
)
{
PADDLE_ENFORCE_EQ
(
variances
.
size
(),
4
,
"Must and only provide 4 variance."
);
for
(
size_t
i
=
0
;
i
<
variances
.
size
();
++
i
)
{
PADDLE_ENFORCE_GT
(
variances
[
i
],
0.0
,
"variance[%d] must be greater than 0."
,
i
);
}
});
AddAttr
<
bool
>
(
"flip"
,
"(bool) Whether to flip aspect ratios."
)
.
SetDefault
(
true
);
AddAttr
<
bool
>
(
"clip"
,
"(bool)
"
,
"
Whether to clip out-of-boundary boxes."
)
AddAttr
<
bool
>
(
"clip"
,
"(bool) Whether to clip out-of-boundary boxes."
)
.
SetDefault
(
true
);
AddAttr
<
float
>
(
"step_w"
,
"Prior boxes step across width, 0 for auto calculation."
)
.
SetDefault
(
0.0
);
.
SetDefault
(
0.0
)
.
AddCustomChecker
([](
const
float
&
step_w
)
{
PADDLE_ENFORCE_GT
(
step_w
,
0.0
,
"step_h should be larger than 0."
);
});
AddAttr
<
float
>
(
"step_h"
,
"Prior boxes step across height, 0 for auto calculation."
)
.
SetDefault
(
0.0
);
.
SetDefault
(
0.0
)
.
AddCustomChecker
([](
const
float
&
step_h
)
{
PADDLE_ENFORCE_GT
(
step_h
,
0.0
,
"step_h should be larger than 0."
);
});
AddAttr
<
float
>
(
"offset"
,
"(float) "
"Prior boxes center offset."
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录