This is training data that receives 12 inputs and outputs 1, but strange values appear, so please check and review the code.
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#if defined ( __ICCARM__ )
#define AI_RAM _Pragma("location=\"AI_RAM\"")
#elif defined ( __CC_ARM ) || ( __GNUC__ )
#define AI_RAM __attribute__((section(".AI_RAM")))
#endif
/* System headers */
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
#include <inttypes.h>
#include <string.h>
#include "network.h"
#include "network_data.h"
#include "app_x-cube-ai.h"
#include "bsp_ai.h"
#include "aiSystemPerformance.h"
#include "ai_datatypes_defines.h"
#include <string.h>
#include "ai_datatypes_defines.h"
/* USER CODE BEGIN includes */
/* USER CODE END includes */
/* IO buffers ----------------------------------------------------------------*/
DEF_DATA_IN
DEF_DATA_OUT
/* Activations buffers -------------------------------------------------------*/
AI_ALIGNED(32)
AI_RAM
static ai_handle network = AI_HANDLE_NULL;
static uint8_t POOL_0_RAM[AI_NETWORK_DATA_ACTIVATION_1_SIZE];
ai_handle data_activations0[] = {POOL_0_RAM};
/* Entry points --------------------------------------------------------------*/
void MX_X_CUBE_AI_Init(void)
{
ai_error ai_err;
MX_UARTx_Init();
ai_network_params ai_params={
AI_NETWORK_DATA_WEIGHTS(ai_network_data_weights_get()),
AI_NETWORK_DATA_ACTIVATIONS(data_activations0)
};
printf("stm32 ai init \r\n");
ai_err = ai_network_create(&network,AI_NETWORK_DATA_CONFIG);
if (ai_err.type !=AI_ERROR_NONE)
{
printf("ERROR:could not create ai_network_create \r\n");
}
if (!ai_network_init(network,&ai_params))
{
printf("ERROR:could not create ai_network_init \r\n");
}
// aiSystemPerformanceInit();
/* USER CODE BEGIN 5 */
/* USER CODE END 5 */
}
void MX_X_CUBE_AI_Process(void)
{
float y_val;
((ai_float *)data_in_1)[0] = (ai_float)25.0f;
((ai_float *)data_in_1)[1] = (ai_float)23.0f;
((ai_float *)data_in_1)[2] = (ai_float)27.0f;
((ai_float *)data_in_1)[3] = (ai_float)30.0f;
((ai_float *)data_in_1)[4] = (ai_float)34.0f;
((ai_float *)data_in_1)[5] = (ai_float)47.0f;
((ai_float *)data_in_1)[6] = (ai_float)68.0f;
((ai_float *)data_in_1)[7] = (ai_float)130.0f;
((ai_float *)data_in_1)[8] = (ai_float)100.0f;
((ai_float *)data_in_1)[9] = (ai_float)10.0f;
((ai_float *)data_in_1)[10] = (ai_float)50.0f;
((ai_float *)data_in_1)[11] = (ai_float)58.0f;
ai_network_run(network, &data_ins[0], &data_outs[0]);
y_val = ((float *)data_out_1)[0];
printf("output: %f\r\n",y_val);
//aiSystemPerformanceProcess();
HAL_Delay(1000); /* delay 1s */
/* USER CODE BEGIN 6 */
/* USER CODE END 6 */
}