Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Mobile, AI and TensorFlow

Mobile, AI and TensorFlow

Supriya Srivatsa

October 05, 2017
Tweet

More Decks by Supriya Srivatsa

Other Decks in Technology

Transcript

  1. Mobile, AI and Tensorflow
    Supriya Srivatsa

    View Slide

  2. View Slide

  3. View Slide

  4. NEURAL NETWORKS
    Human anatomy inspired learning network.

    View Slide

  5. Neural Networks

    View Slide

  6. Neural Networks

    View Slide

  7. Neural Network – A Peek Inside

    View Slide

  8. Deep Neural Network

    View Slide

  9. PREDICTION AND INFERENCE
    How it works today. How it shall work tomorrow.

    View Slide

  10. “Transfer to Infer” Approach

    View Slide

  11. Why On-Device Prediction
    • Data Privacy
    • Poor internet connections
    • Questionable user experience

    View Slide

  12. To The Rescue…

    View Slide

  13. TensorFlow
    • Tensor: N Dimensional Arrays
    • Open source software library for numerical
    computation using data flow graphs.

    View Slide

  14. TensorFlow – Data Flow Graphs
    • Nodes represent mathematical functions
    • Edges represent tensors.

    View Slide

  15. Tensorflow – “Deferred Execution” Model
    • Graph first. Computation Afterward.
    import tensorflow as tf
    x = tf.constant(10)
    y = tf.Variable(x + 5)
    print(y)

    View Slide

  16. Tensorflow – “Deferred Execution” Model
    • Graph first. Computation Afterward.
    import tensorflow as tf
    x = tf.constant(10)
    y = tf.Variable(x + 5)
    model = tf.global_variables_initializer()
    with tf.Session() as session:
    session.run(model)
    print(session.run(y))

    View Slide

  17. View Slide

  18. View Slide

  19. Packaging the App and the Model

    View Slide

  20. QUANTIZATION
    Compress. And Compress More.

    View Slide

  21. Quantization
    • Round it up
    • Transform: round_weights
    • Compression rates: ~8% => ~70%
    • Shrink down node names
    • Transform: obfuscate_names
    • Eight bit calculations

    View Slide

  22. Quantization - Eight Bit Calculations

    View Slide

  23. Quantization - Eight Bit Calculations

    View Slide

  24. View Slide

  25. IMPLEMENTATION
    Code Away! ☺

    View Slide

  26. Implementation
    build.gradle
    buildscript {
    repositories {
    jcenter()
    }
    dependencies {
    classpath 'com.android.tools.build:gradle:2.3.0'
    }
    }

    View Slide

  27. Implementation
    1. Load
    2. Feed
    3. Run
    4. Fetch

    View Slide

  28. Implementation
    1. Load the model
    2. Feed in the input
    3. Run the model
    4. Fetch the output
    TensorFlowInferenceInterface inferenceInterface =
    new TensorFlowInferenceInterface(assetManager, modelFile);

    View Slide

  29. Implementation
    1. Load the model
    2. Feed in the input
    3. Run the model
    4. Fetch the output
    // feed(String s, float[] floats, long… longs)
    inferenceInterface.feed(inputName, floatValues, 1, inputSize, inputSize, 3);

    View Slide

  30. Implementation
    1. Load the model
    2. Feed in the input
    3. Run the model
    4. Fetch the output
    inferenceInterface.run(outputNames);

    View Slide

  31. Implementation
    1. Load the model
    2. Feed in the input
    3. Run the model
    4. Fetch the output
    // fetch(String s, float[] floats)
    inferenceInterface.fetch(outputName, outputs);

    View Slide

  32. APPLICATIONS
    Awesomeness.

    View Slide

  33. Google Translate

    View Slide

  34. View Slide

  35. View Slide