2025-07-31 4:19 AM - last edited on 2025-07-31 7:14 AM by Andrew Neil
I validated the AI network using the‘Validate on desktop‘ tool,and the accuracy was high.But when I debugged the AI C-program(generated by CUBE AI) with the same input data, the result have large difference with correct output values.Could you help me understand the reason for this discrepancy.The MCU is STM32G4 Series
the network is run in this function:
batch = ai_network_run(network, ai_input, ai_output);
I only changed this two function in app_x-cube-ai.c:
acquire_and_process_data()
{
float test_data[4] = {1.094757,20,1,0};
ai_input->data = test_data;
float inputread[4];
for(int idx=0;idx<4;idx++)
{
inputread[idx] = *((float*)(ai_input->data)+idx);
}
}
post_process()
{
float outputread[2] = {0};
for(int idx=0;idx<2;idx++)
{
outputread[idx] = *((float*)(ai_output->data)+idx);
}
}
Edited to apply source code formatting - please see How to insert source code for future reference.
2025-07-31 7:35 AM - edited 2025-07-31 7:36 AM
Hello @Hamanken
Could you run a validate on target to see if you get a good COS, example:
In the process of using AI on a MCU you can lose accuracy at multiple steps:
By looking at the cos with the model running on target, we can first see if this seems to come from your model or from your code.
Have a good day,
Julian