本文做者:Apollo開發者社區app
簡介ide
評估器經過應用預訓練的深度學習模型生成特徵(來自障礙物和當前車輛的原始信息)以得到模型輸出。學習
添加評估器的步驟lua
請按照下面的步驟添加名稱爲NewEvaluator
的評估器:spa
在proto中添加一個字段code
聲明一個從
Evaluator
類繼承的類NewEvaluator
繼承實現類
NewEvaluator
開發更新預測配置get
更新評估器管理深度學習
下面讓咱們用上面的方法來添加新的評估器。
1、聲明一個從Evaluator
類繼承的類
NewEvaluator
modules/prediction/evaluator/vehicle
目錄下新建文件new_evaluator.h
。聲明以下:
#include "modules/prediction/evaluator/evaluator.h" namespace apollo { namespace prediction { class NewEvaluator : public Evaluator { public: NewEvaluator(); virtual ~NewEvaluator(); void Evaluate(Obstacle* obstacle_ptr) override; // Other useful functions and fields. }; } // namespace prediction } // namespace apollo
2、實現類 NewEvaluator
在new_evaluator.h
所在目錄下新建文件new_evaluator.cc
。實現以下:
#include "modules/prediction/evaluator/vehicle/new_evaluator.h" namespace apollo { namespace prediction { NewEvaluator::NewEvaluator() { // Implement } NewEvaluator::~NewEvaluator() { // Implement } NewEvaluator::Evaluate(Obstacle* obstacle_ptr)() { // Extract features // Compute new_output by applying pre-trained model } // Other functions } // namespace prediction } // namespace apollo
3、在proto中添加新評估器
在prediction_conf.proto
中添加新評估器類型:
enum EvaluatorType { MLP_EVALUATOR = 0; NEW_EVALUATOR = 1; }
4、更新prediction_conf文件
在modules/prediction/conf/prediction_conf.pb.txt
中,按照以下方式更新字段evaluator_type
:
obstacle_conf { obstacle_type: VEHICLE obstacle_status: ON_LANE evaluator_type: NEW_EVALUATOR predictor_type: NEW_PREDICTOR }
5、更新評估器管理
按照以下方式更新CreateEvluator( ... ):
case ObstacleConf::NEW_EVALUATOR: { evaluator_ptr.reset(new NewEvaluator()); break; }
按照以下方式更新RegisterEvaluators():
RegisterEvaluator(ObstacleConf::NEW_EVALUATOR);
完成上述步驟後,新評估器便建立成功了。
添加新特性
若是你想添加新特性,請按照以下的步驟進行操做:
在proto中添加一個字段
假設新的評估結果名稱是new_output
且類型是int32
。若是輸出直接與障礙物相關,能夠將它添加到modules/prediction/proto/feature.proto
中,以下所示:
message Feature { // Other existing features optional int32 new_output = 1000; }
若是輸出與車道相關,請將其添加到modules/prediction/proto/lane_graph.proto
中,以下所示:
message LaneSequence { // Other existing features optional int32 new_output = 1000; }