61 #ifndef AILAYER_BATCH_NORM
62 #define AILAYER_BATCH_NORM
64 #define AIFES_CHANNELS_FIRST 1
65 #define AIFES_CHANNELS_LAST -1
355 #ifdef AIDEBUG_PRINT_MODULE_SPECS
void ailayer_batch_norm_backward(ailayer_t *self)
Calculate the backward pass for the given Batch Normalization layer.
uint32_t ailayer_batch_norm_sizeof_trainmem(const ailayer_t *self)
Calculate and return the memory size needed by this layer for training.
void ailayer_batch_norm_forward(ailayer_t *self)
Calculate the forward pass for given Batch Normalization layer.
ailayer_t * ailayer_batch_norm(ailayer_batch_norm_t *layer, ailayer_t *input_layer)
Initialize and connect the given Batch Normalization layer.
void ailayer_batch_norm_set_trainmem(ailayer_t *self, void *memory_ptr)
Distribute provided memory to the gradients pointers.
void ailayer_batch_norm_print_specs(const ailayer_t *self)
Print the layer specification.
uint32_t ailayer_batch_norm_sizeof_paramem(const ailayer_t *self)
Calculate and return the parameter memory size needed for this layer.
void ailayer_batch_norm_set_paramem(ailayer_t *self, void *memory_ptr)
Distribute provided memory to the parameter pointers.
void ailayer_batch_norm_calc_result_shape(ailayer_t *self)
Calculate the shape of the result tensor (ailayer.result)
const aicore_layertype_t * ailayer_batch_norm_type
Batch Normalization layer type.
Math functions for F32 data type, default implementation.
Type indicator of the layer.
Definition: aifes_core.h:82
General Batch Normalization layer structure.
Definition: ailayer_batch_normalization.h:75
void(* empirical_variance_channelwise)(const aitensor_t *x, int8_t channel_axis, const aitensor_t *means, aitensor_t *variances)
Required math function: Channel-wise empirical variance calculation.
Definition: ailayer_batch_normalization.h:145
uint16_t parameter_shape[1]
Shape of the parameter vectors ( ).
Definition: ailayer_batch_normalization.h:109
aitensor_t * gradients[2]
Gradients of and for the back propagation algorithm.
Definition: ailayer_batch_normalization.h:100
void(* d_batch_norm)(const aitensor_t *x_in, int8_t axis, const aitensor_t *means, const aitensor_t *vars, const aitensor_t *betas, const aitensor_t *gammas, const aitensor_t *delta_out, const void *eps, aitensor_t *delta_in, aitensor_t *d_betas, aitensor_t *d_gammas)
Required math function: Gradients of Batch Normalization.
Definition: ailayer_batch_normalization.h:204
void * momentum
Momentum for the exponential moving average of means and variances.
Definition: ailayer_batch_normalization.h:85
aitensor_t * variances
Vector of the variances ( ).
Definition: ailayer_batch_normalization.h:112
void * optimem[2]
Memory field used by the trainings optimizer.
Definition: ailayer_batch_normalization.h:101
void(* batch_norm)(const aitensor_t *x, int8_t channel_axis, const aitensor_t *means, const aitensor_t *variances, const aitensor_t *offsets, const aitensor_t *scales, const void *eps, aitensor_t *result)
Required math function: Batch Normalization.
Definition: ailayer_batch_normalization.h:176
void * eps
Small constant for numeric stability.
Definition: ailayer_batch_normalization.h:86
void(* empirical_mean_channelwise)(const aitensor_t *x, int8_t channel_axis, aitensor_t *means)
Required math function: Channel-wise empirical mean calculation.
Definition: ailayer_batch_normalization.h:131
aitensor_t gammas
Vector of the scale parameters ( ).
Definition: ailayer_batch_normalization.h:94
aitensor_t betas
Vector of the shift parameters ( ).
Definition: ailayer_batch_normalization.h:93
aitensor_t * means
Vector of the means ( ).
Definition: ailayer_batch_normalization.h:111
ailayer_t base
Inherited field members from general ailayer struct.
Definition: ailayer_batch_normalization.h:76
aitensor_t moving_variances
Vector of the moving averages of the variance (required for inference).
Definition: ailayer_batch_normalization.h:97
void(* exponential_moving_average)(const aitensor_t *new_data, const void *momentum, aitensor_t *average)
Required math function: Exponential moving average.
Definition: ailayer_batch_normalization.h:158
aitensor_t moving_means
Vector of the moving averages of the means (required for inference).
Definition: ailayer_batch_normalization.h:96
aitensor_t * trainable_params[2]
Pointer to and (which are the trainable parameters).
Definition: ailayer_batch_normalization.h:99
int8_t channel_axis
Index of the channel axis (1 for channels first, -1 for channels last)
Definition: ailayer_batch_normalization.h:84
AIfES layer interface.
Definition: aifes_core.h:252
A tensor in AIfES.
Definition: aifes_math.h:89