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

Tensorflow Hub - DevFest Nairobi 2018

Barsolai
September 22, 2018

Tensorflow Hub - DevFest Nairobi 2018

Tensorflow Hub is being introduced by Google with a focus on discovery, and consumption of reusable parts of ML models. This presentation will give a subtle introduction to the library, and the reusable modules one can leverage presently

Barsolai

September 22, 2018
Tweet

Other Decks in Technology

Transcript

  1. Tensorflow Hub
    Frontier for Reusable ML Modules
    Chris Barsolai
    Organizer, Nairobi AI
    @chrisbarso
    GDG DevFest
    Nairobi 2018

    View full-size slide

  2. https://toolbox.google.com/datasetsearch

    View full-size slide

  3. TensorFlow Hub
    Frontier for Reusable ML Modules
    Chris Barsolai
    @chrisbarso

    View full-size slide

  4. Make machines intelligent. Improve people’s lives.

    View full-size slide


  5. Make solar energy affordable

    Provide energy from fusion

    Develop carbon sequestration
    methods

    Manage the nitrogen cycle

    Provide access to clean water

    Restore & improve urban
    infrastructure

    Advance health informatics

    Engineer better medicines

    Reverse-engineer the brain

    Prevent nuclear terror

    Secure cyberspace

    Enhance virtual reality

    Advance personalized learning

    Engineer the tools for scientific
    discovery
    www.engineeringchallenges.org/challenges.aspx
    U.S. NAE Grand Engineering Challenges for 21st Century

    View full-size slide

  6. Deep Learning for
    Image-Based Cassava
    Disease Detection

    View full-size slide

  7. Half screen photo slide if
    text is necessary
    Using Tensorflow to keep
    farmers happy and cows
    healthy
    Source: https://www.blog.google/technology/ai/using-tensorflow-keep-farmers-happy-and-cows-healthy/

    View full-size slide

  8. AutoML: Automated machine learning
    (“learning to learn”)

    View full-size slide

  9. Current:
    Solution = ML expertise + data + computation

    View full-size slide

  10. Current:
    Solution = ML expertise + data + computation
    Can we turn this into:
    Solution = data + 100X computation
    ???

    View full-size slide

  11. Neural Architecture Search to find a model
    Controller: proposes ML models Train & evaluate models
    20K
    times
    Iterate to
    find the
    most
    accurate
    model

    View full-size slide

  12. Inception-ResNet-v2
    computational cost
    Accuracy (precision @1)
    accuracy
    AutoML outperforms handcrafted models
    Learning Transferable Architectures for Scalable Image Recognition, Zoph et al. 2017, https://arxiv.org/abs/1707.07012

    View full-size slide

  13. Inception-ResNet-v2
    Years of effort by top ML
    researchers in the world
    computational cost
    Accuracy (precision @1)
    accuracy
    Learning Transferable Architectures for Scalable Image Recognition, Zoph et al. 2017, https://arxiv.org/abs/1707.07012
    AutoML outperforms handcrafted models

    View full-size slide

  14. Learning Transferable Architectures for Scalable Image Recognition, Zoph et al. 2017, https://arxiv.org/abs/1707.07012
    computational cost
    Accuracy (precision @1)
    accuracy
    AutoML outperforms handcrafted models

    View full-size slide

  15. cloud.google.com/automl

    View full-size slide

  16. TensorFlow Hub
    The Next Frontier in AI Collaboration
    Chris Barsolai
    @chrisbarso

    View full-size slide

  17. “Doing ML in production is hard.”
    -Everyone who has ever tried

    View full-size slide

  18. Because, in addition to the actual ML...
    ML
    Code

    View full-size slide

  19. ...you have to worry about so much more.
    Configuration
    Data Collection
    Data
    Verification
    Feature Extraction
    Process Management
    Tools
    Analysis Tools
    Machine
    Resource
    Management
    Serving
    Infrastructure
    Monitoring
    Source: Sculley et al.: Hidden Technical Debt in Machine Learning Systems
    ML
    Code

    View full-size slide

  20. Typical ML Pipeline
    batch processing
    During training
    “online” processing
    During serving
    data request

    View full-size slide

  21. 2005, no source control
    2010, source control & C.I.
    … but not for ML
    2018, great tools and practices
    … some still to be defined
    Story time
    ML
    Software

    View full-size slide

  22. Repositories: Shared Code
    Repositories

    View full-size slide

  23. TensorFlow
    Hub
    Tensorflow Hub: Shared ML

    View full-size slide

  24. Data
    Algorithm Expertise
    Compute
    Ingredients of ML

    View full-size slide

  25. Tensorflow Hub: Shared ML
    Module
    TensorFlow
    Hub
    Model

    View full-size slide

  26. A repository of pre-trained
    model components, packaged
    for one-line reuse
    Easiest way to share and use
    best approaches for your task
    tensorflow.org/hub
    Module

    View full-size slide

  27. Modules contain pretrained weights and graphs

    View full-size slide

  28. Modules are composable, reusable, retrainable

    View full-size slide

  29. Image Retraining

    View full-size slide

  30. Model structure

    View full-size slide

  31. # Download and use NASNet feature vector module.
    module = hub.Module(
    "https://tfhub.dev/google/imagenet/nasnet_large/feature_vector/1")
    features = module(my_images)
    logits = tf.layers.dense(features, NUM_CLASSES)
    probabilities = tf.nn.softmax(logits)
    62,000+ GPU hours!

    View full-size slide

  32. # Download and use NASNet feature vector module.
    module = hub.Module(
    "https://tfhub.dev/google/imagenet/nasnet_large/feature_vector/1",
    trainable=True, tags={“train”})
    features = module(my_images)
    logits = tf.layers.dense(features, NUM_CLASSES)
    probabilities = tf.nn.softmax(logits)

    View full-size slide

  33. ● NASNet-A mobile, large
    ● PNASNet-5 large
    ● MobileNet V2 (all sizes)
    ● Inception V1, V2, V3
    ● Inception-ResNet V2
    ● ResNet V1 & V2 50/101/152
    ● MobileNet V1 (all sizes)
    Available image modules

    View full-size slide

  34. Text Classification

    View full-size slide

  35. Sentence embeddings
    “The quick brown fox”

    View full-size slide

  36. Sentence embeddings
    “DevFest Nairobi is super awesome so far”

    View full-size slide

  37. Available text modules
    ● Neural network language model (en, jp, de, es)
    ● Word2vec trained on Wikipedia
    ● ELMo (Embeddings from Language Models)

    View full-size slide

  38. From researchers to you

    View full-size slide

  39. Universal Sentence Encoder
    embed = hub.Module(
    "https://tfhub.dev/google/universal-sentence-encoder/1")
    messages = [
    “The food was great, and USIU rocks”,
    “I didn’t understand a thing today”
    …..
    “Where is jollof rice?”
    ]
    print session.run(embeddings)
    Check out the semantic similarity colab at
    https://alpha.tfhub.dev/google/universal-sentence-encoder/2

    View full-size slide

  40. # Use pre-trained universal sentence encoder to build text vector column.
    review = hub.text_embedding_column(
    "review", "https://tfhub.dev/google/universal-sentence-encoder/1")
    features = {
    "review": np.array(["an arugula masterpiece", "inedible shoe leather", ...])
    }
    labels = np.array([[1], [0], ...])
    input_fn = tf.estimator.input.numpy_input_fn(features, labels, shuffle=True)
    estimator = tf.estimator.DNNClassifier(hidden_units, [review])
    estimator.train(input_fn, max_steps=100)

    View full-size slide

  41. # Use pre-trained universal sentence encoder to build text vector column.
    review = hub.text_embedding_column(
    "review", "https://tfhub.dev/google/universal-sentence-encoder/1",
    trainable=True)
    features = {
    "review": np.array(["an arugula masterpiece", "inedible shoe leather", ...])
    }
    labels = np.array([[1], [0], ...])
    input_fn = tf.estimator.input.numpy_input_fn(features, labels, shuffle=True)
    estimator = tf.estimator.DNNClassifier(hidden_units, [review])
    estimator.train(input_fn, max_steps=100)

    View full-size slide

  42. # Use pre-trained universal sentence encoder to build text vector column.
    review = hub.text_embedding_column(
    "review", "https://tfhub.dev/google/universal-sentence-encoder/1")
    features = {
    "review": np.array(["an arugula masterpiece", "inedible shoe leather", ...])
    }
    labels = np.array([[1], [0], ...])
    input_fn = tf.estimator.input.numpy_input_fn(features, labels, shuffle=True)
    estimator = tf.estimator.DNNClassifier(hidden_units, [review])
    estimator.train(input_fn, max_steps=100)

    View full-size slide

  43. More modules
    ● Progressive GAN
    ● Google Landmarks Deep Local Features (DELF)
    ● Audio, video, and more coming...

    View full-size slide

  44. New Web Experience

    View full-size slide

  45. Try it!
    tensorflow.org/hub
    Build notebooks
    Share modules
    #tfhub

    View full-size slide

  46. Blog
    blog.tensorflow.org

    View full-size slide

  47. One URL to get involved
    tensorflow.org/community

    View full-size slide

  48. https://meetup.com/NairobiAI
    To Join:

    View full-size slide