| AIfES 2 2.0.0

Data Structures | Typedefs | Functions
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_t * | aiopti_sgd_f32_default (aiopti_sgd_f32_t *opti)
| Initializes a SGD optimizer with the F32 default implementation. More...
aiopti_t * | aiopti_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

Copyright
  Copyright (C) 2020-2023 Fraunhofer Institute for Microelectronic Circuits and Systems. All rights reserved.
  AIfES is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
  This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
  You should have received a copy of the GNU Affero General Public License along with this program. If not, see https://www.gnu.org/licenses/.

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
};
aiopti_sgd_f32
Data-type specific SGD optimizer struct for F32 .
Definition: aiopti_sgd_default.h:49
aiopti_sgd_f32::learning_rate
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_sgd_f32_default
aiopti_t * aiopti_sgd_f32_default(aiopti_sgd_f32_t *opti)
Initializes a SGD optimizer with the F32 default implementation.
aiopti
AIfES optimizer interface.
Definition: aifes_core.h:438

Parameters

  *opti | The 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)
};
aiopti_sgd_q31
Data-type specific SGD optimizer struct for Q31 .
Definition: aiopti_sgd_default.h:61
aiopti_sgd_q31::learning_rate
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_sgd_q31_default
aiopti_t * aiopti_sgd_q31_default(aiopti_sgd_q31_t *opti)
Initializes a SGD optimizer with the Q31 default implementation.

Parameters

  *opti | The optimizer structure to initialize.

Returns
  The (successfully) initialized optimizer structure.