#include <net_layer.h>
|
| bool | Load (const apollo::prediction::LayerParameter &layer_pb) override |
| | Load the parameter from a pb message
|
| |
| void | Run (const std::vector< Eigen::MatrixXf > &inputs, Eigen::MatrixXf *output) override |
| | Compute the layer output from inputs
|
| |
| | Layer ()=default |
| | Constructor
|
| |
| virtual | ~Layer ()=default |
| | Destructor
|
| |
| virtual void | ResetState () |
| | Reset the internal state of a layer such as LSTM, GRU
|
| |
| virtual void | SetState (const std::vector< Eigen::MatrixXf > &states) |
| | Set the internal state of a layer
|
| |
| virtual void | State (std::vector< Eigen::MatrixXf > *states) const |
| | Access to the internal state of a layer
|
| |
| std::string | Name () const |
| | Name of a layer
|
| |
| int | OrderNumber () const |
| | Order number of a layer in a network
|
| |
◆ Load()
| bool apollo::prediction::network::BatchNormalization::Load |
( |
const apollo::prediction::LayerParameter & |
layer_pb | ) |
|
|
overridevirtual |
Load the parameter from a pb message
- 参数
-
| A | pb message contains the parameters |
- 返回
- True is loaded successively, otherwise False
重载 apollo::prediction::network::Layer .
在文件 net_layer.cc 第 269 行定义.
269 {
271 AERROR <<
"Fail to Load the layer parameters!";
272 return false;
273 }
274
275 auto bn_pb = layer_pb.batch_normalization();
276 epsilon_ = static_cast<float>(bn_pb.epsilon());
277 axis_ = bn_pb.axis();
278 center_ = bn_pb.center();
279 scale_ = bn_pb.scale();
280 momentum_ = bn_pb.momentum();
281 if (!bn_pb.has_mu() || !
LoadTensor(bn_pb.mu(), &mu_)) {
282 AERROR <<
"Fail to Load mu!";
283 return false;
284 }
285 if (!bn_pb.has_sigma() || !
LoadTensor(bn_pb.sigma(), &sigma_)) {
286 AERROR <<
"Fail to Load sigma!";
287 return false;
288 }
289 if (scale_) {
290 if (!bn_pb.has_gamma() || !
LoadTensor(bn_pb.gamma(), &gamma_)) {
291 AERROR <<
"Fail to Load gamma!";
292 return false;
293 }
294 }
295 if (center_) {
296 if (!bn_pb.has_beta() || !
LoadTensor(bn_pb.beta(), &beta_)) {
297 AERROR <<
"Fail to Load beta!";
298 return false;
299 }
300 }
301 return true;
302}
virtual bool Load(const apollo::prediction::LayerParameter &layer_pb)
Load layer parameters from a protobuf message
bool LoadTensor(const TensorParameter &tensor_pb, Eigen::MatrixXf *matrix)
load matrix value from a protobuf message
◆ Run()
| void apollo::prediction::network::BatchNormalization::Run |
( |
const std::vector< Eigen::MatrixXf > & |
inputs, |
|
|
Eigen::MatrixXf * |
output |
|
) |
| |
|
overridevirtual |
Compute the layer output from inputs
- 参数
-
| Inputs | to a network layer |
| Output | of a network layer will be returned |
实现了 apollo::prediction::network::Layer.
在文件 net_layer.cc 第 304 行定义.
305 {
306 CHECK_EQ(inputs.size(), 1U);
307 Eigen::MatrixXf temp = (inputs[0].rowwise() - mu_.transpose());
308 Eigen::MatrixXf norm =
309 temp.array().rowwise() / (sigma_.array().sqrt() + epsilon_).transpose();
310 if (scale_) {
311 norm = norm.array().rowwise() * gamma_.transpose().array();
312 }
313 if (center_) {
314 norm = norm.rowwise() + beta_.transpose();
315 }
316 *output = norm;
317}
该类的文档由以下文件生成: