cancel
Showing results for 
Search instead for 
Did you mean: 

Discrepancy in Predictions Between Laptop and STM Microcontroller for 1D CNN Model

khushbu_parmar
Associate

I am working on deploying a 1D CNN model on an STM microcontroller using STM32CubeMX with the X-CUBE-AI package to convert the TensorFlow Lite model into C code.

While testing the model, I noticed significant discrepancies in predictions:

  • On Laptop: Using the quantized model for inference gives reasonable predictions.
  • On Microcontroller: Using the same test data, the predictions differ substantially when validating the model on hardware.

Steps Taken:

  1. Ensured the test data was preprocessed identically for both laptop and microcontroller predictions.
  2. Used X-CUBE-AI to generate C code from the quantized TFLite model.
  3. Deployed the generated C code on the microcontroller for validation.

Questions:

  1. What could cause such prediction differences between the laptop and microcontroller?
  2. Could this issue be related to quantization or numerical precision differences during deployment?
  3. Are there any additional steps or configurations in X-CUBE-AI to ensure consistent performance between platforms?

 

 

1 REPLY 1
fauvarque.daniel
ST Employee

The STM32Cube.AI (i.e. X-CUBE-AI) library used on the target has it's own implementation of the neural network kernels so you may see different results between the results when executed in Python versus the target.

In the X-Cube-AI tool  you have 2 validate buttons, one to validate on the desktop using the same library as the one used on the target and one validate on target.

The results of the validate on desktop and validate on target should not differ as it is basically the same library. On the target we have some more optimizations based on the processor you use.

If you see a bad COS (less that 0.98) when you validate the model with real data then it is likely to be a bug in the implementation of the kernels that we should look at.

Could you share your model and ideally some input/output data so we can reproduce the issue ?

Thanks in advance

Regards


In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.