AIfES 2  2.0.0
ailayer_batch_normalization_default.h File Reference

Default implementation of the Batch Normalization layer . More...

Go to the source code of this file.

Data Structures

struct  ailayer_batch_norm_f32
 Data-type specific Batch Normalization layer struct for F32 . More...
 

Typedefs

typedef struct ailayer_batch_norm_f32 ailayer_batch_norm_f32_t
 

Functions

ailayer_tailayer_batch_norm_f32_default (ailayer_batch_norm_f32_t *layer, ailayer_t *input_layer)
 Initializes and connect a Batch Normalization layer with the F32 default implementation. More...
 
ailayer_tailayer_batch_norm_cfirst_f32_default (ailayer_batch_norm_f32_t *layer, ailayer_t *input_layer)
 Initializes and connect a Batch Normalization layer (channels first) with the F32 default implementation. More...
 
ailayer_tailayer_batch_norm_chw_f32_default (ailayer_batch_norm_f32_t *layer, ailayer_t *input_layer)
 Initializes and connect a Batch Normalization layer (channels first) with the F32 default implementation. More...
 
ailayer_tailayer_batch_norm_cl_f32_default (ailayer_batch_norm_f32_t *layer, ailayer_t *input_layer)
 Initializes and connect a Batch Normalization layer (channels first) with the F32 default implementation. More...
 
ailayer_tailayer_batch_norm_clast_f32_default (ailayer_batch_norm_f32_t *layer, ailayer_t *input_layer)
 Initializes and connect a Batch Normalization layer (channels last) with the F32 default implementation. More...
 
ailayer_tailayer_batch_norm_hwc_f32_default (ailayer_batch_norm_f32_t *layer, ailayer_t *input_layer)
 Initializes and connect a Batch Normalization layer (channels first) with the F32 default implementation. More...
 
ailayer_tailayer_batch_norm_lc_f32_default (ailayer_batch_norm_f32_t *layer, ailayer_t *input_layer)
 Initializes and connect a Batch Normalization layer (channels first) with the F32 default implementation. More...
 
void ailayer_batch_norm_init_params_f32_default (ailayer_t *self)
 F32 default implementation of the ailayer.init_params function for the Batch Normalization layer More...
 

Detailed Description

Default implementation of the Batch Normalization layer .

Version
2.2.0

Hardware independent implementations of the Batch Normalization layer in F32 data-type.

For more information about the Batch Normalization layer refer to ailayer_batch_normalization.h.

Function Documentation

◆ ailayer_batch_norm_cfirst_f32_default()

ailayer_t* ailayer_batch_norm_cfirst_f32_default ( ailayer_batch_norm_f32_t layer,
ailayer_t input_layer 
)

Initializes and connect a Batch Normalization layer (channels first) with the F32 default implementation.

Code examples are given in the description of ailayer_batch_norm_f32_default().

Parameters
*layerThe layer structure to initialize.
*input_layerThe prior layer.
Returns
The (successfully) initialized layer structure.

◆ ailayer_batch_norm_chw_f32_default()

ailayer_t* ailayer_batch_norm_chw_f32_default ( ailayer_batch_norm_f32_t layer,
ailayer_t input_layer 
)

Initializes and connect a Batch Normalization layer (channels first) with the F32 default implementation.

Code examples are given in the description of ailayer_batch_norm_f32_default().

Parameters
*layerThe layer structure to initialize.
*input_layerThe prior layer.
Returns
The (successfully) initialized layer structure.

◆ ailayer_batch_norm_cl_f32_default()

ailayer_t* ailayer_batch_norm_cl_f32_default ( ailayer_batch_norm_f32_t layer,
ailayer_t input_layer 
)

Initializes and connect a Batch Normalization layer (channels first) with the F32 default implementation.

Code examples are given in the description of ailayer_batch_norm_f32_default().

Parameters
*layerThe layer structure to initialize.
*input_layerThe prior layer.
Returns
The (successfully) initialized layer structure.

◆ ailayer_batch_norm_clast_f32_default()

ailayer_t* ailayer_batch_norm_clast_f32_default ( ailayer_batch_norm_f32_t layer,
ailayer_t input_layer 
)

Initializes and connect a Batch Normalization layer (channels last) with the F32 default implementation.

Code examples are given in the description of ailayer_batch_norm_f32_default().

Parameters
*layerThe layer structure to initialize.
*input_layerThe prior layer.
Returns
The (successfully) initialized layer structure.

◆ ailayer_batch_norm_f32_default()

ailayer_t* ailayer_batch_norm_f32_default ( ailayer_batch_norm_f32_t layer,
ailayer_t input_layer 
)

Initializes and connect a Batch Normalization layer with the F32 default implementation.

Example: Create the layer structure with pretrained weights, means and variances:
In C:

// Use constant data only for inference. For training remove the const qualifier!!
const float means_data_bn[3] = {-0.743f, 1.133f, -0.05f};
const float vars_data_bn[3] = {0.9f, 1.0f, 0.87f};
const float betas_data_bn[3] = {0.1f, -0.1f, 0.0f};
const float gammas_data_bn[3] = {4.0f, 2.0f, 1.0f};
.momentum = 0.9f,
.eps = 1e-6f,
.base.moving_means = means_data_bn,
.base.moving_variances = vars_data_bn,
.base.betas = betas_data_bn,
.base.gammas = gammas_data_bn
};
Data-type specific Batch Normalization layer struct for F32 .
Definition: ailayer_batch_normalization_default.h:46
aiscalar_f32_t momentum
Storage for ailayer_batch_norm.momentum scalar in F32.
Definition: ailayer_batch_normalization_default.h:49

In C, C++ and on Arduino:

// Use constant data only for inference. For training remove the const qualifier!!
const float means_data_bn[3] = {-0.743f, 1.133f, -0.05f};
const float vars_data_bn[3] = {0.9f, 1.0f, 0.87f};
const float betas_data_bn[3] = {0.1f, -0.1f, 0.0f};
const float gammas_data_bn[3] = {4.0f, 2.0f, 1.0f};
ailayer_batch_norm_f32_t bn_layer = AILAYER_BATCH_NORM_F32_M(
/* momentum =*/ 0.9f,
/* eps =*/ 1e-6f,
/* means =*/ means_data_bn,
/* variances =*/ vars_data_bn,
/* betas (offset) =*/ betas_data_bn,
/* gammas (scale) =*/ gammas_data_bn
);

Example: Create the layer structure for automatic parameter distribution (e.g. for training):
In C:

.momentum = 0.9f,
.eps = 1e-6f
};

In C, C++ and on Arduino:

ailayer_batch_norm_f32_t bn_layer = AILAYER_BATCH_NORM_F32_A(
/* momentum =*/ 0.9f,
/* eps =*/ 1e-6f
);

Example: Initialize and connect the layer for data with channels first (all options are equivalent):

bn_layer.channel_axis = 1;
ailayer_t * ailayer_batch_norm_f32_default(ailayer_batch_norm_f32_t *layer, ailayer_t *input_layer)
Initializes and connect a Batch Normalization layer with the F32 default implementation.

or

ailayer_t * ailayer_batch_norm_cfirst_f32_default(ailayer_batch_norm_f32_t *layer, ailayer_t *input_layer)
Initializes and connect a Batch Normalization layer (channels first) with the F32 default implement...

or

ailayer_t * ailayer_batch_norm_chw_f32_default(ailayer_batch_norm_f32_t *layer, ailayer_t *input_layer)
Initializes and connect a Batch Normalization layer (channels first) with the F32 default implement...

or

ailayer_t * ailayer_batch_norm_cl_f32_default(ailayer_batch_norm_f32_t *layer, ailayer_t *input_layer)
Initializes and connect a Batch Normalization layer (channels first) with the F32 default implement...

Example: Initialize and connect the layer for data with channels last (all options are equivalent):

bn_layer.channel_axis = -1;

or

ailayer_t * ailayer_batch_norm_clast_f32_default(ailayer_batch_norm_f32_t *layer, ailayer_t *input_layer)
Initializes and connect a Batch Normalization layer (channels last) with the F32 default implementa...

or

ailayer_t * ailayer_batch_norm_hwc_f32_default(ailayer_batch_norm_f32_t *layer, ailayer_t *input_layer)
Initializes and connect a Batch Normalization layer (channels first) with the F32 default implement...

or

ailayer_t * ailayer_batch_norm_lc_f32_default(ailayer_batch_norm_f32_t *layer, ailayer_t *input_layer)
Initializes and connect a Batch Normalization layer (channels first) with the F32 default implement...
Parameters
*layerThe layer structure to initialize.
*input_layerThe prior layer.
Returns
The (successfully) initialized layer structure.

◆ ailayer_batch_norm_hwc_f32_default()

ailayer_t* ailayer_batch_norm_hwc_f32_default ( ailayer_batch_norm_f32_t layer,
ailayer_t input_layer 
)

Initializes and connect a Batch Normalization layer (channels first) with the F32 default implementation.

Code examples are given in the description of ailayer_batch_norm_f32_default().

Parameters
*layerThe layer structure to initialize.
*input_layerThe prior layer.
Returns
The (successfully) initialized layer structure.

◆ ailayer_batch_norm_init_params_f32_default()

void ailayer_batch_norm_init_params_f32_default ( ailayer_t self)

F32 default implementation of the ailayer.init_params function for the Batch Normalization layer

Implementation of ailayer.init_params.

The function will initialize the tensors for moving_means and betas with zeros and for moving_variances and gammas with ones.

Parameters
*selfThe layer structure

◆ ailayer_batch_norm_lc_f32_default()

ailayer_t* ailayer_batch_norm_lc_f32_default ( ailayer_batch_norm_f32_t layer,
ailayer_t input_layer 
)

Initializes and connect a Batch Normalization layer (channels first) with the F32 default implementation.

Code examples are given in the description of ailayer_batch_norm_f32_default().

Parameters
*layerThe layer structure to initialize.
*input_layerThe prior layer.
Returns
The (successfully) initialized layer structure.