Apollo 11.0
自动驾驶开放平台
net_model.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
17#pragma once
18
19#include <memory>
20#include <string>
21#include <vector>
22
24#include "modules/prediction/proto/network_model.pb.h"
25
30namespace apollo {
31namespace prediction {
32namespace network {
33
40class NetModel {
41 public:
45 NetModel() = default;
46
50 virtual ~NetModel() = default;
51
57 virtual void Run(const std::vector<Eigen::MatrixXf>& inputs,
58 Eigen::MatrixXf* output) const = 0;
59
64 virtual void SetState(const std::vector<Eigen::MatrixXf>& states) {}
65
70 virtual void State(std::vector<Eigen::MatrixXf>* states) const {}
71
76 virtual void ResetState() const {}
77
83 bool LoadModel(const NetParameter& net_parameter);
84
89 std::string PerformanceString() const;
90
95 const std::string& Name() const;
96
101 int Id() const;
102
107 bool IsOk() const;
108
109 protected:
110 std::vector<std::unique_ptr<Layer>> layers_;
112 bool ok_ = false;
113};
114
115} // namespace network
116} // namespace prediction
117} // namespace apollo
NetModel is a base class for specific network model It contains a pure virtual function Run which mus...
Definition net_model.h:40
const std::string & Name() const
Name of a network model
Definition net_model.cc:95
virtual void ResetState() const
Set the internal state of a model
Definition net_model.h:76
std::string PerformanceString() const
Shows the performance information of a network
Definition net_model.cc:73
virtual void Run(const std::vector< Eigen::MatrixXf > &inputs, Eigen::MatrixXf *output) const =0
Compute the model output from inputs
bool IsOk() const
Indicate the state of a network model
Definition net_model.cc:99
bool LoadModel(const NetParameter &net_parameter)
Load network parameters from a protobuf message
Definition net_model.cc:27
virtual void SetState(const std::vector< Eigen::MatrixXf > &states)
Set the internal state of a network model
Definition net_model.h:64
virtual ~NetModel()=default
Destructor
virtual void State(std::vector< Eigen::MatrixXf > *states) const
Access to the internal state of a network model
Definition net_model.h:70
int Id() const
Id of a network model
Definition net_model.cc:97
std::vector< std::unique_ptr< Layer > > layers_
Definition net_model.h:110
class register implement
Definition arena_queue.h:37