• Stars
    star
    264
  • Rank 154,290 (Top 4 %)
  • Language
    C++
  • Created over 8 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Tensorflow MNIST demo on Android

TensorFlowAndroidMNIST - Android MNIST demo with TensorFlow

This is a demo app for Android with Tensorflow to detect handwritten digits.

image

This Android demo is based on Tensorflow tutorial.

MNIST For ML Beginners https://www.tensorflow.org/versions/r0.10/tutorials/mnist/beginners/index.html

Deep MNIST for Experts https://www.tensorflow.org/versions/r0.10/tutorials/mnist/pros/index.html

How to train model.

Training scripts for neural network model are located at

https://github.com/miyosuda/TensorFlowAndroidMNIST/tree/master/trainer-script

To create model by yourself, install Tensorflow and run python scripts like

$ python beginner.py

or

$ python expert.py

and locate exported .pb file to assets dir.

To export training model, I added some modification to original tutorial scripts.

Now Tensorflow cannot export network graph and trained network weight Variable at the same time, so we need to create another graph to export and convert Variable into constants.

After training is finished, converted trained Variable to numpy ndarray.

_W = W.eval(sess)
_b = b.eval(sess)

and then convert them into constant and re-create graph for exporting.

W_2 = tf.constant(_W, name="constant_W")
b_2 = tf.constant(_b, name="constant_b")

And then use tf.train.write_graph to export graph with trained weights.

How to build JNI codes

Native .so files are already built in this project, but if you would like to build it by yourself, please install and setup NDK.

First download, extract and place Android NDK.

http://developer.android.com/intl/ja/ndk/downloads/index.html

And then update your PATH environment variable. For example,

export NDK_HOME="/Users/[your-username]/Development/android/android-ndk-r11b"
export PATH=$PATH:$NDK_HOME

And build .so file in jni-build dir.

$ cd jni-build
$ make

and copy .so file into app/src/main/jniLibs/armeabi-v7a/ with

$ make install

(Unlike original Android demo in Tensorflow, you don't need to install bazel to build this demo.

Tensorflow library files (.a files) and header files are extracted from original Tensorflow Android demo r0.10.

More Repositories

1

async_deep_reinforce

Asynchronous Methods for Deep Reinforcement Learning
Python
590
star
2

unreal

Reinforcement learning with unsupervised auxiliary tasks
Python
415
star
3

TensorFlowAndroidDemo

TensorFlow Android stand-alone demo
C++
275
star
4

disentangled_vae

Replicating "Understanding disentangling in ฮฒ-VAE"
Python
193
star
5

scan

SCAN: Learning Abstract Hierarchical Compositional Visual Concepts
Python
54
star
6

heartrate-monitor

Heart rate variability (HRV) analysis tool to detect autonomic nerve state
Swift
37
star
7

predictive_coding

Predictive Coding in the Visual Cortex: a Functional Interpretation of Some Extra-classical Receptive-field Effects
Jupyter Notebook
23
star
8

rat_grid

Vector-based navigation using grid-like representations in artificial agents
Jupyter Notebook
19
star
9

rodentia

3D learning environment with rigid body simulation for Linux/MacOSX
C++
15
star
10

episodic_control

Model-Free Episodic Control
Python
15
star
11

evolution_and_ai

Python
12
star
12

intro-to-dl-android

Jinnan Android Meetup Vol.1 "Androidใงๅ‹•ใ‹ใ™ใฏใ˜ใ‚ใฆใฎDeep Learning"
C++
5
star
13

narr-note

Fast math note-taking tool with Tex notation for MacOSX.
JavaScript
5
star
14

can

Continous Attractor Network Model
Jupyter Notebook
5
star
15

dendritic_bp

Dendritic error backpropagation in deep cortical microcircuits
Jupyter Notebook
4
star
16

snmf

Hebbian/Anti-Hebbian Network for Online NMF
Jupyter Notebook
3
star
17

narr-map

A minimal mind map editor
TypeScript
2
star
18

hvrnn

Hierarchical variational autoencoder
Python
2
star
19

reinforcement_learning_samples

samples of reinforcement learning
Java
2
star
20

manimalai

Easy-to-use Animal-AI clone environment
Python
1
star
21

tinymac

Tiny old mac (Macintosh 128K) like hardware
C
1
star
22

intro-to-dl2

Python
1
star