Apollo 11.0
自动驾驶开放平台
apollo::prediction::network::BatchNormalization类 参考

#include <net_layer.h>

类 apollo::prediction::network::BatchNormalization 继承关系图:
apollo::prediction::network::BatchNormalization 的协作图:

Public 成员函数

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
 
- Public 成员函数 继承自 apollo::prediction::network::Layer
 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
 

详细描述

在文件 net_layer.h288 行定义.

成员函数说明

◆ Load()

bool apollo::prediction::network::BatchNormalization::Load ( const apollo::prediction::LayerParameter &  layer_pb)
overridevirtual

Load the parameter from a pb message

参数
Apb message contains the parameters
返回
True is loaded successively, otherwise False

重载 apollo::prediction::network::Layer .

在文件 net_layer.cc269 行定义.

269 {
270 if (!Layer::Load(layer_pb)) {
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
Definition net_layer.cc:32
#define AERROR
Definition log.h:44
bool LoadTensor(const TensorParameter &tensor_pb, Eigen::MatrixXf *matrix)
load matrix value from a protobuf message
Definition net_util.cc:66

◆ Run()

void apollo::prediction::network::BatchNormalization::Run ( const std::vector< Eigen::MatrixXf > &  inputs,
Eigen::MatrixXf *  output 
)
overridevirtual

Compute the layer output from inputs

参数
Inputsto a network layer
Outputof a network layer will be returned

实现了 apollo::prediction::network::Layer.

在文件 net_layer.cc304 行定义.

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}

该类的文档由以下文件生成: