Created
October 20, 2017 23:06
-
-
Save lobrien/eb7aee3484e12128fbca17c003dd7f43 to your computer and use it in GitHub Desktop.
Android impl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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