Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

MCL303-Deep Learning with Apache MXNet and Gluon

845 views

Published on

Developing deep learning applications just got even simpler and faster. In this session, you will learn how to program deep learning models using Gluon, the new intuitive, dynamic programming interface available for the Apache MXNet open-source framework. We’ll also explore neural network architectures such as multi-layer perceptrons, convolutional neural networks (CNNs) and LSTMs.

  • Be the first to comment

MCL303-Deep Learning with Apache MXNet and Gluon

  1. 1. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS re:INVENT Sunil Mallya Miro Enev S r . A I S o l u t i o n s A r c h i t e c t , A W S D e e p L e a r n i n g M C L 3 0 3 - D e e p L e a r n i n g w i t h A p a c h e M X N e t a n d G l u o n S r . S o l u t i o n A r c h i t e c t , N V I D I A D e e p L e a r n i n g M C L 3 0 3 N o v e m b e r 2 7 , 2 0 1 7
  2. 2. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Agenda • Introduction to AI at Amazon • AI at scale: challenges and solutions • Model deployment • Visualizing deep learning • Apache MXNet overview • What is Gluon? • Live coding a neural network with Gluon • Customer stories with Apache MXNet • Getting started and Apache MXNet resources
  3. 3. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
  4. 4. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
  5. 5. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon ML Stack
  6. 6. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. One-click deep learning Up to~40k CUDA cores Apache MXNet TensorFlow Keras 1.2, 2.0 Caffe, Caffe2 Torch, Pytorch CNTK Pre-configured CUDA drivers Anaconda, Python2.7, Python3 + AWS CloudFormation template + Container image Deep Learning AMI https://bit.ly/deepami
  7. 7. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. The “Learning” in Deep Learning 0.4 0.3 0.2 0.9 ... backpropagation (gradient descent) Y1 != Y 0.4 ± 𝛿 0.3 ± 𝛿 new weights new weights 0 1 0 1 1 . . -- Y input label ... Y1
  8. 8. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Deep Learning in Computer Vision .02 .85 p(cat) p(dog) Convolutional neural network Layer 1 Layer 2 Output Explore spatial information with convolution layers Img src: https://leonardoaraujosantos.gitbooks.io/artificial-inteligence
  9. 9. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Deep Learning in Natural Language Processing Recurrent neural networks input output state Variable length input and output sequences
  10. 10. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AI and Deep Learning Story
  11. 11. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. DL IN CONTEXT AI ML DL AI
  12. 12. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. ML TRIBES
  13. 13. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. EVOLUTIONIS T CONNECTIONI ST BAYESIAN ANALOGISTSYMBOLIST BOOSTER Generalization Performance
  14. 14. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Learning at Scale
  15. 15. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Native distributed training supported Supports distributed training on multiple CPU/GPU machines to take advantage of cloud scal Flexible programming model Supports both imperative and symbolic programming maximizing efficiency and productivity Portable from the cloud to the client Runs on CPUs or GPUs, on clusters, servers, desktops, or mobile phones Multi-lingual | No need to learn a new language Python, R, Scala, Julia, C++, Matlab, or Javascript Performance 0ptimized Optimized C++ backend engine parallelizes both I/O regardless of source language
  16. 16. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. TESLA V100 THE MOST ADVANCED DATA CENTER GPU EVER BUILT 5,120 CUDA cores [ 640 Tensor cores ] 7.5 FP64 TFLOPS | 15 FP32 TFLOPS 120 Tensor TFLOPS 16GB HBM2 @ 900 GB/s 300 GB/s NVLink
  17. 17. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Distributed Training
  18. 18. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
  19. 19. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
  20. 20. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Ingest Next Batch, with Updated Model
  21. 21. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Demo
  22. 22. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Apache MXNet Single implementation of backend system and common operators Performance guarantee regardless of which front-end language is used Front end Backend
  23. 23. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Deep Learning Framework Comparison Apache MXNet TensorFlow Cognitive Toolkit Industry Owner N/A – Apache Community Google Microsoft Programmability Imperative and Declarative Declarative only Declarative only Language Support R, Python, Scala, Julia, Cpp. Javascript, Go, Matlab and more.. Python, Cpp. Experimental Go and Java Python, Cpp, Brainscript. Code Length | AlexNet (Python) 44 sloc 107 sloc using TF.Slim 214 sloc Memory Footprint (LSTM) 2.6GB 7.2GB N/A *sloc – source lines of code
  24. 24. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Introducing Gluon Simple, easy-to- understand code Flexible, imperative structure Dynamic graphs High performance  Neural networks can be defined using simple, clear, concise code  Plug-and-play neural network building blocks—including predefined layers, optimizers, and initializers  Eliminates rigidity of neural network model definition and brings together the model with the training algorithm  Intuitive, easy-to-debug, familiar code  Neural networks can change in shape or size during the training process to address advanced use cases where the size of data feed is variable  Important area of innovation in natural language processing (NLP)  There is no sacrifice with respect to training speed  When it is time to move from prototyping to production, easily cache neural networks for high performance and a reduced memory footprint
  25. 25. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Let’s Build Our First Gluon Application
  26. 26. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. # code from https://github.com/zackchase/mxnet-the-straight-dope num_fc = 512 net = gluon.nn.Sequential() with net.name_scope(): net.add(gluon.nn.Conv2D(channels=20, kernel_size=5, activation='relu')) net.add(gluon.nn.MaxPool2D(pool_size=2, strides=2)) net.add(gluon.nn.Conv2D(channels=50, kernel_size=5, activation='relu')) net.add(gluon.nn.MaxPool2D(pool_size=2, strides=2)) # The Flatten layer collapses all axis, except the first one, into one axis. net.add(gluon.nn.Flatten()) net.add(gluon.nn.Dense(num_fc, activation="relu")) net.add(gluon.nn.Dense(num_outputs)) # Handy class available here https://github.com/sunilmallya/dl-twitch-series/blob/master/cnn_mnist_gluon_simplified.ipynb CNN in Gluon
  27. 27. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. data = mx.symbol.Variable('data') # first conv layer conv1 = mx.sym.Convolution(data=data, kernel=(5,5), num_filter=20) tanh1 = mx.sym.Activation(data=conv1, act_type=”relu") pool1 = mx.sym.Pooling(data=tanh1, pool_type="max", kernel=(2,2), stride=(2,2)) # second conv layer conv2 = mx.sym.Convolution(data=pool1, kernel=(5,5), num_filter=50) tanh2 = mx.sym.Activation(data=conv2, act_type=”relu") pool2 = mx.sym.Pooling(data=tanh2, pool_type="max", kernel=(2,2), stride=(2,2)) # first full connected layer flatten = mx.sym.Flatten(data=pool2) fc1 = mx.symbol.FullyConnected(data=flatten, num_hidden=500) tanh3 = mx.sym.Activation(data=fc1, act_type=”relu") # second full connected layer fc2 = mx.sym.FullyConnected(data=tanh3, num_hidden=10) # softmax loss lenet = mx.sym.SoftmaxOutput(data=fc2, name='softmax') Convolutional Neural Net i n Symbolic MXNet
  28. 28. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Object Detection Using SSD https://github.com/zhreshold/mxnet-ssd https://github.com/zackchase/mxnet-the-straight-dope/ S Y M B O L I C G L U O N
  29. 29. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Train with default settings: python -m sockeye.train --source train-corpus.de --target train-corpus.en --validation-source dev-corpus.de --validation-target dev-corpus.en --output model-dir Decode with default settings: python -m sockeye.translate --models model-dir # Sockeye Framework Code https://github.com/awslabs/sockeye Sequence to Sequence <BOS> la casa blanca the white house <EOS>
  30. 30. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. https://github.com/apache/incubator-mxnet/tree/master/example/recommenders Recommender Systems source: Jacob Schreiber
  31. 31. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Generative Adversarial Networks (GAN) [ .76 .14 .83 -.06 ] Z “Fake” image “Real” image “Fake” image https://github.com/apache/incubator-mxnet/tree/master/example/
  32. 32. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Customer Stories with Apache MXNet
  33. 33. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. SigOpt uses deep learning in its optimization platform to configure and improve machine learning and AI models for its clients • Improves accuracy and lowers training costs using Apache MXNet and other frameworks running on Amazon EC2 P2 and SigOpt HPO • Dramatically reduces computation costs by eight times or more compared to traditional optimization methods Optimizing AI Models for Better, Faster Results
  34. 34. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Autonomous Driving
  35. 35. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Using Deep Learning to Drive Targeted Advertising GumGum uses deep learning to provide actionable insights to help advertisers create highly visible and targeted campaigns • Mantii, GumGum’s real-time social media listening tool built on deep learning, can analyze the more than 1.8 billion social images posted daily, where 80% of them lack text to help marketers find them • With deep learning on AWS using Apache MXNet and Amazon EC2 P2 instances, the company reduced model training time from 21 hours to 6 hours
  36. 36. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Apache MXNet Cheat Sheet Cheat sheet: bit.ly/2xTIwuj
  37. 37. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Thank you! s m a l l y a @ a m a z o n . c o m m e n e v @ a m a z o n . c o m

×