Convert 4-dimensional float array to FloatBuffer in Java

Viewed 23

I have a 4 dimensional float array of size [1][300][3][1] which I have to give as Input for a .tflite model built in python.

I tried converting the the 4D float array to a FloatBuffer using the below code.

FloatBuffer fb = FloatBuffer.allocate(1*300*3*1);
 for (int i = 0; i < 1; i++)
        {
            for (int j = 0; j < 300; j++)
            {
                for (int k = 0; k < 3; k++)
                {
                    for (int l = 0; l < 1; l++)
                    {
                        fb.put(inputData[i][j][k][l]);
                    }
                }
            }
        }
float[][] outputData = new float[1][16];
tflite.run(fb,outputData); 

I am able to get output but the iutput value is different when running it in python and with my Java code. Is the above code affecting the accuracy of the model?

0 Answers
Related