Skip to content

Commit

Permalink
Updated model proto
Browse files Browse the repository at this point in the history
  • Loading branch information
jinghaomiao authored and kechxu committed Jul 31, 2017
1 parent cacfd6f commit 00a1d08
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 7 deletions.
Binary file modified modules/prediction/data/mlp_vehicle_model.bin
Binary file not shown.
11 changes: 5 additions & 6 deletions modules/prediction/evaluator/vehicle/mlp_evaluator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
*****************************************************************************/

#include <cmath>
#include <fstream>
#include <numeric>

#include "modules/prediction/evaluator/vehicle/mlp_evaluator.h"
Expand Down Expand Up @@ -297,15 +296,15 @@ double MLPEvaluator::ComputeProbability() {
double weight = layer.layer_input_weight().rows(row).columns(col);
neuron_output += (layer_input[row] * weight);
}
if (layer.layer_activation_type() == "relu") {
if (layer.layer_activation_func() == Layer::RELU) {
neuron_output = apollo::prediction::util::Relu(neuron_output);
} else if (layer.layer_activation_type() == "sigmoid") {
} else if (layer.layer_activation_func() == Layer::SIGMOID) {
neuron_output = apollo::prediction::util::Sigmoid(neuron_output);
} else if (layer.layer_activation_type() == "tanh") {
} else if (layer.layer_activation_func() == Layer::TANH) {
neuron_output = std::tanh(neuron_output);
} else {
AERROR << "Undefined activation type ["
<< layer.layer_activation_type()
AERROR << "Undefined activation function ["
<< layer.layer_activation_func()
<< "]. A default sigmoid will be used instead.";
neuron_output = apollo::prediction::util::Sigmoid(neuron_output);
}
Expand Down
11 changes: 11 additions & 0 deletions modules/prediction/proto/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,14 @@ py_proto_compile(
"//modules/perception/proto:perception_proto_pylib",
],
)

py_proto_compile(
name = "prediction_model_proto_pylib",
protos = [
"fnn_model_base.proto",
"fnn_vehicle_model.proto",
],
deps = [
"//modules/common/proto:common_proto_pylib",
]
)
8 changes: 7 additions & 1 deletion modules/prediction/proto/fnn_model_base.proto
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,15 @@ message Matrix {
}

message Layer {
enum ActivationFunc {
RELU = 0;
TANH = 1;
SIGMOID = 2;
}
optional int32 layer_input_dim = 1;
optional int32 layer_output_dim = 2;
optional Matrix layer_input_weight = 3; // weight matrix of |input_dim| x |output_dim|
optional Vector layer_bias = 4; // vector of bias, size of |output_dim|
optional string layer_activation_type = 5; // relu, tanh, or sigmoid
optional string layer_activation_type = 5 [deprecated = true];
optional ActivationFunc layer_activation_func = 6;
}

0 comments on commit 00a1d08

Please sign in to comment.