AIfES 2  2.0.0
aiopti_sgd_default.h File Reference

Default implementation of the Stochastic Gradient Descend optimizer . More...

Go to the source code of this file.

Data Structures

struct  aiopti_sgd_f32
 Data-type specific SGD optimizer struct for F32 . More...
 
struct  aiopti_sgd_q31
 Data-type specific SGD optimizer struct for Q31 . More...
 

Typedefs

typedef struct aiopti_sgd_f32 aiopti_sgd_f32_t
 New data type name for code reduction.
 
typedef struct aiopti_sgd_q31 aiopti_sgd_q31_t
 New data type name for code reduction.
 
typedef struct aiopti_sgd_q7 aiopti_sgd_q7_t
 New data type name for code reduction.
 

Functions

aiopti_taiopti_sgd_f32_default (aiopti_sgd_f32_t *opti)
 Initializes a SGD optimizer with the F32 default implementation. More...
 
aiopti_taiopti_sgd_q31_default (aiopti_sgd_q31_t *opti)
 Initializes a SGD optimizer with the Q31 default implementation. More...
 

Detailed Description

Default implementation of the Stochastic Gradient Descend optimizer .

Version
2.2.0

Hardware independent implementations of the Stochastic Gradient Descend optimizer in F32 , Q31 data-type. For more information about the Stochastic Gradient Descend optimizer refer to aiopti_sgd.h.

Function Documentation

◆ aiopti_sgd_f32_default()

aiopti_t* aiopti_sgd_f32_default ( aiopti_sgd_f32_t opti)

Initializes a SGD optimizer with the F32 default implementation.

You can set the momentum to zero to save memory space.

Example: Create the optimizer structure (with disabled momentum):
In C:

aiopti_sgd_f32_t sgd_optimizer = {
.learning_rate = 0.01f,
.momentum = 0.0f
};
Data-type specific SGD optimizer struct for F32 .
Definition: aiopti_sgd_default.h:49
aiscalar_f32_t learning_rate
Storage for aiopti.learning_rate scalar in F32.
Definition: aiopti_sgd_default.h:52

In C, C++ and on Arduino:

aiopti_sgd_f32_t sgd_optimizer = AIOPTI_SGD_F32(0.01f);

Example: Create the optimizer structure (with enabled momentum):
In C:

aiopti_sgd_f32_t sgd_optimizer = {
.learning_rate = 0.01f,
.momentum = 0.9f
};

In C, C++ and on Arduino:

aiopti_sgd_f32_t sgd_optimizer = AIOPTI_SGD_WITH_MOMENTUM_F32(0.01f, 0.9f);

Example: Initialize the optimizer:

aiopti_t *optimizer;
optimizer = aiopti_sgd_f32_default(&sgd_optimizer);
aiopti_t * aiopti_sgd_f32_default(aiopti_sgd_f32_t *opti)
Initializes a SGD optimizer with the F32 default implementation.
AIfES optimizer interface.
Definition: aifes_core.h:438
Parameters
*optiThe optimizer structure to initialize.
Returns
The (successfully) initialized optimizer structure.

◆ aiopti_sgd_q31_default()

aiopti_t* aiopti_sgd_q31_default ( aiopti_sgd_q31_t opti)

Initializes a SGD optimizer with the Q31 default implementation.

You can set the momentum to zero to save memory space.

Example: Create the optimizer structure (with disabled momentum):
In C:

aiopti_sgd_q31_t sgd_optimizer = {
.learning_rate = AISCALAR_Q31(0.01f, 28, 0),
.momentum = AISCALAR_Q31(0.0f, 0, 0)
};
Data-type specific SGD optimizer struct for Q31 .
Definition: aiopti_sgd_default.h:61
aiscalar_q31_t learning_rate
Data-type specific learning rate.
Definition: aiopti_sgd_default.h:64

In C, C++ and on Arduino:

aiopti_sgd_q31_t sgd_optimizer = AIOPTI_SGD_Q31(AISCALAR_Q31(0.01f, 28, 0));

Example: Create the optimizer structure (with enabled momentum):
In C:

aiopti_sgd_q31_t sgd_optimizer = {
.learning_rate = AISCALAR_Q31(0.01f, 28, 0),
.momentum = AISCALAR_Q31(0.9f, 28, 0)
};

In C, C++ and on Arduino:

aiopti_sgd_q31_t sgd_optimizer = AIOPTI_SGD_WITH_MOMENTUM_Q31(AISCALAR_Q31(0.01f, 28, 0), AISCALAR_Q31(0.9f, 28, 0));

Example: Initialize the optimizer:

aiopti_t *optimizer;
optimizer = aiopti_sgd_q31_default(&sgd_optimizer);
aiopti_t * aiopti_sgd_q31_default(aiopti_sgd_q31_t *opti)
Initializes a SGD optimizer with the Q31 default implementation.
Parameters
*optiThe optimizer structure to initialize.
Returns
The (successfully) initialized optimizer structure.