Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Pinoxchio
apollo
提交
a7da15bf
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,发现更多精彩内容 >>
提交
a7da15bf
编写于
9月 28, 2018
作者:
J
Jiangtao Hu
提交者:
Calvin Miao
9月 28, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
perception: remove common/test directory. RDFModelUltra code is not available.
上级
3e58a66b
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
0 addition
and
237 deletion
+0
-237
modules/perception/common/test/BUILD.txt
modules/perception/common/test/BUILD.txt
+0
-44
modules/perception/common/test/common_machine_learning_rdf_test.cc
...erception/common/test/common_machine_learning_rdf_test.cc
+0
-193
未找到文件。
modules/perception/common/test/BUILD.txt
已删除
100644 → 0
浏览文件 @
3e58a66b
# DO NOT MODIFY
# THIS FILE IS GENERATED AUTOMATICALLY TO HELP WRITE BUILD FILE
# DELETE THIS FILE WHEN YOU HAVE CREATED THE COMPLETE BUILD FILE
load("//tools:cpplint.bzl", "cpplint")
package(default_visibility = ["//visibility:public"])
cc_library(
name = "common_image_processing_hough_test",
srcs = [
"common_image_processing_hough_test.cc",
],
deps = [
],
)
cc_library(
name = "common_io_io_util_test",
srcs = [
"common_io_io_util_test.cc",
],
deps = [
],
)
cc_library(
name = "common_machine_learning_rdf_test",
srcs = [
"common_machine_learning_rdf_test.cc",
],
deps = [
],
)
cc_library(
name = "common_point_cloud_processing_common_test",
srcs = [
"common_point_cloud_processing_common_test.cc",
],
deps = [
],
)
cpplint()
modules/perception/common/test/common_machine_learning_rdf_test.cc
已删除
100644 → 0
浏览文件 @
3e58a66b
/******************************************************************************
* Copyright 2018 The Apollo Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*****************************************************************************/
#include <gtest/gtest.h>
#include "modules/perception/common/machine_learning/rdf_helper.h"
#include "modules/perception/common/machine_learning/rdf_model_ultra.h"
namespace
apollo
{
namespace
perception
{
namespace
common
{
TEST
(
RDFModelUltraTest
,
bit_operation_test
)
{
uint32_t
var_idx
=
0x00000010
;
uint32_t
dest
=
0x10011000
;
uint32_t
i_result
=
SetVarIdx
(
var_idx
,
dest
);
EXPECT_EQ
(
0x01011000
,
i_result
);
uint32_t
childpos
=
0x00000080
;
i_result
=
SetChildPos
(
childpos
,
dest
);
EXPECT_EQ
(
0x10000080
,
i_result
);
i_result
=
GetVarIdx
(
dest
);
EXPECT_EQ
(
0x00000100
,
i_result
);
i_result
=
GetChildPos
(
dest
);
EXPECT_EQ
(
0x00011000
,
i_result
);
float
f_result
=
SetLeftChildLeaf
(
Uint32ToFloatByBit
(
dest
));
EXPECT_EQ
(
0x10011002
,
FloatToUint32ByBit
(
f_result
));
f_result
=
SetLeftChildUnleaf
(
Uint32ToFloatByBit
(
dest
));
EXPECT_EQ
(
0x10011000
,
FloatToUint32ByBit
(
f_result
));
f_result
=
SetRightChildLeaf
(
Uint32ToFloatByBit
(
dest
));
EXPECT_EQ
(
0x10011001
,
FloatToUint32ByBit
(
f_result
));
f_result
=
SetRightChildUnleaf
(
Uint32ToFloatByBit
(
dest
));
EXPECT_EQ
(
0x10011000
,
FloatToUint32ByBit
(
f_result
));
bool
b_result
=
IsLeftChildLeaf
(
Uint32ToFloatByBit
(
dest
));
EXPECT_FALSE
(
b_result
);
b_result
=
IsRightChildLeaf
(
Uint32ToFloatByBit
(
dest
));
EXPECT_FALSE
(
b_result
);
b_result
=
IsBothChildLeaf
(
Uint32ToFloatByBit
(
dest
));
EXPECT_FALSE
(
b_result
);
b_result
=
IsBothChildNotLeaf
(
Uint32ToFloatByBit
(
dest
));
EXPECT_TRUE
(
b_result
);
f_result
=
SetChildClassOnSplitVal
(
0x00000003
,
Uint32ToFloatByBit
(
dest
));
EXPECT_EQ
(
0x1001100c
,
FloatToUint32ByBit
(
f_result
));
i_result
=
GetChildClassOnSplitVal
(
Uint32ToFloatByBit
(
dest
));
EXPECT_EQ
(
0
,
i_result
);
i_result
=
SetChildClassOnPos
(
0x00000003
,
dest
);
EXPECT_EQ
(
0x10011003
,
i_result
);
i_result
=
GetChildClassOnPos
(
dest
);
EXPECT_EQ
(
0x00000000
,
i_result
);
}
TEST
(
RDFModelUltraTest
,
trans_old_model_to_ultra_model_test
)
{
RDFModelUltra
ultra_model
;
bool
model_loaded
=
ultra_model
.
IsModelLoaded
();
EXPECT_FALSE
(
model_loaded
);
bool
trans_res
=
ultra_model
.
TransOldModelToUltraModel
(
"./common_test_data/machine_learning/data/not_exist_model"
);
EXPECT_FALSE
(
trans_res
);
trans_res
=
ultra_model
.
TransOldModelToUltraModel
(
"./common_test_data/machine_learning/data/normal_correct_model.bin"
);
EXPECT_TRUE
(
trans_res
);
model_loaded
=
ultra_model
.
IsModelLoaded
();
EXPECT_TRUE
(
model_loaded
);
bool
save_res
=
ultra_model
.
SaveBinModel
(
"./common_test_data/machine_learning/data/ultra_correct_model.bin"
);
EXPECT_TRUE
(
save_res
);
const
RDFModelUltra
::
ForestHead
*
head
=
ultra_model
.
GetForestHeader
();
EXPECT_EQ
(
2
,
head
->
tree_num
);
EXPECT_EQ
(
4
,
head
->
tree_node_num
);
EXPECT_EQ
(
0
,
head
->
tree_pos_list
[
0
]);
EXPECT_EQ
(
2
,
head
->
tree_pos_list
[
1
]);
const
std
::
vector
<
RDFModelUltra
::
TreeNodeUltra
>*
ultra_tree_nodes
=
ultra_model
.
GetTreeNodeUltraList
();
EXPECT_EQ
(
4
,
ultra_tree_nodes
->
size
());
}
TEST
(
RDFModelUltraTest
,
load_predict_test
)
{
std
::
vector
<
float
>
test_feature1
=
{
0.5
,
2.5
,
2.6
,
4.5
,
4.6
,
6.5
,
6.6
,
8.5
,
8.6
,
10.5
};
std
::
vector
<
float
>
test_feature2
=
{
1.5
,
1.5
,
3.6
,
3.5
,
5.6
,
5.5
,
7.6
,
7.5
,
9.6
,
9.5
};
std
::
vector
<
float
>
test_features
=
{
0.5
,
2.5
,
2.6
,
4.5
,
4.6
,
6.5
,
6.6
,
8.5
,
8.6
,
10.5
,
1.5
,
1.5
,
3.6
,
3.5
,
5.6
,
5.5
,
7.6
,
7.5
,
9.6
,
9.5
};
RDFModelUltra
ultra_model
;
bool
load_res
=
ultra_model
.
LoadBinModel
(
"./common_test_data/machine_learning/data/ultra_correct_model.bin"
);
EXPECT_TRUE
(
load_res
);
int
ultra_tree_node_idx
=
ultra_model
.
GetTreeNodeUltraIdx
(
nullptr
);
EXPECT_EQ
(
-
1
,
ultra_tree_node_idx
);
ultra_tree_node_idx
=
ultra_model
.
GetTreeNodeUltraIdx
(
ultra_model
.
tree_node_ultra_list_
.
data
());
EXPECT_EQ
(
0
,
ultra_tree_node_idx
);
std
::
vector
<
float
>
probs
;
float
predict_res
=
ultra_model
.
ForestPredict
(
test_feature1
,
&
probs
);
EXPECT_EQ
(
1
,
static_cast
<
int
>
(
predict_res
));
predict_res
=
ultra_model
.
ForestPredict
(
test_feature2
,
&
probs
);
EXPECT_EQ
(
0
,
static_cast
<
int
>
(
predict_res
));
ultra_model
.
BatchForestPredict
(
test_features
.
data
(),
probs
.
data
(),
10
,
2
,
2
);
EXPECT_FLOAT_EQ
(
0.0
,
probs
[
0
]);
EXPECT_FLOAT_EQ
(
1.0
,
probs
[
1
]);
EXPECT_FLOAT_EQ
(
0.5
,
probs
[
2
]);
EXPECT_FLOAT_EQ
(
0.5
,
probs
[
3
]);
ultra_model
.
ClearModel
();
bool
model_loaded
=
ultra_model
.
IsModelLoaded
();
EXPECT_FALSE
(
model_loaded
);
load_res
=
ultra_model
.
LoadBinModel
(
"./common_test_data/machine_learning/data/normal_correct_model.bin"
);
EXPECT_FALSE
(
load_res
);
load_res
=
ultra_model
.
LoadBinModel
(
"not_exist_model"
);
EXPECT_FALSE
(
load_res
);
bool
save_res
=
ultra_model
.
SaveBinModel
(
"./common_test_data/machine_learning/data/not_exist_model"
);
EXPECT_FALSE
(
save_res
);
}
TEST
(
RDFModelTest
,
load_predict_test
)
{
std
::
vector
<
float
>
test_feature1
=
{
0.5
,
2.5
,
2.6
,
4.5
,
4.6
,
6.5
,
6.6
,
8.5
,
8.6
,
10.5
};
std
::
vector
<
float
>
test_feature2
=
{
1.5
,
1.5
,
3.6
,
3.5
,
5.6
,
5.5
,
7.6
,
7.5
,
9.6
,
9.5
};
std
::
vector
<
float
>
test_features
=
{
0.5
,
2.5
,
2.6
,
4.5
,
4.6
,
6.5
,
6.6
,
8.5
,
8.6
,
10.5
,
1.5
,
1.5
,
3.6
,
3.5
,
5.6
,
5.5
,
7.6
,
7.5
,
9.6
,
9.5
};
RDFModel
model
;
bool
load_res
=
model
.
LoadBinModel
(
"./common_test_data/machine_learning/data/normal_correct_model.bin"
);
EXPECT_TRUE
(
load_res
);
const
std
::
vector
<
RDFModel
::
TreeNode
>*
node_list
=
model
.
GetTreeNodeList
();
EXPECT_EQ
(
10
,
node_list
->
size
());
int
tree_node_idx
=
model
.
GetTreeNodeIdx
(
nullptr
);
EXPECT_EQ
(
-
1
,
tree_node_idx
);
std
::
vector
<
float
>
probs
;
float
predict_res
=
model
.
ForestPredict
(
test_feature1
,
&
probs
);
EXPECT_EQ
(
1
,
static_cast
<
int
>
(
predict_res
));
predict_res
=
model
.
ForestPredict
(
test_feature2
,
&
probs
);
EXPECT_EQ
(
0
,
static_cast
<
int
>
(
predict_res
));
predict_res
=
model
.
ForestPredict
(
test_feature2
,
nullptr
);
EXPECT_EQ
(
0
,
static_cast
<
int
>
(
predict_res
));
model
.
BatchForestPredict
(
test_features
.
data
(),
probs
.
data
(),
10
,
2
,
2
);
EXPECT_FLOAT_EQ
(
0.0
,
probs
[
0
]);
EXPECT_FLOAT_EQ
(
1.0
,
probs
[
1
]);
EXPECT_FLOAT_EQ
(
0.5
,
probs
[
2
]);
EXPECT_FLOAT_EQ
(
0.5
,
probs
[
3
]);
model
.
ClearModel
();
bool
model_loaded
=
model
.
IsModelLoaded
();
EXPECT_FALSE
(
model_loaded
);
load_res
=
model
.
LoadBinModel
(
"./common_test_data/machine_learning/data/ultra_correct_model.bin"
);
EXPECT_FALSE
(
load_res
);
load_res
=
model
.
LoadBinModel
(
"not_exist_model"
);
EXPECT_FALSE
(
load_res
);
bool
save_res
=
model
.
SaveBinModel
(
"./common_test_data/machine_learning/data/not_exist_model"
);
EXPECT_FALSE
(
save_res
);
}
}
// namespace common
}
// namespace perception
}
// namespace apollo
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录