29 namespace prediction {
48 virtual ~Layer() =
default;
55 virtual bool Load(
const apollo::prediction::LayerParameter& layer_pb);
66 virtual void SetState(
const std::vector<Eigen::MatrixXf>& states) {}
72 virtual void State(std::vector<Eigen::MatrixXf>* states)
const {}
79 virtual void Run(
const std::vector<Eigen::MatrixXf>& inputs,
80 Eigen::MatrixXf* output) = 0;
86 std::string
Name()
const {
return name_; }
96 int order_number_ = -1;
115 bool Load(
const apollo::prediction::LayerParameter& layer_pb)
override;
122 bool Load(
const apollo::prediction::DenseParameter& layer_pb);
129 void Run(
const std::vector<Eigen::MatrixXf>& inputs,
130 Eigen::MatrixXf* output)
override;
135 Eigen::MatrixXf weights_;
136 Eigen::VectorXf bias_;
137 std::function<float(float)> kactivation_;
156 bool Load(
const apollo::prediction::LayerParameter& layer_pb)
override;
163 bool Load(
const apollo::prediction::Conv1dParameter& conv1d_pb);
170 void Run(
const std::vector<Eigen::MatrixXf>& inputs,
171 Eigen::MatrixXf* output)
override;
174 std::vector<int> shape_;
176 std::vector<Eigen::MatrixXf> kernel_;
177 Eigen::VectorXf bias_;
192 bool Load(
const apollo::prediction::LayerParameter& layer_pb)
override;
199 bool Load(
const apollo::prediction::MaxPool1dParameter& maxpool1d_pb);
206 void Run(
const std::vector<Eigen::MatrixXf>& inputs,
207 Eigen::MatrixXf* output)
override;
225 bool Load(
const apollo::prediction::LayerParameter& layer_pb)
override;
232 bool Load(
const apollo::prediction::AvgPool1dParameter& avgpool1d_pb);
239 void Run(
const std::vector<Eigen::MatrixXf>& inputs,
240 Eigen::MatrixXf* output)
override;
262 bool Load(
const apollo::prediction::LayerParameter& layer_pb)
override;
269 bool Load(
const apollo::prediction::ActivationParameter& activation_pb);
276 void Run(
const std::vector<Eigen::MatrixXf>& inputs,
277 Eigen::MatrixXf* output)
override;
280 std::function<float(float)> kactivation_;
295 bool Load(
const apollo::prediction::LayerParameter& layer_pb)
override;
302 void Run(
const std::vector<Eigen::MatrixXf>& inputs,
303 Eigen::MatrixXf* output)
override;
307 Eigen::VectorXf sigma_;
308 Eigen::VectorXf gamma_;
309 Eigen::VectorXf beta_;
310 float epsilon_ = 0.0f;
311 float momentum_ = 0.0f;
313 bool center_ =
false;
329 bool Load(
const apollo::prediction::LayerParameter& layer_pb)
override;
336 void Run(
const std::vector<Eigen::MatrixXf>& inputs,
337 Eigen::MatrixXf* output)
override;
348 void SetState(
const std::vector<Eigen::MatrixXf>& states)
override;
354 void State(std::vector<Eigen::MatrixXf>* states)
const override;
364 void Step(
const Eigen::MatrixXf& input, Eigen::MatrixXf* output,
365 Eigen::MatrixXf* ht_1, Eigen::MatrixXf* ct_1);
376 Eigen::MatrixXf r_wi_;
377 Eigen::MatrixXf r_wf_;
378 Eigen::MatrixXf r_wc_;
379 Eigen::MatrixXf r_wo_;
381 Eigen::MatrixXf ht_1_;
382 Eigen::MatrixXf ct_1_;
383 std::function<float(float)> kactivation_;
384 std::function<float(float)> krecurrent_activation_;
386 bool return_sequences_ =
false;
387 bool stateful_ =
false;
388 bool use_bias_ =
false;
389 bool unit_forget_bias_ =
false;
402 bool Load(
const apollo::prediction::LayerParameter& layer_pb)
override;
409 void Run(
const std::vector<Eigen::MatrixXf>& inputs,
410 Eigen::MatrixXf* output)
override;
424 bool Load(
const apollo::prediction::LayerParameter& layer_pb)
override;
431 void Run(
const std::vector<Eigen::MatrixXf>& inputs,
432 Eigen::MatrixXf* output)
override;
435 std::vector<int> input_shape_;
437 bool sparse_ =
false;
451 bool Load(
const apollo::prediction::LayerParameter& layer_pb)
override;
458 void Run(
const std::vector<Eigen::MatrixXf>& inputs,
459 Eigen::MatrixXf* output)
override;
virtual void ResetState()
Reset the internal state of a layer such as LSTM, GRU.
Definition: net_layer.h:60
Definition: net_layer.h:444
Activation is an activation network layer. Activation layer output is y = f(x), where x is the input...
Definition: net_layer.h:255
AvgPool1d is the average Pool 1d network layer.
Definition: net_layer.h:218
PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
virtual void State(std::vector< Eigen::MatrixXf > *states) const
Access to the internal state of a layer.
Definition: net_layer.h:72
Definition: net_layer.h:288
Conv1d is the convolution 1d network layer. Conv1d layer output is y = Conv(x, w), where x is the input, w the weight.
Definition: net_layer.h:149
virtual ~Layer()=default
Destructor.
Layer()=default
Constructor.
For a step-by-step description of the algorithm, see this tutorial.
Definition: net_layer.h:322
virtual void SetState(const std::vector< Eigen::MatrixXf > &states)
Set the internal state of a layer.
Definition: net_layer.h:66
MaxPool1d is the max Pool 1d network layer.
Definition: net_layer.h:185
Definition: net_layer.h:395
virtual bool Load(const apollo::prediction::LayerParameter &layer_pb)
Load layer parameters from a protobuf message.
int OrderNumber() const
Order number of a layer in a network.
Definition: net_layer.h:92
std::string Name() const
Name of a layer.
Definition: net_layer.h:86
virtual void Run(const std::vector< Eigen::MatrixXf > &inputs, Eigen::MatrixXf *output)=0
Compute the layer output from inputs.
Layer is a base class for specific network layers It contains a pure virtual function Run which must ...
Definition: net_layer.h:38
Dense is the forward fully connected network layer. Dense layer output is y = f(x*w + b)...
Definition: net_layer.h:108