Digit classifier

Now let's write the classifier. Inside of this, we will first load the model file. This method reads the model from the assets folder and loads it into the memory:

/** Memory-map the model file in Assets. */private MappedByteBuffer loadModelFile(Activity activity) throws IOException {    AssetFileDescriptor fileDescriptor =                    activity.getAssets().openFd(getModelPath());    FileInputStream inputStream = new           FileInputStream(fileDescriptor.getFileDescriptor());          FileChannel fileChannel = inputStream.getChannel();          long startOffset = fileDescriptor.getStartOffset();          long declaredLength = fileDescriptor.getDeclaredLength();          return fileChannel.map(FileChannel.MapMode.READ_ONLY,                                             startOffset, declaredLength);}

Now let's write the TensorFlow ...

Get Machine Learning Projects for Mobile Applications now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.