Skip to content

Instantly share code, notes, and snippets.

@lobrien
Created October 20, 2017 23:06
Show Gist options
  • Select an option

  • Save lobrien/eb7aee3484e12128fbca17c003dd7f43 to your computer and use it in GitHub Desktop.

Select an option

Save lobrien/eb7aee3484e12128fbca17c003dd7f43 to your computer and use it in GitHub Desktop.
Android impl
public class TensorflowInferencePredictor : ITidePredictor
{
const string MODEL_FILE_URL = "file:///android_asset/TF_LSTM_Inference.pb";
const string INPUT_ARGUMENT_NAME = "lstm_1_input";
const string OUTPUT_VARIABLE_NAME = "output_node0";
const int OUTPUT_SIZE = 100;
TensorFlowInferenceInterface inferenceInterface;
public TensorflowInferencePredictor(AssetManager assetManager)
{
inferenceInterface = new TensorFlowInferenceInterface(assetManager, MODEL_FILE_URL);
}
public float[] Predict(float[] inputSeaLevels)
{
inferenceInterface.Feed(INPUT_ARGUMENT_NAME, inputSeaLevels, inputSeaLevels.Length, 1, 1);
inferenceInterface.Run(new string[] { OUTPUT_VARIABLE_NAME });
float[] predictions = new float[OUTPUT_SIZE];
inferenceInterface.Fetch(OUTPUT_VARIABLE_NAME, predictions);
return predictions;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment