![]() |
AIfES 2
2.0.0
|
General Dense layer structure. More...
#include <ailayer_dense.h>
Data Fields | |
| ailayer_t | base |
| Inherited field members from general ailayer struct. | |
| uint16_t | result_shape [2] |
| Inference result tensor (ailayer.result) shape. | |
Layer configuration | |
Required configuration parameters for the layer These fields have to be configured by the user before calling the initializer function. | |
| uint32_t | neurons |
| Layer neurons count (number of outputs). | |
Trainable parameters | |
Data fields for the trainable parameters (weights, bias) of the layer | |
| aitensor_t | weights |
| Tensor containing the layer weights. | |
| aitensor_t | bias |
| Tensor containing the layer bias weights. | |
| uint16_t | weights_shape [2] |
| Weights tensor shape (n x m matrix). | |
| uint16_t | bias_shape [1] |
| Bias weights tensor shape (n x m matrix). | |
| aitensor_t * | trainable_params [2] |
| Pointer to the weights and biases (which are the trainable parameters). | |
| aitensor_t * | gradients [2] |
| Gradients structure for the back propagation algorithm. | |
| void * | optimem [2] |
| Memory field used by the trainings optimizer. | |
Math functions | |
Required data type specific math functions | |
| void(* | linear )(const aitensor_t *a, const aitensor_t *b, const aitensor_t *c, aitensor_t *result) |
| Required math function: Linear transformation. More... | |
| void(* | mat_mul_at )(const aitensor_t *a, const aitensor_t *b, aitensor_t *result) |
| Required math function: Matrix multiplication with transposed a. More... | |
| void(* | mat_mul_bt )(const aitensor_t *a, const aitensor_t *b, aitensor_t *result) |
| Required math function: Matrix multiplication with transposed b. More... | |
| void(* | tensor_add )(const aitensor_t *a, const aitensor_t *b, aitensor_t *result) |
| Required math function: Element wise tensor addition. More... | |
| void(* | sum_channelwise )(const aitensor_t *a, int8_t channel_axis, aitensor_t *result) |
| Required math function: Channel-wise sum. More... | |
General Dense layer structure.
| void(* linear) (const aitensor_t *a, const aitensor_t *b, const aitensor_t *c, aitensor_t *result) |
Required math function: Linear transformation.
Requires a math function that performs a linear transformation:
\[ result = a \cdot b \oplus c = a \cdot b + \left( \begin{array}{c} 1 \\ \vdots \\ 1 \\ \end{array}\right) \cdot c \]
| a | Matrix with dimension \( N \times K \) (input) |
| b | Matrix with dimension \( K \times M \) (input) |
| c | Laying vektor with dimension \( 1 \times M \) (input) |
| result | Matrix with dimension \( N \times M \) (output) |
| void(* mat_mul_at) (const aitensor_t *a, const aitensor_t *b, aitensor_t *result) |
Required math function: Matrix multiplication with transposed a.
Requires a math function that performs a matrix multiplication on two 2D tensors:
\[ result = a^T \cdot b \]
| a | Matrix with dimension \( K \times N \) (input) |
| b | Matrix with dimension \( K \times M \) (input) |
| result | Matrix with dimension \( N \times M \) (output) |
| void(* mat_mul_bt) (const aitensor_t *a, const aitensor_t *b, aitensor_t *result) |
Required math function: Matrix multiplication with transposed b.
Requires a math function that performs a matrix multiplication on two 2D tensors:
\[ result = a \cdot b^T \]
| a | Matrix with dimension \( N \times K \) (input) |
| b | Matrix with dimension \( M \times K \) (input) |
| result | Matrix with dimension \( N \times M \) (output) |
| void(* sum_channelwise) (const aitensor_t *a, int8_t channel_axis, aitensor_t *result) |
Required math function: Channel-wise sum.
Requires a math function that calculates the sum of all elements of each channel c. The result tensor is 1D.:
\[ result_c = \sum_i(a_{ci}) \]
| void(* tensor_add) (const aitensor_t *a, const aitensor_t *b, aitensor_t *result) |
Required math function: Element wise tensor addition.
Requires a math function that adds two tensors element-wise:
\[ result = a + b \]