Apollo 11.0
自动驾驶开放平台
net_util.h
浏览该文件的文档.
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
35namespace apollo {
36namespace prediction {
37namespace network {
38
43float sigmoid(const float x);
44
49float tanh(const float x);
50
55float linear(const float x);
56
63float hard_sigmoid(const float x);
64
71float relu(const float x);
72
78Eigen::MatrixXf FlattenMatrix(const Eigen::MatrixXf& matrix);
79
85std::function<float(float)> serialize_to_function(const std::string& str);
86
93bool LoadTensor(const TensorParameter& tensor_pb, Eigen::MatrixXf* matrix);
94
101bool LoadTensor(const TensorParameter& tensor_pb, Eigen::VectorXf* vector);
102
109bool LoadTensor(const TensorParameter& tensor_pb,
110 std::vector<Eigen::MatrixXf>* const tensor3d);
111
112} // namespace network
113} // namespace prediction
114} // namespace apollo
float linear(const float x)
linear function: f(x) = x
Definition net_util.cc:31
std::function< float(float)> serialize_to_function(const std::string &str)
translate a string into a network activation function
Definition net_util.cc:56
float tanh(const float x)
hyperbolic tangent function: f(x) = (1 + exp(-2x)) / (1 - exp(-2x))
Definition net_util.cc:29
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....
Definition net_util.cc:33
Eigen::MatrixXf FlattenMatrix(const Eigen::MatrixXf &matrix)
flatten a matrix to a row vector
Definition net_util.cc:40
float sigmoid(const float x)
sigmoid function: f(x) = 1 / (1 + exp(-x))
Definition net_util.cc:27
bool LoadTensor(const TensorParameter &tensor_pb, Eigen::MatrixXf *matrix)
load matrix value from a protobuf message
Definition net_util.cc:66
float relu(const float x)
relu function: | 0.0 x in (-oo, 0.0) f(x) = | | x x in [0.0, +oo)
Definition net_util.cc:38
class register implement
Definition arena_queue.h:37