Question/Issue:
I am experiencing numerical mismatch between the feature extraction pipeline implemented in the generated C++ SDK (specifically the MFE block, as seen in edge-impulse-run-dsp.h) and standard Python/TensorFlow libraries (e.g., tf.signal or librosa). This mismatch prevents me from accurately aligning my model training results (in Python) with the inference results (on the target device running C++).
I need a bit-perfect replication of the Edge Impulse C++ DSP pipeline to be run in a Python/Jupyter Notebook environment so I can train my model with features that exactly match those computed during on-device inference.
Does Edge Impulse provide a Python utility, module, or Jupyter Notebook template that guarantees the exact same numerical result as the deployed C++ DSP?
Project ID:
Context/Use case:
I am training a custom model using a Python framework (TensorFlow/Keras). The model requires MFE features extracted from audio data. To ensure successful deployment, the MFE feature vector used for training must match exactly the feature vector generated by the C++ runtime on the target device.
Steps Taken:
- Extracted MFE features using the generated C++ SDK on the target.
- Extracted MFE features using Python (
tf.signal.stft+tf.signal.linear_to_mel_weight_matrix), ensuring all parameters (frame length, stride, Mel bins, sample rate) match the C++ configuration. - Disabled Pre-emphasis in both C++ and Python to eliminate that variable.
Expected Outcome:
The floating-point feature vectors generated by the C++ code should be numerically identical (or nearly identical, considering minor float differences) to the feature vectors generated by the Python tool.
Actual Outcome:
The feature vectors show significant numerical discrepancies (due to library implementation differences, FFT result handling, or rounding logic, such as the $0\text{ Hz}$ to $300\text{ Hz}$ check in older C++ versions).
Reproducibility:
- [x] Always
Environment:
- Platform: [Ex: ESP32, Raspberry Pi, Custom board]
- Build Environment Details: [Ex: Visual Studio Code]
- OS Version: [Ex: Ubuntu 22.04]
- Edge Impulse Version (Firmware):
- **Edge Impulse CLI Version:
Logs/Attachments:
Additional Information:
My primary concern is model accuracy degradation due to this feature alignment issue. A bit-perfect Python DSP module would solve this training/inference alignment problem.