Different prediction result on real board and example c program

I am trying to porting a classify solution on laptop’s embedded controller. It use Microchip MEC1723 which is not on support list, so I downloaded c++ library and start to porting it.

At beginning, I clone the project from below. After debug, this library is workable on my MCU with real sensor’s data.
[Tutorial: Continuous motion recognition - Data acquisition - Edge Impulse](https://Tutorial: Continuous motion recognition)

To clarify that my MCU can run ML program, then I started to build my own project.
Project ID:135643
But it is strange that prediction result which is different on real device.
For example, I load " idle_13_111223" sample’s first raw data in live classification.
It has correct result if I merge library to Edge Impulse’s standalone c program.

But if I use same “fixed” data on my MCU, result is totally incorrect. Below is the result from MCU.

game: 0.0407
idle: 0.014
normal: 0.8202
video: 0.1250

Does anyone can help to give some clue to keep debugging? I search the forum found that most problems are different result from live classification and library. But my problem is same library but different result on c problem and mcu board.

Hi @hyde545,

Could you check if generated features out of the DSP block are the same?
You can display them if you set the debug flag to true in the run_classifier() function (last argument).


Temporary solution, set EI_CLASSIFIER_ALLOCATION_STATIC define can fix the issue. Suspect it might related to my MCU’s heap setting. Will keep debugging.

Debug procedure.

  1. Checked generated features, it is the same between two programs.
  2. Enable EI_CLASSIFIER_PRINT_STATE in trained_model_compiled.cpp to check detail data.
  3. Found each layer’s input 1 data is incorrect.
  4. Input 1 alloc_type is kTfLiteArenaRw.
  5. Should be my “tensor_arena” related problems.
1 Like