Running the TensorFlow and Keras models on Android
It turns out it's like walking on the beach using the models on Android - we don't even need to use the custom TensorFlow Android library as we did in the last chapter, although we have to use the custom TensorFlow library (not the TensorFlow pod as of February 2018) on iOS. The TensorFlow Android library built with compile 'org.tensorflow:tensorflow-android:+'
in the build.gradle
file must have more complete data type support for the Less
Op than the TensorFlow pod for iOS does.
To test the models in Android, create a new Android app StockPrice and add the two model files to its assets
folder. Then add a couple of buttons and a TextView
in the layout and define some fields and constants in the MainActivity.java
:
private static final String TF_MODEL_FILENAME = "file:///android_asset/amzn_tf_frozen.pb"; private static final String KERAS_MODEL_FILENAME = "file:///android_asset/amzn_keras_frozen.pb"; private static final String INPUT_NODE_NAME_TF...