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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.