Hi, I am running into an issue where I am using 3x spectrogram blocks for feature extraction on 3 sensor inputs prior to inference as a workaround to a previous (DSP Error -1004) issue here.
A constraint I have is that my sample size is most of the time smaller than the selected window size and therefore I have chosen to zero-pad the samples for training and test which has resulted in good training and test results online.
I then transfer the model to a C/C++ app which is running locally and because I was getting the error on size mismatch (“The size of your ‘features’ array is not correct. Expected %d items, but had %lu\n”), I have adapted the demo C++ code (https://github.com/edgeimpulse/example-standalone-inferencing) so that I now pad the remainder of the sample with zeros to get to a correct length (I assume this is the same as online zero-pad). The demo app now accepts the input.
I run this but I end up where the online calculated features compare well with the local features up to a point and then they start to deviate. This seems to result in differing output for inference compared with the web classification.
I have checked that my padding of the “raw_features” variable is correct - here is my code for reference
if (raw_features.size() != EI_CLASSIFIER_DSP_INPUT_FRAME_SIZE) {
printf("The size of your 'features' array is not correct. Expected %d items, but had %lu\n",
EI_CLASSIFIER_DSP_INPUT_FRAME_SIZE, raw_features.size());
const size_t nonPaddedSize = raw_features.size();
const size_t numPaddingElements = EI_CLASSIFIER_DSP_INPUT_FRAME_SIZE - nonPaddedSize;
if (numPaddingElements > 0) {
raw_features.resize(nonPaddedSize + numPaddingElements, 0);
}
//return 1;
printf("Corrected the size. Expected %d items, have %lu\n",
EI_CLASSIFIER_DSP_INPUT_FRAME_SIZE, raw_features.size());
}
What I have noticed is that the online generated features have a lot of zeros after a bulk of numbers up front, whereas the locally generated features does not have the bulk of zeros on the backend of the features that are generated.
E.G.
Sample size = 645
Window size = 3000 (therefore fill 646 > 2999 with zeros)
Calculated features = 9801
Online X features - values 1 to 726 have a value, after this up to 3267 has zero as value
Local X features - have values up to 3267 with zeros interspersed without big block
Please help - perhaps there is something simple that I am doing wrong in padding or other ?