首页 > 解决方案 > Pass Input to tensorflow lite model in Android

问题描述

I have created a neural network that take numerical data as input and saved it as tensorflow lite model using python. I am trying to pass input to the model in Android. Shape of ndarray is 1*3

Sample of the input in python is as follows

np.array([[-0.276786765 ,8.41897583008  ,-0.0222015380859]])

But i do not know to create the same input in java to pass it to model.

I tried using nd4j library. But still not able to write the proper code to create the input which is required by the model.

标签: pythontensorflowneural-networktensorflow-lite

解决方案


假设您使用的是TensorFlow Lite,您可以使用以下方法提供 1x3 输入:

float[] innerInput = {-0.276786765 ,8.41897583008  ,-0.0222015380859
float[][] input = {innerInput};
interpreter.run(input, output);

推荐阅读