Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Pinoxchio
apollo
提交
fa160405
A
apollo
项目概览
Pinoxchio
/
apollo
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
A
apollo
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
fa160405
编写于
11月 07, 2018
作者:
H
Hongyi
提交者:
Jiangtao Hu
12月 13, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Prediction: ComputeProbability for online inference
上级
c4cb874c
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
46 addition
and
6 deletion
+46
-6
modules/prediction/evaluator/vehicle/junction_mlp_evaluator.cc
...es/prediction/evaluator/vehicle/junction_mlp_evaluator.cc
+44
-5
modules/prediction/evaluator/vehicle/junction_mlp_evaluator.h
...les/prediction/evaluator/vehicle/junction_mlp_evaluator.h
+2
-1
未找到文件。
modules/prediction/evaluator/vehicle/junction_mlp_evaluator.cc
浏览文件 @
fa160405
...
...
@@ -21,6 +21,7 @@
#include "modules/common/math/math_utils.h"
#include "modules/prediction/common/feature_output.h"
#include "modules/prediction/common/prediction_gflags.h"
#include "modules/prediction/common/prediction_util.h"
#include "modules/prediction/common/prediction_map.h"
using
apollo
::
hdmap
::
LaneInfo
;
...
...
@@ -81,8 +82,13 @@ void JunctionMLPEvaluator::Evaluate(Obstacle* obstacle_ptr) {
}
std
::
vector
<
double
>
feature_values
;
ExtractFeatureValues
(
obstacle_ptr
,
&
feature_values
);
std
::
vector
<
double
>
probability
=
ComputeProbability
(
feature_values
);
for
(
double
prob
:
probability
)
{
obstacle_ptr
->
mutable_latest_feature
()
->
mutable_junction_feature
()
->
add_junction_mlp_probability
(
prob
);
}
if
(
FLAGS_prediction_offline_mode
)
{
FeatureOutput
::
Insert
(
obstacle_ptr
->
latest_feature
());
...
...
@@ -208,7 +214,6 @@ void JunctionMLPEvaluator::SetJunctionFeatureValues(
double
diff_heading
=
apollo
::
common
::
math
::
AngleDiff
(
heading
,
junction_exit
.
exit_heading
());
double
angle
=
std
::
atan2
(
diff_y
,
diff_x
);
// TODO(Hongyi) test d_idx
double
d_idx
=
(
angle
/
(
2.0
*
M_PI
))
*
12.0
;
int
idx
=
static_cast
<
int
>
(
floor
(
d_idx
>=
0
?
d_idx
:
d_idx
+
12
));
feature_values
->
operator
[](
idx
*
5
)
=
1.0
;
...
...
@@ -238,10 +243,44 @@ void JunctionMLPEvaluator::LoadModel(const std::string& model_file) {
AINFO
<<
"Succeeded in loading the model file: "
<<
model_file
<<
"."
;
}
double
JunctionMLPEvaluator
::
ComputeProbability
(
std
::
vector
<
double
>
JunctionMLPEvaluator
::
ComputeProbability
(
const
std
::
vector
<
double
>&
feature_values
)
{
// TODO(all) implement
return
0.5
;
CHECK_NOTNULL
(
model_ptr_
.
get
());
if
(
model_ptr_
->
dim_input
()
!=
static_cast
<
int
>
(
feature_values
.
size
()))
{
ADEBUG
<<
"Model feature size not consistent with model proto definition. "
<<
"model input dim = "
<<
model_ptr_
->
dim_input
()
<<
"; feature value size = "
<<
feature_values
.
size
();
return
{};
}
std
::
vector
<
double
>
layer_input
;
layer_input
.
reserve
(
model_ptr_
->
dim_input
());
std
::
vector
<
double
>
layer_output
;
for
(
int
i
=
0
;
i
<
model_ptr_
->
num_layer
();
++
i
)
{
if
(
i
>
0
)
{
layer_input
.
swap
(
layer_output
);
layer_output
.
clear
();
}
const
Layer
&
layer
=
model_ptr_
->
layer
(
i
);
for
(
int
col
=
0
;
col
<
layer
.
layer_output_dim
();
++
col
)
{
double
neuron_output
=
layer
.
layer_bias
().
columns
(
col
);
for
(
int
row
=
0
;
row
<
layer
.
layer_input_dim
();
++
row
)
{
double
weight
=
layer
.
layer_input_weight
().
rows
(
row
).
columns
(
col
);
neuron_output
+=
(
layer_input
[
row
]
*
weight
);
}
if
(
layer
.
layer_activation_func
()
==
Layer
::
RELU
)
{
neuron_output
=
apollo
::
prediction
::
math_util
::
Relu
(
neuron_output
);
}
else
if
(
layer
.
layer_activation_func
()
==
Layer
::
SIGMOID
)
{
neuron_output
=
apollo
::
prediction
::
math_util
::
Sigmoid
(
neuron_output
);
}
else
if
(
layer
.
layer_activation_func
()
==
Layer
::
TANH
)
{
neuron_output
=
std
::
tanh
(
neuron_output
);
}
layer_output
.
push_back
(
neuron_output
);
if
(
layer
.
layer_activation_func
()
==
Layer
::
SOFTMAX
)
{
layer_output
=
apollo
::
prediction
::
math_util
::
Softmax
(
layer_output
);
}
}
}
return
layer_output
;
}
}
// namespace prediction
...
...
modules/prediction/evaluator/vehicle/junction_mlp_evaluator.h
浏览文件 @
fa160405
...
...
@@ -98,7 +98,8 @@ class JunctionMLPEvaluator : public Evaluator {
/**
* @brief Compute probability of a junction exit
*/
double
ComputeProbability
(
const
std
::
vector
<
double
>&
feature_values
);
std
::
vector
<
double
>
ComputeProbability
(
const
std
::
vector
<
double
>&
feature_values
);
private:
static
const
size_t
OBSTACLE_FEATURE_SIZE
=
3
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录