Linked Questions

Popular Questions

How to test Tensorflowlite model with multiple inputs?

Asked by At

I created a simple MLP Regression Keras model with 4 inputs and one output. I converted this model to TFlite now I'm just trying to find out how to test it on android studio. How can I input multiple 4D objects to test in Java? The following gives an error when trying to run the model:

try{
            tflite = new Interpreter(loadModelFile());
        }
        catch(Exception ex){
            ex.printStackTrace();
        }   

double[][] inp= new double[1][4];
    inp[0][1]= 0;
    inp[0][0] = 0;
    inp[0][2]= 0;
    inp[0][3]=-2.01616982303105;

    double[] output = new double[100];

    tflite.run(inp,output);

EDIT: Here is the model I originally created:

# create model
model = Sequential()
model.add(Dense(50, activation="tanh", input_dim=4, 
kernel_initializer="random_uniform", name="input_tensor"))
model.add(Dense(50, activation="tanh", 
kernel_initializer="random_uniform"))
model.add(Dense(1, activation="linear", 
kernel_initializer='random_uniform', name="output_tensor"))

Related Questions