int main()
{
// Create the model and interpreter options.
TfLiteModel* model = TfLiteModelCreateFromFile("VNPAPA.tflite");
TfLiteInterpreterOptions* options = TfLiteInterpreterOptionsCreate();
TfLiteInterpreterOptionsSetNumThreads(options, 2);
// Create the interpreter.
TfLiteInterpreter* interpreter = TfLiteInterpreterCreate(model, options);
// Allocate tensors and populate the input tensor data.
TfLiteInterpreterAllocateTensors(interpreter);
TfLiteTensor* input_tensor = TfLiteInterpreterGetInputTensor(interpreter, 0);
float inputs[] = {1.0f,19.0f,4.0f,1.0f,0.0f,1.0f,0.0f,1.0f,1.0f};
TfLiteTensorCopyFromBuffer(input_tensor, inputs,sizeof(inputs) * sizeof(float));
// Execute inference.
TfLiteInterpreterInvoke(interpreter);
// Extract the output tensor data.
const TfLiteTensor* output_tensor = TfLiteInterpreterGetOutputTensor(interpreter, 0);
float outputs[2];
TfLiteTensorCopyToBuffer(output_tensor, outputs, 2 * sizeof(float));
printf("%f", outputs[0]);
// Dispose of the model and interpreter objects.
TfLiteInterpreterDelete(interpreter);
TfLiteInterpreterOptionsDelete(options);
TfLiteModelDelete(model);
}
So when I run the exact same from keras model in google colab, I get nice and concise results Around what I would expect to see.
But when I export the tflite model and run in in C program you see above, I get wast array of garbage data.
-0.000000
98539232544683341287260160.000000
0.000000
-0.000001
-0.000000
0.000000
-23981264472346816886445254628324933632.000000
10819050381292601344.000000```
Thank you in advance for helping out!
https://colab.research.google.com/drive/1eRan90fkk_0VldlWQfQkHvb_G038B5Hg?usp=sharing <- Link to the Python Training module