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

Machine Learning for Developers

Machine Learning for Developers

Voxxed Days Zurich, February 23rd, 2017

Have you always wanted to add predictive capabilities or voice recognition to your application, but haven’t been able to find the time or the right technology to get started? Everybody wants to build smart apps, but only a few are Data Scientists. This session will help you understand machine learning terminology & challenges, implement a machine learning model, add predictive capabilities to your app, and provide your customer with voice UX.

Danilo Poccia

February 23, 2017
Tweet

More Decks by Danilo Poccia

Other Decks in Programming

Transcript

  1. Machine Learning
    for Developers
    Danilo Poccia
    @danilop danilop
    AWS Technical Evangelist

    View full-size slide

  2. Credit: Gerry Cranham/Fox Photos/Getty Images
    http://www.telegraph.co.uk/travel/destinations/europe/united-kingdom/england/london/galleries/The-history-of-the-Tube-in-pictures-150-years-of-London-Underground/1939-ticket-examin/

    View full-size slide

  3. 1939 London Underground
    Credit: Gerry Cranham/Fox Photos/Getty Images
    http://www.telegraph.co.uk/travel/destinations/europe/united-kingdom/england/london/galleries/The-history-of-the-Tube-in-pictures-150-years-of-London-Underground/1939-ticket-examin/

    View full-size slide

  4. Batch
    Reports
    Real-Time
    Alerts
    Prediction
    Forecasts

    View full-size slide

  5. Data Predictions

    View full-size slide

  6. Data Model Predictions

    View full-size slide

  7. http://www.thehudsonvalley.com/articles/60-years-ago-today-local-technology-demonstrated-artificial-intelligence-for-the-first-time
    1959 Arthur Samuel

    View full-size slide

  8. Machine Learning

    View full-size slide

  9. Machine Learning
    Supervised
    Learning
    Inferring a model
    from labeled
    training data

    View full-size slide

  10. Machine Learning
    Supervised
    Learning
    Unsupervised
    Learning
    Inferring a model
    from labeled
    training data
    Inferring a model
    to describe hidden
    structure from
    unlabeled data

    View full-size slide

  11. Reinforcement
    Learning
    Perform a certain
    goal in a
    dynamic
    environment

    View full-size slide

  12. Driving a vehicle
    Playing a game
    against an opponent

    View full-size slide

  13. Topic Modeling
    Discovering abstract “topics”
    that occur in a collection of documents
    Try that with your own emails ;-)

    View full-size slide

  14. Regression “How many bikes will
    be rented tomorrow?”
    Happy, Sad, Angry,
    Confused, Disgusted,
    Surprised, Calm,
    Unknown
    Binary
    Classification
    Multi-Class
    Classification
    “Is this email spam?”
    “What is the
    sentiment of this
    tweet, or of this social
    media comment?”
    1, 0, 100K
    Yes, No
    True, False
    %

    View full-size slide

  15. Training the Model
    Minimizing the Error

    View full-size slide

  16. Labeled Data

    View full-size slide

  17. Labeled Data
    70%
    30%
    Training
    Validation

    View full-size slide

  18. Be Careful of Overfitting

    View full-size slide

  19. Be Careful of Overfitting

    View full-size slide

  20. Be Careful of Overfitting

    View full-size slide

  21. Better Fitting

    View full-size slide

  22. Better Fitting

    View full-size slide

  23. Different Models ⇒ Different Predictions

    View full-size slide

  24. Adding a “cost” for using
larger
    parameters in the model
    L1, L2,
    Neural Network Dropouts
    Regularization

    View full-size slide

  25. Large numbers can have a bigger impact
    in a mathematical model
    Feature Scaling
    So they are all in the same range,
    For example between 0 and 1
    Normalization

    View full-size slide

  26. Model Parameters
    “Hyperparameters”

    View full-size slide

  27. Labeled Data
    70%
    15%
    Training
    Validation
    15% Test
    Try Different
    Hyperparameters

    View full-size slide

  28. Labeled Data
    Cross Validation

    View full-size slide

  29. Neural
    Networks

    View full-size slide

  30. 1943 Warren McCulloch, Walter Pitts
    Threshold
    Logic
    Units

    View full-size slide

  31. 1962 Frank Rosenblatt
    Perceptron

    View full-size slide

  32. https://github.com/cdipaolo/goml/tree/master/perceptron
    weights activation function
    input output

    View full-size slide

  33. https://en.wikipedia.org/wiki/Artificial_neural_network
    Multiple Layers
    Backpropagation

    View full-size slide

  34. Microprocessor Transistor Counts 1971-2011
    Intel E7 CPU
    4-24 cores
    NVIDIA K80 GPU
    2,496 cores
    https://en.wikipedia.org/wiki/Moore's_law

    View full-size slide

  35. LeCun, Gradient-Based
    Learning Applied to Document
    Recognition,1998
    Hinton, A Fast Learning
    Algorithm for Deep Belief
    Nets, 2006
    Bengio, Learning Deep
    Architectures for AI, 2009
    Advances in Research 1998-2009

    View full-size slide

  36. Image
    Processing

    View full-size slide

  37. Photo by David Iliff. License: CC-BY-SA 3.0
    https://commons.wikimedia.org/wiki/File:Colosseum_in_Rome,_Italy_-_April_2007.jpg
    Convolution Matrix

    View full-size slide

  38. Convolution Matrix
    Photo by David Iliff. License: CC-BY-SA 3.0
    https://commons.wikimedia.org/wiki/File:Colosseum_in_Rome,_Italy_-_April_2007.jpg

    View full-size slide

  39. Convolution Matrix
    0 0 0
    0 1 0
    0 0 0
    Identity
    Photo by David Iliff. License: CC-BY-SA 3.0
    https://commons.wikimedia.org/wiki/File:Colosseum_in_Rome,_Italy_-_April_2007.jpg

    View full-size slide

  40. Convolution Matrix
    1 0 -1
    2 0 -2
    1 0 -1
    Left Edges
    Photo by David Iliff. License: CC-BY-SA 3.0
    https://commons.wikimedia.org/wiki/File:Colosseum_in_Rome,_Italy_-_April_2007.jpg

    View full-size slide

  41. Convolution Matrix
    -1 0 1
    -2 0 2
    -1 0 1
    Right Edges
    Photo by David Iliff. License: CC-BY-SA 3.0
    https://commons.wikimedia.org/wiki/File:Colosseum_in_Rome,_Italy_-_April_2007.jpg

    View full-size slide

  42. Convolution Matrix
    1 2 1
    0 0 0
    -1 -2 -1
    Top Edges
    Photo by David Iliff. License: CC-BY-SA 3.0
    https://commons.wikimedia.org/wiki/File:Colosseum_in_Rome,_Italy_-_April_2007.jpg

    View full-size slide

  43. Convolution Matrix
    -1 -2 -1
    0 0 0
    1 2 1
    Bottom Edges
    Photo by David Iliff. License: CC-BY-SA 3.0
    https://commons.wikimedia.org/wiki/File:Colosseum_in_Rome,_Italy_-_April_2007.jpg

    View full-size slide

  44. Convolution Matrix
    0.6 -0.6 1.2
    -1.4 1.2 -1.6
    0.8 -1.4 1.6
    Random Values
    Photo by David Iliff. License: CC-BY-SA 3.0
    https://commons.wikimedia.org/wiki/File:Colosseum_in_Rome,_Italy_-_April_2007.jpg

    View full-size slide

  45. Convolutional Neural Networks (CNNs)
    https://en.wikipedia.org/wiki/Convolutional_neural_network

    View full-size slide

  46. ImageNet Classification Error Over Time
    0
    5
    10
    15
    20
    25
    30
    2010 2011 2012 2013 2014 2015 2016
    Classification Error
    CNNs

    View full-size slide

  47. 2012 ImageNet Classification with Deep Convolutional Neural Networks

    View full-size slide

  48. SuperVision: 8 layers, 60M parameters
    0

    View full-size slide

  49. 2013 Visualizing and Understanding Convolutional Networks

    View full-size slide

  50. How Do Neural Networks Learn?
    ?
    More generic and can be reused
    as feature extractor for other visual tasks
    Specific
    to task
    Cat
    Dog
    0

    View full-size slide

  51. output
    input
    state
    output
    input
    state(t)
    memory
    Feedforward
    Neural Networks
    (no cycle)
    Recurrent
    Neural Networks
    (directed cycle)
    What About Memory?

    View full-size slide

  52. https://en.wikipedia.org/wiki/Long_short-term_memory
    Long Short-Term Memory (LSTM)
    How much
    goes into
    memory
    How much
    is used
    in computing
    the output
    How much
    remains in
    memory

    View full-size slide

  53. http://www.asimovinstitute.org/neural-network-zoo/
    Lots of Parameters
    Network Architectures
    defined by Hyperparameters
    Dropout Layers
    for Regularization

    View full-size slide

  54. Generative Adversarial Networks (GANs)
    Generator
    Neural
    Network
    Discriminator
    Neural
    Network
    Real or
    Generated?
    Real
    Picture
    Generated
    Picture

    View full-size slide

  55. 2014
    Generative Adversarial Networks (GANs)

    View full-size slide

  56. 2016
    Generative Adversarial Networks (GANs)

    View full-size slide

  57. How much can you improve?
    Bayes Limit Vs Human Performance
    Training better than Validation?
    Learning Bias
    Data Leakage
    Do you have all the Data?
    Building a Model

    View full-size slide

  58. Artificial Intelligence & Deep Learning At Amazon
    Thousands Of Employees Across The Company Focused on AI
    Discovery &
    Search
    Fulfilment &
    Logistics
    Add ML-powered
    features to existing products
    Echo &
    Alexa

    View full-size slide

  59. Create Great Content:
    ASK is how you connect
    to your consumer
    THE ALEXA ECOSYSTEM
    Supported by two powerful frameworks
    A L E X A
    V O I C E
    S E R V I C E
    Unparalleled Distribution:
    AVS allows your content
    to be everywhere
    Lives In The Cloud
    Automated Speech
    Recognition (ASR)
    Natural Language
    Understanding (NLU)
    Always Learning
    A L E X A
    S K I L L S
    K I T

    View full-size slide

  60. UNDER THE HOOD OF ASK
    A closer look at how the Alexa Skills Kit process a request and returns an appropriate
    response
    You Pass Back a Textual
    or Audio Response
    You Pass Back a Graphical Response
    Alexa Converts Text-to-Speech
    (TTS) & Renders Graphical
    Component
    Respond to Intent
    through Text & Visual
    Alexa sends Customer
    Intent to Your Service
    User Makes
    a Request
    Alexa Identifies Skill &
    Recognizes Intent Through
    ASR & NLU
    Your Service
    processes
    Request
    Audio Stream is
    sent up to Alexa

    View full-size slide

  61. Artificial Intelligence on AWS
    P2 Deep Learning
    AMI and template
    Investment in
    Apache MXNet

    View full-size slide

  62. Elastic GPUs On EC2
    P2
    M4 D2 X1 G2
    T2 R4 I3 C5
    General Purpose
    GPU
    General Purpose
    Dense storage Large memory
    Graphics
    intensive
    Memory intensive High I/O
    Compute intensive
    Burstable
    Lightsail
    Simple VPS
    F1
    FPGAs
    Instance Families

    View full-size slide

  63. Up to
    40 thousand parallel processing cores
    70 teraflops (single precision)
    over 23 teraflops (double precision)
    Instance Size GPUs GPU Peer
    to Peer
    vCPUs Memory
    (GiB)
    Network
    Bandwidth*
    p2.xlarge 1 - 4 61 1.25Gbps
    p2.8xlarge 8 Y 32 488 10Gbps
    p2.16xlarge 16 Y 64 732 20Gbps
    *In a placement group
    Amazon EC2 P2 Instances

    View full-size slide

  64. Elastic GPUs For EC2: GPU Acceleration For Graphics Workloads
    1GiB
    GPU Memory
    2 GiB
    4 GiB
    8 GiB
    Current
    Generation
    EC2
    Instance

    View full-size slide

  65. F1 Instances: Bringing Hardware Acceleration To All
    FPGA Images Available In AWS Marketplace
    F1 Instance
    With your custom logic
    running on an FPGA
    Develop, simulate, debug
    & compile your code
    Package as
    FPGA Images

    View full-size slide

  66. Apache MXNet

    View full-size slide

  67. Deep Learning Frameworks
    MXNet, Caffe, Tensorflow,
    Theano, Torch, CNTK and Keras
    Pre-installed components to
    speed productivity, such as
    Nvidia drivers, CUDA, cuDNN,
    Intel MKL-DNN with MXNet,
    Anaconda, Python 2 and 3
    AWS Integration
    Deep Learning AMI

    View full-size slide

  68. Apache Spark MLlib

    View full-size slide

  69. Amazon AI
    Bringing Powerful Artificial Intelligence To All Developers

    View full-size slide

  70. Amazon Rekognition
    Image Recognition And Analysis
    Powered By Deep Learning
    1

    View full-size slide

  71. Amazon Rekognition: Images In,
    Categories and Facial Analysis Out
    Amazon
    Rekognition
    Car
    Outside
    Daytime
    Driving
    Objects
    & Scenes
    Female
    Smiling
    Sunglasses
    Faces

    View full-size slide

  72. Ground Truth Generation
    Training

    View full-size slide

  73. Deep Learning Process
    Conv 1 Conv 2 Conv n


    Feature Maps
    Labrador
    Dog
    Beach
    Outdoors
    Softmax
    Probability
    Fully
    Connected
    Layer

    View full-size slide


  74. Amazon Rekognition

    View full-size slide

  75. Amazon Polly
    Text To Speech Powered By Deep Learning
    2

    View full-size slide

  76. Amazon Polly: Text In, Life-like Speech Out
    Amazon Polly
    “The temperature
    in WA is 75°F”
    “The temperature
    in Washington is 75 degrees
    Fahrenheit”

    View full-size slide

  77. TEXT
    Market grew by > 20%.
    WORDS
    PHONEMES
    {
    {
    {
    {
    {
    ˈtwɛn.ti
    pɚ.ˈsɛnt
    ˈmɑɹ.kət ˈgɹu baɪ ˈmoʊɹ
    ˈðæn
    PROSODY CONTOUR
    UNIT SELECTION AND ADAPTATION
    TEXT PROCESSING
    PROSODY MODIFICATION
    STREAMING
    Market grew by more
    than
    twenty
    percent
    Speech units
    inventory

    View full-size slide


  78. Amazon Polly

    View full-size slide

  79. Amazon ALEXA
    (It’s what’s inside Alexa)
    3
    Natural Language Understanding (NLU) &
    Automatic Speech Recognition (ASR) Powered By Deep Learning

    View full-size slide

  80. Amazon Lex: Speech Recognition
    & Natural Language Understanding
    Amazon Lex
    Automatic Speech Recognition
    Natural Language Understanding
    “What’s the weather
    forecast?”
    Weather
    Forecast

    View full-size slide

  81. Amazon Lex: Speech Recognition
    & Natural Language Understanding
    Amazon Lex
    Automatic Speech Recognition
    Natural Language Understanding
    “What’s the weather
    forecast?”
    “It will be sunny
    and 25°C”
    Weather
    Forecast

    View full-size slide

  82. Lex Bot Structure
    Utterances
    Spoken or typed phrases that invoke your
    intent
    BookHotel
    Intents
    An Intent performs an action in response
    to natural language user input
    Slots
    Slots are input data required to fulfill the
    intent
    Fulfillment
    Fulfillment mechanism for your intent

    View full-size slide

  83. Hotel Booking
    City New York City
    Check In Nov 30th
    Check Out Dec 2nd
    Hotel Booking
    City New York City
    Check In
    Check Out
    “Book a Hotel”
    Book Hotel
    NYC
    “Book a Hotel in
    NYC”
    Automatic Speech
    Recognition
    Hotel Booking
    New York City
    Natural Language
    Understanding
    Intent/Slot
    Model
    Utterances
    “Your hotel is booked
    for Nov 30th”
    Polly
    Confirmation: “Your hotel is
    booked for Nov 30th”
    a
    in
    “Can I go ahead with
    the booking?”

    View full-size slide

  84. Amazon Machine Learning
    Create ML models without having to learn
    complex algorithms and technology
    4

    View full-size slide

  85. Train
    model
    Evaluate and
    optimize
    Retrieve
    predictions
    Building smart applications with Amazon ML
    1 2 3

    View full-size slide

  86. Train
    model
    Evaluate and
    optimize
    Retrieve
    predictions
    Building smart applications with Amazon ML
    Create a datasource object pointing to your data
    Explore and understand your data
    Transform data and train your model
    1 2 3

    View full-size slide

  87. Create a datasource object
    >>> import boto
    >>> ml = boto.connect_machinelearning()
    >>> ds = ml.create_data_source_from_s3(
    data_source_id = ’my_datasource',
    data_spec= {
    'DataLocationS3':'s3://bucket/input/',
    'DataSchemaLocationS3':'s3://bucket/input/.schema'},
    compute_statistics = True)

    View full-size slide

  88. Explore and understand your data

    View full-size slide

  89. Train your model
    >>> import boto
    >>> ml = boto.connect_machinelearning()
    >>> model = ml.create_ml_model(
    ml_model_id=’my_model',
    ml_model_type='REGRESSION',
    training_data_source_id='my_datasource')

    View full-size slide

  90. Train
    model
    Evaluate and
    optimize
    Retrieve
    predictions
    Building smart applications with Amazon ML
    Understand model quality
    Adjust model interpretation
    1 2 3

    View full-size slide

  91. Explore model quality

    View full-size slide

  92. Fine-tune model interpretation

    View full-size slide

  93. Fine-tune model interpretation

    View full-size slide

  94. Train
    model
    Evaluate and
    optimize
    Retrieve
    predictions
    Building smart applications with Amazon ML
    Batch predictions
    Real-time predictions
    1 2 3

    View full-size slide

  95. Batch predictions
    Asynchronous, large-volume prediction generation
    Request through service console or API
    Best for applications that deal with batches of data records
    >>> import boto
    >>> ml = boto.connect_machinelearning()
    >>> model = ml.create_batch_prediction(
    batch_prediction_id = 'my_batch_prediction’
    batch_prediction_data_source_id = ’my_datasource’
    ml_model_id = ’my_model',
    output_uri = 's3://examplebucket/output/’)

    View full-size slide

  96. Real-time predictions
    Synchronous, low-latency, high-throughput prediction generation
    Request through service API or server or mobile SDKs
    Best for interaction applications that deal with individual data
    records
    >>> import boto
    >>> ml = boto.connect_machinelearning()
    >>> ml.predict(
    ml_model_id=’my_model',
    predict_endpoint=’example_endpoint’,
    record={’key1':’value1’, ’key2':’value2’})
    {
    'Prediction': {
    'predictedValue': 13.284348,
    'details': {
    'Algorithm': 'SGD',
    'PredictiveModelType': 'REGRESSION’
    }
    }
    }

    View full-size slide


  97. Bike Sharing

    View full-size slide

  98. All Users
    Casual Users
    Registered Users

    View full-size slide

  99. Your Skill
    (Lambda function)
    Amazon
    Machine Learning
    get real-time predictions
    invoke
    Weather
    Forecast
    Historical Data
    get forecast
    build & train model

    View full-size slide

  100. Nikola Tesla, 1926
    “When wireless is perfectly
    applied, the whole earth will be
    converted into a huge brain…”

    View full-size slide

  101. Let’s Build Smarter Apps
    Using
    Services
    Platforms
    Engines

    View full-size slide

  102. Machine Learning
    for Developers
    Danilo Poccia
    @danilop danilop
    AWS Technical Evangelist

    View full-size slide