Interpreter output returns NAN on arduino

we have tried invoking the interpreter in python and it works fine, however, deploying the model in arduino nano 33 ble returns all NAN without an error message
here’s the code i’ve tried different data array but didn’t work, i dont know whats wrong with it, can someone help me?

//#include <ArduinoBLE.h>
#include <Arduino_LSM9DS1.h>

#include <cmath>

#include <TensorFlowLite.h>
#include "tensorflow/lite/micro/micro_interpreter.h"
#include "tensorflow/lite/micro/micro_log.h"
#include "tensorflow/lite/micro/micro_mutable_op_resolver.h"
#include "tensorflow/lite/micro/system_setup.h"
#include "tensorflow/lite/schema/schema_generated.h"
#include "tensorflow/lite/micro/all_ops_resolver.h"
#include "realtime_test_finalData.h"


#define DEBUG 1
const float accelerationThreshold = 2.1; // threshold of significant in G's
const int numSamples = 10; //for audio 44.1*1000
int samplesRead = numSamples;

float imuarray [] = {-9.70000e-01,
    2.20000e-01,
    1.50000e-01,
    1.36100e+01,
    2.32000e+00,
    6.70000e-01,
    3.56300e+01,
   -1.15800e+01,
    4.58600e+01,
    1.43000e-01,
    7.91000e-01,
    1.02000e-01,
    4.46780e+01,
    3.00290e+01,
   -2.22780e+01,
    4.97680e+01,
    5.30270e+01,
    5.24290e+01,

  -9.70000e-01,
    1.80000e-01,
    1.90000e-01,
   -1.13500e+01,
    6.10000e+00,
   -5.50000e-01,
    3.62700e+01,
   -1.14000e+01,
    4.43700e+01,
    5.84000e-01,
   -5.80000e-01,
    1.90000e-01,
   -2.04470e+01,
   -3.92460e+01,
   -1.68396e+02,
    4.88650e+01,
    5.40890e+01,
    5.22580e+01,

  -9.80000e-01,
    1.90000e-01,
    1.80000e-01,
    8.06000e+00,
    1.22000e+00,
    4.88000e+00,
    3.65400e+01,
   -1.10500e+01,
    4.48700e+01,
    2.21000e-01,
   -8.42000e-01,
    2.34000e-01,
   -3.27760e+01,
   -6.59200e+00,
   -2.48535e+02,
    4.58010e+01,
    6.02660e+01,
    5.19040e+01,

  -9.90000e-01,
    1.60000e-01,
    1.40000e-01,
   -1.20000e-01,
   -1.59000e+00,
    1.10000e+00,
    3.69300e+01,
   -1.16700e+01,
    4.31900e+01,
   -8.91000e-01,
   -6.76000e-01,
    3.45000e-01,
    8.01390e+01,
    9.94900e+00,
   -7.34250e+01,
    1.13400e+01,
    6.56860e+01,
    4.31880e+01,

  -9.60000e-01,
    1.80000e-01,
    1.40000e-01,
   -5.49000e+00,
   -6.00000e-02,
   -1.10000e+00,
    3.65100e+01,
   -1.12800e+01,
    4.18200e+01,
   -8.68000e-01,
   -4.56000e-01,
    2.69000e-01,
   -7.93000e-01,
    8.48400e+00,
   -1.10470e+01,
    9.09400e+00,
    5.47850e+01,
    5.02080e+01,

  -9.70000e-01,
    1.60000e-01,
    1.20000e-01,
   -1.20200e+01,
    4.30000e-01,
   -1.10000e+00,
    3.60100e+01,
   -1.17100e+01,
    4.08200e+01,
   -8.23000e-01,
   -4.78000e-01,
    2.24000e-01,
   -6.10000e-02,
   -1.28200e+00,
    8.54000e-01,
    8.52100e+00,
    5.54440e+01,
    4.94260e+01,

  -9.60000e-01,
    1.80000e-01,
    1.50000e-01,
    3.78000e+00,
    6.00000e-02,
    6.00000e-02,
    3.63500e+01,
   -1.15500e+01,
    4.11900e+01,
   -8.45000e-01,
   -4.58000e-01,
    2.56000e-01,
    4.88000e-01,
    1.22000e-01,
   -3.66000e-01,
    8.76500e+00,
    5.47610e+01,
    4.92920e+01,

  -9.60000e-01,
    1.70000e-01,
    1.30000e-01,
    3.10000e-01,
   -1.80000e-01,
   -3.70000e-01,
    3.59500e+01,
   -1.15000e+01,
    4.14200e+01,
   -8.39000e-01,
   -4.74000e-01,
    2.50000e-01,
    2.07500e+00,
    1.28200e+00,
    5.49000e-01,
    8.72800e+00,
    5.50540e+01,
    4.88650e+01,

  -9.70000e-01,
    1.70000e-01,
    1.30000e-01,
    1.22000e+00,
   -1.20000e-01,
   -6.00000e-02,
    3.64000e+01,
   -1.16700e+01,
    4.21100e+01,
   -8.37000e-01,
   -4.66000e-01,
    2.50000e-01,
   -5.49000e-01,
    1.22000e-01,
    4.27000e-01,
    8.80100e+00,
    5.50780e+01,
    4.84250e+01,

  -9.60000e-01,
    1.60000e-01,
    1.40000e-01,
    1.10000e+00,
   -4.30000e-01,
    4.90000e-01,
    3.66600e+01,
   -1.11900e+01,
    4.28100e+01,
   -8.40000e-01,
   -4.63000e-01,
    2.57000e-01,
   -2.62500e+00,
   -1.64800e+00,
    1.40400e+00,
    8.61800e+00,
    5.51270e+01,
    5.04520e+01
                    };

float emgarray [] = {  0,
   224,

   0,
   232,

    0,
   196,

  0,
   187,

    0,
   184,

   0,
   184,

  0,
   183,

    0,
   183,

   0,
   183,

  0,
   184};


// array to map gesture index to a name
const char* GESTURES[] = {
  "marriage",
  "happy",
  "work",
  "wait",
  "slam",
  "urgent",
  "weather",
  "ambulance",
  "beauty",
  "cold",
  "congrats",
  "friend",
  "help",
  "me",
  "meet",
  "place",
  "pls",
  "police",
  "scared",
  "sick",
  "sorry",
  "thanks",
  "where",
  "you",
  "hungry"
};
int NUM_GESTURES = 25;
//-------------------------------------pointers-----------------


namespace {

const tflite::Model* tflModel = nullptr;
tflite::MicroInterpreter* tflInterpreter = nullptr;
TfLiteTensor* tflInputTensor = nullptr;
TfLiteTensor* tflInputTensor0 = nullptr;
TfLiteTensor* tflOutputTensor = nullptr;

//tensor arena
constexpr int kTensorArenaSize = 45 * 1024;
alignas(16) uint8_t tensor_arena[kTensorArenaSize];
//periph

float x, y, z;

float gx, gy, gz;

float mx, my, mz;

float emg1;

//cent

float aX, aY, aZ;

float gX, gY, gZ;

float mX, mY, mZ;

float emg2R;

}




void setup() {

  Serial.begin(9600);
  Serial1.begin(9600);

  //wait for serial to connect
  while (!Serial);



  if (!IMU.begin()) {
    while (1);
  }
  // get the TFL representation of the model byte array
  tflModel = tflite::GetModel(g_realtime_test_finalData);
  if (tflModel->version() != TFLITE_SCHEMA_VERSION) {
    Serial.println("Model schema mismatch!");
    while (1);
  }



  static tflite::AllOpsResolver resolver;

  // Create an interpreter to run the model
  static tflite::MicroInterpreter static_interpreter(
    tflModel, resolver, tensor_arena, kTensorArenaSize);
  tflInterpreter = &static_interpreter;


  // Allocate memory for the model's input and output tensors
  // tflInterpreter->AllocateTensors();

  TfLiteStatus allocate_status = tflInterpreter->AllocateTensors();
  if (allocate_status != kTfLiteOk) {
    Serial.println("cant allocate tensor");
    while (1);
  }


  // Get pointers for the model's input and output tensors
  tflInputTensor0 = tflInterpreter->input(0);
  tflInputTensor = tflInterpreter->input(1);
  tflOutputTensor = tflInterpreter->output(0);

}



void loop() {


  while (1) {

    while (samplesRead == numSamples) {

      if (IMU.accelerationAvailable()) {

        // read the acceleration data

        IMU.readAcceleration(aX, aY, aZ);



        // sum up the absolutes

        float aSum = fabs(aX) + fabs(aY) + fabs(aZ);



        // check if it's above the threshold

        if (aSum >= accelerationThreshold) {

          // reset the sample read count

          samplesRead = 0;

          break;

        }

      }
    }


    while (samplesRead < numSamples) {

        samplesRead++;
      }

      if (samplesRead == numSamples) {
#if DEBUG
        Serial.print("Number of dimensions: ");
        Serial.println(tflInputTensor->dims->size);
        Serial.print("Dim 1 size: ");
        Serial.println(tflInputTensor->dims->data[0]);
        Serial.print("Dim 2 size: ");
        Serial.println(tflInputTensor->dims->data[1]);
        Serial.print("Dim 3 size: ");
        Serial.println(tflInputTensor->dims->data[2]);
        Serial.print("Dim 4 size: ");
        Serial.println(tflInputTensor->dims->data[3]);
        Serial.print("Input type: ");
        Serial.println(tflInputTensor->type);


        Serial.print("Number of dimensions: ");
        Serial.println(tflInputTensor0->dims->size);
        Serial.print("Dim 1 size: ");
        Serial.println(tflInputTensor0->dims->data[0]);
        Serial.print("Dim 2 size: ");
        Serial.println(tflInputTensor0->dims->data[1]);
        Serial.print("Dim 3 size: ");
        Serial.println(tflInputTensor0->dims->data[2]);
        Serial.print("Dim 4 size: ");
        Serial.println(tflInputTensor0->dims->data[3]);
        Serial.print("Input type: ");
        Serial.println(tflInputTensor0->type);


        Serial.print("Number of dimensions: ");
        Serial.println(tflOutputTensor->dims->size);
        Serial.print("Dim 1 size: ");
        Serial.println(tflOutputTensor->dims->data[0]);
        Serial.print("Dim 2 size: ");
        Serial.println(tflOutputTensor->dims->data[1]);
        Serial.print("Input type: ");
        Serial.println(tflOutputTensor->type);
#endif

        for (int i = 0; i < 20; i++) {
          tflInputTensor0->data.f[i] = emgarray[i];
        }
        for (int i = 0; i < 180; i++) {
          tflInputTensor->data.f[i] = imuarray[i];
        }

        for (int i = 0; i < 20; i++) {
          Serial.println(tflInputTensor0->data.f[i]);
        }
        for (int i = 0; i < 180; i++) {
          Serial.println(tflInputTensor->data.f[i]);
        }

        Serial.println();
        // Run inferencing
        TfLiteStatus invokeStatus = tflInterpreter->Invoke();
        if (invokeStatus != kTfLiteOk) {
          Serial.println("Invoke failed!");
          while (1);
          return;
        }
        int index = 0;
        float temp = 0;
    Serial.print("Number of dimensions: ");
        Serial.println(tflOutputTensor->dims->size);
        Serial.print("Dim 1 size: ");
        Serial.println(tflOutputTensor->dims->data[0]);
        Serial.print("Dim 2 size: ");
        Serial.println(tflOutputTensor->dims->data[1]);
        Serial.print("Input type: ");
        Serial.println(tflOutputTensor->type);
        tflOutputTensor = tflInterpreter->output(0);

        // Loop through the output tensor values from the model
        for (int i = 0; i < NUM_GESTURES; i++) {
          if (tflOutputTensor->data.f[i] > temp) {
            temp = tflOutputTensor->data.f[i];
            index = i;
          }
          else {
            temp = temp;
          }
          Serial.print(GESTURES[i]);
          Serial.print(": ");
          Serial.println(double(tflOutputTensor->data.f[i]), 20);
          Serial.println();
        }

        Serial.println(index);

        //send index to app
        Serial1.print(index);
      }

    }
  }
}