Apollo  6.0
Open source self driving car software
net_util.h
Go to the documentation of this file.
1 /******************************************************************************
2  * Copyright 2017 The Apollo Authors. All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *****************************************************************************/
16 
22 #pragma once
23 
24 #include <string>
25 #include <vector>
26 
27 #include "Eigen/Dense"
28 
29 #include "modules/prediction/proto/network_layers.pb.h"
30 
35 namespace apollo {
36 namespace prediction {
37 namespace network {
38 
43 float sigmoid(const float x);
44 
49 float tanh(const float x);
50 
55 float linear(const float x);
56 
63 float hard_sigmoid(const float x);
64 
71 float relu(const float x);
72 
78 Eigen::MatrixXf FlattenMatrix(const Eigen::MatrixXf& matrix);
79 
85 std::function<float(float)> serialize_to_function(const std::string& str);
86 
93 bool LoadTensor(const TensorParameter& tensor_pb, Eigen::MatrixXf* matrix);
94 
101 bool LoadTensor(const TensorParameter& tensor_pb, Eigen::VectorXf* vector);
102 
109 bool LoadTensor(const TensorParameter& tensor_pb,
110  std::vector<Eigen::MatrixXf>* const tensor3d);
111 
112 } // namespace network
113 } // namespace prediction
114 } // namespace apollo
float relu(const float x)
relu function: | 0.0 x in (-oo, 0.0) f(x) = | | x x in [0.0, +oo)
PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
float hard_sigmoid(const float x)
"hard" sigmoid function: | 0.0 x in (-oo, 0) f(x) = | 0.2x + 0.5 x in [0, 2.5] | 1.0 x in (2.5, +oo)
float sigmoid(const float x)
sigmoid function: f(x) = 1 / (1 + exp(-x))
bool LoadTensor(const TensorParameter &tensor_pb, Eigen::MatrixXf *matrix)
load matrix value from a protobuf message
std::function< float(float)> serialize_to_function(const std::string &str)
translate a string into a network activation function
float linear(const float x)
linear function: f(x) = x
float tanh(const float x)
hyperbolic tangent function: f(x) = (1 + exp(-2x)) / (1 - exp(-2x))
Eigen::MatrixXf FlattenMatrix(const Eigen::MatrixXf &matrix)
flatten a matrix to a row vector