SlideShare uma empresa Scribd logo
1 de 34
Baixar para ler offline
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS re:INVENT
MCL309
Deep Learning on a Raspberry Pi
J u l i e n S i m o n , P r i n c i p a l A I / M L E v a n g e l i s t , E M E A
@ j u l s i m o n
M C L 3 0 9
N o v e m b e r 2 7 , 2 0 1 7
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
What to expect from this workshop
• Welcome and housekeeping—5 minutes
• An introduction to the Apache MXNet API—20 minutes (slides)
• Training an MXNet model—10 minutes
• Setting up your Raspberry Pi—20 minutes
• Using pre-trained models—30 minutes
• Building an app with MXNet, Amazon Rekognition, and Amazon Polly—60 minutes
• Wrap-up—5 minutes
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Welcome!
Matthieu Fuzellier, Sr. Consultant IoT, Professional Services (US)
Stephan Hadinger, Senior Manager, Solution Architecture (France)
Adrian Hornsby, Technical Evangelist (Nordics)
Rudy Krol, Solutions Architect (France)
Troy Larson, Sr. DevOps Cloud Architect, Professional Services (US)
Nicolas Malaval, Consultant, Professional Services (France)
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
An introduction to the Apache MXNet API
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Apache MXNet: Open source l i brary for d eep l earni ng
Programmable Portable High performance
Near linear scaling
across hundreds of GPUs
Highly efficient
models for mobile
and IoT
Simple syntax,
multiple languages
Most open Best On AWS
Optimized for
deep learning on AWS
Accepted into the
Apache Incubator
mxnet.incubator.apache.org
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Neural networks
x =
x11, x12, …. x1I
x21, x22, …. x2I
x…, x.., …. x.I
xm1, xm2, …. xmI
I features
m samples
y =
y1
y2
y…
ym
m labels
Total number of predictions
Accuracy =
Number of correct predictions
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Training
Training data set Training
Trained
neural network
Number of epochs
Batch size
Learning rate
Hyper parameters
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Validation
Validation data set Trained
neural network
Validation
accuracy
Prediction at
the end of
each epoch
Stop training when validation accuracy stops increasing
Saving parameters at the end of each epoch is a good idea ;)
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
The Apache MXNet API
• Storing and accessing data  multi-dimensional arrays: NDArray API
• Neural network (layers, weights, activation functions)  Symbol API
• Serving data during training and validation  Iterators
• Data + neural network = model  Module API
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Let’s build a data set of 1000 samples with 100 features each and belonging to one of 10 categories.
We split it 80/20 for training and validation.
sample_count = 1000
train_count = 800
valid_count = sample_count - train_count
feature_count = 100
category_count = 10
X = mx.nd.uniform(low=0, high=1, shape=(sample_count,feature_count))
Y = mx.nd.empty((sample_count,))
for i in range(0,sample_count-1):
Y[i] = np.random.randint(0,category_count)
X_train = mx.nd.crop(X, begin=(0,0), end=(train_count,feature_count))
Y_train = Y[0:train_count]
X_valid = mx.nd.crop(X, begin=(train_count,0), end=(sample_count,feature_count))
Y_valid = Y[train_count:sample_count]
print(X.shape, Y.shape, X_train.shape, Y_train.shape, X_valid.shape, Y_valid.shape)
NDArray API example
h t t p s : / / m x n e t . i n c u b a t o r . a p a c h e . o r g / a p i / p y t h o n / n d a r r a y . h t m l
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Let’s build a simple Multi-Layer Perceptron
1. Input layer
2. One hidden layer with 64 neurons,
using the Rectified Linear Unit activation function
3. Output layer with 10 neurons,
using the Softmax function to output probabilities
data = mx.sym.Variable('data')
fc1 = mx.sym.FullyConnected(data, name='fc1', num_hidden=64)
relu1 = mx.sym.Activation(fc1, name='relu1', act_type="relu")
fc2 = mx.sym.FullyConnected(relu1, name='fc2', num_hidden=category_count)
out = mx.sym.SoftmaxOutput(fc2, name='softmax')
mod = mx.mod.Module(out)
Symbol API example
h t t p s : / / m x n e t . i n c u b a t o r . a p a c h e . o r g / a p i / p y t h o n / s y m b o l . h t m l
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
• Training is performed batch by batch
• Iterators take care of this automatically 
• MXNet provides iterators for NDArrays, image files, and more
• You can also write your own
batch = 10
train_iter = mx.io.NDArrayIter(data=X_train,label=Y_train,batch_size=batch)
val_iter = mx.io.NDArrayIter(data=X_valid,label=Y_valid, batch_size=batch)
Iterator API example
h t t p s : / / m x n e t . i n c u b a t o r . a p a c h e . o r g / a p i / p y t h o n / i o . h t m l
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
• This is where the rubber meets the road
• Binding the data set to the network
• Setting initialization and optimization parameters
• Training the model
• Saving the trained model
nb_epochs=50
mod = mx.mod.Module(out)
mod.bind(data_shapes=train_iter.provide_data, label_shapes=train_iter.provide_label)
mod.init_params(initializer=mx.init.Xavier(magnitude=2.))
mod.init_optimizer(optimizer='sgd', optimizer_params=(('learning_rate', 0.1), ))
mod.fit(train_iter, num_epoch=nb_epochs)
mod.save_checkpoint(”myFirstModel", nb_epochs)
Module API example
h t t p s : / / m x n e t . i n c u b a t o r . a p a c h e . o r g / a p i / p y t h o n / m o d u l e . h t m l
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
$ python introduction.py
((1000L, 100L), (1000L,), (800L, 100L), (800L,), (200L, 100L), (200L,))
INFO:root:Epoch[0] Train-accuracy=0.093750
INFO:root:Epoch[0] Time cost=0.051
. . .
INFO:root:Epoch[49] Train-accuracy=0.995000
INFO:root:Epoch[49] Time cost=0.047
Validation accuracy: 0.12
• The model is able to perfectly learn our synthetic training set
(universal approximation theorem)
• Validation accuracy is what you need to look at
Putting it all together
0 1 _ i n t r o d u c t i o n . p y
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Training an MXNet model
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
The MNIST data set
• 70,000 hand-written digits
• 28x28 grayscale images
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
You have three options
1. Install on your own machine
• Linux, MacOS, Docker—no Windows
• https://mxnet.incubator.apache.org/get_started/install.html
2. Start an Amazon EC2 instance using the Deep Learning AMI in your own account
• CPU or GPU, it’s up to you
• Scripts are provided: ec2_setup.sh and ec2_cleanup.sh
• Read them first!
3. Use the shared Amazon EC2 instance
• Instructions will be provided
• PLEASE work in your own folder: mkdir ~/firstname-lastname
Setting up your MXNet machine
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Training models on MNIST
0 2 _ m n i s t /
• Download the data set
• Either from the web: get_mnist_from_web.sh
• Or from S3: get_mnist_from_s3.sh
• Train two models
• A Multi-Layer Perceptron: trainMlp.py
• The LeNet Convolutional Neural Network: trainLeNet.py
• How does training differ?
• Use each model to predict new digits: predict.py
• How does prediction differ?
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Setting up your Raspberry Pi
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Setting up the hardware & network
• Instructions will be provided
• Ask us for help if you’re blocked
• Please be a good neighbor: help out other participants if you can 
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Installing MXNet
0 3 _ p i S e t u p /
• Install a pre-built version of MXNet: setup.sh
• For reference only (>> 1 hour):
build from source: build.sh
• Detailed installation instructions:
https://mxnet.incubator.apache.org/get_started/install.html
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Using pre-trained models
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Training MNIST on the Pi
0 2 _ m n i s t /
• Download the data set
• Either from the web: get_mnist_from_web.sh
• Or from Amazon Simple Storage Service: get_mnist_from_s3.sh
• Train two models
• A Multi-Layer Perceptron: trainMlp.py
• The LeNet Convolutional Neural Network: trainLeNet.py
• What’s the problem?
• Obviously, you wouldn’t want to train CNNs on a Raspberry Pi 
• Even on a powerful system, training is not an easy task, which leads us to…
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Why pre-trained models make sense
• Training a complex model on a large data set can take days
• Finding the right settings is not easy
• A pre-trained model may be good enough to solve your problem
• You can also fine-tune it on your own data to improve accuracy
• Take a look at the MXNET model zoo
• https://mxnet.incubator.apache.org/model_zoo/
• Two files: model definition (JSON), model weights (.params)
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Using pre-trained models
0 4 _ p i M o d e l s /
• Download three pre-trained models for image classification
• Either from the web: get_models_from_web.sh
• Or from Amazon S3: get_models_from_s3.sh
• Read the code in classify.py. Make sure you understand how to:
• Load a model
• Load a single image from file and turn it into an NDArray
• Build a ”fake” iterator with namedtuple
• Collect results on the output layer and find the top classes
• Run classify.py
• What happens and why? Fix the problem
• Try your own images
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
B u i l d i n g a n a p p w i t h M X N e t , A m a z o n R e k o g n i t i o n
a n d A m a z o n P o l l y
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Connecting and testing the camera
Power down the Pi first from picamera import PiCamera
cam = PiCamera()
cam.resolution=(640,480)
cam.capture(”myimage.jpg”)
cam.close()
Copy the image on your laptop
and check that it’s correct
If not, you probably need to flip
the cable 
Your setup should look like this
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Using a pre-trained MXNet model
0 5 _ p i M x n e t /
1. Add code to classify a picture taken by the camera
2. Take pictures and classify them:
• Pictures with a single object
• Pictures with nested objects (for example, a car on a book cover)
• Pictures with multiple objects
• Pictures of people
• What works well and what doesn’t? Any idea why?
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Adding Amazon Polly
0 6 _ p i P o l l y /
• Amazon Polly is a text-to-speech service
https://aws.amazon.com/polly
• You can generate a sound file from a text string with a single API call
https://docs.aws.amazon.com/polly/latest/dg/API_SynthesizeSpeech.html
• Try the AWS Command Line Interface first: “aws polly…”
• Using information returned by the MXNet model, we build a text string
saying “I’m <score>% sure this is a <top category name>”
• Play it with Amazon Polly
• Try different voices
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Adding Amazon Rekognition
0 7 _ p i R e k o g n i t i o n /
• Amazon Rekognition is an object and face detection service
https://aws.amazon.com/rekognition
• You can detect objects or faces with a single API call
https://docs.aws.amazon.com/rekognition/latest/dg/API_DetectLabels.html
https://docs.aws.amazon.com/rekognition/latest/dg/API_DetectFaces.html
• Try the AWS CLI first: “aws rekognition …”
• Add code to run Amazon Rekognition on a picture
• Use the output to build a text message and play it with Amazon Polly
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Wrap-up
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
• If you created an instance, don’t forget to terminate it (ec2_cleanup.sh)
• You can keep the hardware  Build cool stuff with it and let us know.
We’re always happy to share and retweet.
• You also get $25 credits  Don’t forget them on your way out.
• Please check out the other deep learning sessions (MCL322 *hint* *hint*)
• Thank you very much. Have a GREAT re:Invent!
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Resources
https://aws.amazon.com/ai
https://aws.amazon.com/blogs/ai
https://mxnet.io
https://github.com/apache/incubator-mxnet
https://github.com/gluon-api
https://github.com/awslabs/sockeye
https://medium.com/@julsimon
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Thank you!
J u l i e n S i m o n , P r i n c i p a l A I / M L E v a n g e l i s t , E M E A
@ j u l s i m o n

Mais conteúdo relacionado

Mais procurados

AMF305_Autonomous Driving Algorithm Development on Amazon AI
AMF305_Autonomous Driving Algorithm Development on Amazon AIAMF305_Autonomous Driving Algorithm Development on Amazon AI
AMF305_Autonomous Driving Algorithm Development on Amazon AIAmazon Web Services
 
GPSTEC313_GPS Real-Time Data Processing with AWS Lambda Quickly, at Scale, an...
GPSTEC313_GPS Real-Time Data Processing with AWS Lambda Quickly, at Scale, an...GPSTEC313_GPS Real-Time Data Processing with AWS Lambda Quickly, at Scale, an...
GPSTEC313_GPS Real-Time Data Processing with AWS Lambda Quickly, at Scale, an...Amazon Web Services
 
GPSWKS301_Comprehensive Big Data Architecture Made Easy
GPSWKS301_Comprehensive Big Data Architecture Made EasyGPSWKS301_Comprehensive Big Data Architecture Made Easy
GPSWKS301_Comprehensive Big Data Architecture Made EasyAmazon Web Services
 
DAT316_Report from the field on Aurora PostgreSQL Performance
DAT316_Report from the field on Aurora PostgreSQL PerformanceDAT316_Report from the field on Aurora PostgreSQL Performance
DAT316_Report from the field on Aurora PostgreSQL PerformanceAmazon Web Services
 
STG206_Big Data Data Lakes and Data Oceans
STG206_Big Data Data Lakes and Data OceansSTG206_Big Data Data Lakes and Data Oceans
STG206_Big Data Data Lakes and Data OceansAmazon Web Services
 
NET309_Best Practices for Securing an Amazon Virtual Private Cloud
NET309_Best Practices for Securing an Amazon Virtual Private CloudNET309_Best Practices for Securing an Amazon Virtual Private Cloud
NET309_Best Practices for Securing an Amazon Virtual Private CloudAmazon Web Services
 
CMP216_Use Amazon EC2 Spot Instances to Deploy a Deep Learning Framework on A...
CMP216_Use Amazon EC2 Spot Instances to Deploy a Deep Learning Framework on A...CMP216_Use Amazon EC2 Spot Instances to Deploy a Deep Learning Framework on A...
CMP216_Use Amazon EC2 Spot Instances to Deploy a Deep Learning Framework on A...Amazon Web Services
 
STG305_Deep Dive on Backup to the AWS Cloud
STG305_Deep Dive on Backup to the AWS CloudSTG305_Deep Dive on Backup to the AWS Cloud
STG305_Deep Dive on Backup to the AWS CloudAmazon Web Services
 
AWS Database and Analytics State of the Union - 2017 - DAT201 - re:Invent 2017
AWS Database and Analytics State of the Union - 2017 - DAT201 - re:Invent 2017AWS Database and Analytics State of the Union - 2017 - DAT201 - re:Invent 2017
AWS Database and Analytics State of the Union - 2017 - DAT201 - re:Invent 2017Amazon Web Services
 
GPSTEC305-Machine Learning in Capital Markets
GPSTEC305-Machine Learning in Capital MarketsGPSTEC305-Machine Learning in Capital Markets
GPSTEC305-Machine Learning in Capital MarketsAmazon Web Services
 
CMP316_Hedge Your Own Funds Run Monte Carlo Simulations on EC2 Spot Fleet
CMP316_Hedge Your Own Funds Run Monte Carlo Simulations on EC2 Spot FleetCMP316_Hedge Your Own Funds Run Monte Carlo Simulations on EC2 Spot Fleet
CMP316_Hedge Your Own Funds Run Monte Carlo Simulations on EC2 Spot FleetAmazon Web Services
 
CON209_Interstella 8888 Learn How to Use Docker on AWS
CON209_Interstella 8888 Learn How to Use Docker on AWSCON209_Interstella 8888 Learn How to Use Docker on AWS
CON209_Interstella 8888 Learn How to Use Docker on AWSAmazon Web Services
 
Building Serverless Websites with Lambda@Edge - CTD309 - re:Invent 2017
Building Serverless Websites with Lambda@Edge - CTD309 - re:Invent 2017Building Serverless Websites with Lambda@Edge - CTD309 - re:Invent 2017
Building Serverless Websites with Lambda@Edge - CTD309 - re:Invent 2017Amazon Web Services
 
CON213_Hands-on Kubernetes on AWS
CON213_Hands-on Kubernetes on AWSCON213_Hands-on Kubernetes on AWS
CON213_Hands-on Kubernetes on AWSAmazon Web Services
 
Design patterns and best practices for data analytics with amazon emr (ABD305)
Design patterns and best practices for data analytics with amazon emr (ABD305)Design patterns and best practices for data analytics with amazon emr (ABD305)
Design patterns and best practices for data analytics with amazon emr (ABD305)Amazon Web Services
 
Building a Photorealistic Real-Time 3D Configurator with Server-Side Renderin...
Building a Photorealistic Real-Time 3D Configurator with Server-Side Renderin...Building a Photorealistic Real-Time 3D Configurator with Server-Side Renderin...
Building a Photorealistic Real-Time 3D Configurator with Server-Side Renderin...Amazon Web Services
 
GPSBUS221_Breaking Barriers Move Enterprise SAP Customers to SAP HANA on AWS ...
GPSBUS221_Breaking Barriers Move Enterprise SAP Customers to SAP HANA on AWS ...GPSBUS221_Breaking Barriers Move Enterprise SAP Customers to SAP HANA on AWS ...
GPSBUS221_Breaking Barriers Move Enterprise SAP Customers to SAP HANA on AWS ...Amazon Web Services
 
Scaling Up to Your First 10 Million Users
Scaling Up to Your First 10 Million UsersScaling Up to Your First 10 Million Users
Scaling Up to Your First 10 Million UsersAmazon Web Services
 
Serverless DevOps to the Rescue - SRV330 - re:Invent 2017
Serverless DevOps to the Rescue - SRV330 - re:Invent 2017Serverless DevOps to the Rescue - SRV330 - re:Invent 2017
Serverless DevOps to the Rescue - SRV330 - re:Invent 2017Amazon Web Services
 

Mais procurados (20)

AMF305_Autonomous Driving Algorithm Development on Amazon AI
AMF305_Autonomous Driving Algorithm Development on Amazon AIAMF305_Autonomous Driving Algorithm Development on Amazon AI
AMF305_Autonomous Driving Algorithm Development on Amazon AI
 
GPSTEC313_GPS Real-Time Data Processing with AWS Lambda Quickly, at Scale, an...
GPSTEC313_GPS Real-Time Data Processing with AWS Lambda Quickly, at Scale, an...GPSTEC313_GPS Real-Time Data Processing with AWS Lambda Quickly, at Scale, an...
GPSTEC313_GPS Real-Time Data Processing with AWS Lambda Quickly, at Scale, an...
 
GPSWKS301_Comprehensive Big Data Architecture Made Easy
GPSWKS301_Comprehensive Big Data Architecture Made EasyGPSWKS301_Comprehensive Big Data Architecture Made Easy
GPSWKS301_Comprehensive Big Data Architecture Made Easy
 
DAT316_Report from the field on Aurora PostgreSQL Performance
DAT316_Report from the field on Aurora PostgreSQL PerformanceDAT316_Report from the field on Aurora PostgreSQL Performance
DAT316_Report from the field on Aurora PostgreSQL Performance
 
STG206_Big Data Data Lakes and Data Oceans
STG206_Big Data Data Lakes and Data OceansSTG206_Big Data Data Lakes and Data Oceans
STG206_Big Data Data Lakes and Data Oceans
 
NET309_Best Practices for Securing an Amazon Virtual Private Cloud
NET309_Best Practices for Securing an Amazon Virtual Private CloudNET309_Best Practices for Securing an Amazon Virtual Private Cloud
NET309_Best Practices for Securing an Amazon Virtual Private Cloud
 
ARC205_Born in the Cloud
ARC205_Born in the CloudARC205_Born in the Cloud
ARC205_Born in the Cloud
 
CMP216_Use Amazon EC2 Spot Instances to Deploy a Deep Learning Framework on A...
CMP216_Use Amazon EC2 Spot Instances to Deploy a Deep Learning Framework on A...CMP216_Use Amazon EC2 Spot Instances to Deploy a Deep Learning Framework on A...
CMP216_Use Amazon EC2 Spot Instances to Deploy a Deep Learning Framework on A...
 
STG305_Deep Dive on Backup to the AWS Cloud
STG305_Deep Dive on Backup to the AWS CloudSTG305_Deep Dive on Backup to the AWS Cloud
STG305_Deep Dive on Backup to the AWS Cloud
 
AWS Database and Analytics State of the Union - 2017 - DAT201 - re:Invent 2017
AWS Database and Analytics State of the Union - 2017 - DAT201 - re:Invent 2017AWS Database and Analytics State of the Union - 2017 - DAT201 - re:Invent 2017
AWS Database and Analytics State of the Union - 2017 - DAT201 - re:Invent 2017
 
GPSTEC305-Machine Learning in Capital Markets
GPSTEC305-Machine Learning in Capital MarketsGPSTEC305-Machine Learning in Capital Markets
GPSTEC305-Machine Learning in Capital Markets
 
CMP316_Hedge Your Own Funds Run Monte Carlo Simulations on EC2 Spot Fleet
CMP316_Hedge Your Own Funds Run Monte Carlo Simulations on EC2 Spot FleetCMP316_Hedge Your Own Funds Run Monte Carlo Simulations on EC2 Spot Fleet
CMP316_Hedge Your Own Funds Run Monte Carlo Simulations on EC2 Spot Fleet
 
CON209_Interstella 8888 Learn How to Use Docker on AWS
CON209_Interstella 8888 Learn How to Use Docker on AWSCON209_Interstella 8888 Learn How to Use Docker on AWS
CON209_Interstella 8888 Learn How to Use Docker on AWS
 
Building Serverless Websites with Lambda@Edge - CTD309 - re:Invent 2017
Building Serverless Websites with Lambda@Edge - CTD309 - re:Invent 2017Building Serverless Websites with Lambda@Edge - CTD309 - re:Invent 2017
Building Serverless Websites with Lambda@Edge - CTD309 - re:Invent 2017
 
CON213_Hands-on Kubernetes on AWS
CON213_Hands-on Kubernetes on AWSCON213_Hands-on Kubernetes on AWS
CON213_Hands-on Kubernetes on AWS
 
Design patterns and best practices for data analytics with amazon emr (ABD305)
Design patterns and best practices for data analytics with amazon emr (ABD305)Design patterns and best practices for data analytics with amazon emr (ABD305)
Design patterns and best practices for data analytics with amazon emr (ABD305)
 
Building a Photorealistic Real-Time 3D Configurator with Server-Side Renderin...
Building a Photorealistic Real-Time 3D Configurator with Server-Side Renderin...Building a Photorealistic Real-Time 3D Configurator with Server-Side Renderin...
Building a Photorealistic Real-Time 3D Configurator with Server-Side Renderin...
 
GPSBUS221_Breaking Barriers Move Enterprise SAP Customers to SAP HANA on AWS ...
GPSBUS221_Breaking Barriers Move Enterprise SAP Customers to SAP HANA on AWS ...GPSBUS221_Breaking Barriers Move Enterprise SAP Customers to SAP HANA on AWS ...
GPSBUS221_Breaking Barriers Move Enterprise SAP Customers to SAP HANA on AWS ...
 
Scaling Up to Your First 10 Million Users
Scaling Up to Your First 10 Million UsersScaling Up to Your First 10 Million Users
Scaling Up to Your First 10 Million Users
 
Serverless DevOps to the Rescue - SRV330 - re:Invent 2017
Serverless DevOps to the Rescue - SRV330 - re:Invent 2017Serverless DevOps to the Rescue - SRV330 - re:Invent 2017
Serverless DevOps to the Rescue - SRV330 - re:Invent 2017
 

Semelhante a MCL309_Deep Learning on a Raspberry Pi

[AWS Dev Day] 실습워크샵 | 모두를 위한 컴퓨터 비전 딥러닝 툴킷, GluonCV 따라하기
[AWS Dev Day] 실습워크샵 | 모두를 위한 컴퓨터 비전 딥러닝 툴킷, GluonCV 따라하기[AWS Dev Day] 실습워크샵 | 모두를 위한 컴퓨터 비전 딥러닝 툴킷, GluonCV 따라하기
[AWS Dev Day] 실습워크샵 | 모두를 위한 컴퓨터 비전 딥러닝 툴킷, GluonCV 따라하기Amazon Web Services Korea
 
Time series modeling workd AMLD 2018 Lausanne
Time series modeling workd AMLD 2018 LausanneTime series modeling workd AMLD 2018 Lausanne
Time series modeling workd AMLD 2018 LausanneSunil Mallya
 
[NEW LAUNCH!] Introducing Amazon Elastic Inference: Reduce Deep Learning Infe...
[NEW LAUNCH!] Introducing Amazon Elastic Inference: Reduce Deep Learning Infe...[NEW LAUNCH!] Introducing Amazon Elastic Inference: Reduce Deep Learning Infe...
[NEW LAUNCH!] Introducing Amazon Elastic Inference: Reduce Deep Learning Infe...Amazon Web Services
 
MCL303-Deep Learning with Apache MXNet and Gluon
MCL303-Deep Learning with Apache MXNet and GluonMCL303-Deep Learning with Apache MXNet and Gluon
MCL303-Deep Learning with Apache MXNet and GluonAmazon Web Services
 
Build Deep Learning Applications Using Apache MXNet - Featuring Chick-fil-A (...
Build Deep Learning Applications Using Apache MXNet - Featuring Chick-fil-A (...Build Deep Learning Applications Using Apache MXNet - Featuring Chick-fil-A (...
Build Deep Learning Applications Using Apache MXNet - Featuring Chick-fil-A (...Amazon Web Services
 
MCL310_Building Deep Learning Applications with Apache MXNet and Gluon
MCL310_Building Deep Learning Applications with Apache MXNet and GluonMCL310_Building Deep Learning Applications with Apache MXNet and Gluon
MCL310_Building Deep Learning Applications with Apache MXNet and GluonAmazon Web Services
 
Build Deep Learning Applications Using Apache MXNet, Featuring Workday (AIM40...
Build Deep Learning Applications Using Apache MXNet, Featuring Workday (AIM40...Build Deep Learning Applications Using Apache MXNet, Featuring Workday (AIM40...
Build Deep Learning Applications Using Apache MXNet, Featuring Workday (AIM40...Amazon Web Services
 
MCL 322 Optimizing Training on Apache MXNet
MCL 322 Optimizing Training on Apache MXNet MCL 322 Optimizing Training on Apache MXNet
MCL 322 Optimizing Training on Apache MXNet Julien SIMON
 
Optimize Your Machine Learning Workloads
Optimize Your Machine Learning WorkloadsOptimize Your Machine Learning Workloads
Optimize Your Machine Learning WorkloadsAmazon Web Services
 
Building Content Recommendation Systems Using Apache MXNet and Gluon - MCL402...
Building Content Recommendation Systems Using Apache MXNet and Gluon - MCL402...Building Content Recommendation Systems Using Apache MXNet and Gluon - MCL402...
Building Content Recommendation Systems Using Apache MXNet and Gluon - MCL402...Amazon Web Services
 
AWS 機器學習 II ─ 深度學習 Deep Learning & MXNet
AWS 機器學習 II ─ 深度學習 Deep Learning & MXNetAWS 機器學習 II ─ 深度學習 Deep Learning & MXNet
AWS 機器學習 II ─ 深度學習 Deep Learning & MXNetAmazon Web Services
 
AWS re:Invent 2018 - AIM401 - Deep Learning using Tensorflow
AWS re:Invent 2018 - AIM401 - Deep Learning using TensorflowAWS re:Invent 2018 - AIM401 - Deep Learning using Tensorflow
AWS re:Invent 2018 - AIM401 - Deep Learning using TensorflowJulien SIMON
 
[REPEAT] Deep Learning Applications Using TensorFlow (AIM401-R) - AWS re:Inve...
[REPEAT] Deep Learning Applications Using TensorFlow (AIM401-R) - AWS re:Inve...[REPEAT] Deep Learning Applications Using TensorFlow (AIM401-R) - AWS re:Inve...
[REPEAT] Deep Learning Applications Using TensorFlow (AIM401-R) - AWS re:Inve...Amazon Web Services
 
Speeding up Deep Learning training and inference
Speeding up Deep Learning training and inferenceSpeeding up Deep Learning training and inference
Speeding up Deep Learning training and inferenceThomas Delteil
 
Start machine learning in 5 simple steps
Start machine learning in 5 simple stepsStart machine learning in 5 simple steps
Start machine learning in 5 simple stepsRenjith M P
 
Deep Learning with Apache MXNet (September 2017)
Deep Learning with Apache MXNet (September 2017)Deep Learning with Apache MXNet (September 2017)
Deep Learning with Apache MXNet (September 2017)Julien SIMON
 
Building Content Recommendation Systems using MXNet Gluon
Building Content Recommendation Systems using MXNet GluonBuilding Content Recommendation Systems using MXNet Gluon
Building Content Recommendation Systems using MXNet GluonApache MXNet
 
ACDKOCHI19 - Demystifying amazon sagemaker
ACDKOCHI19 - Demystifying amazon sagemakerACDKOCHI19 - Demystifying amazon sagemaker
ACDKOCHI19 - Demystifying amazon sagemakerAWS User Group Kochi
 
Introduction to Scalable Deep Learning on AWS with Apache MXNet
Introduction to Scalable Deep Learning on AWS with Apache MXNetIntroduction to Scalable Deep Learning on AWS with Apache MXNet
Introduction to Scalable Deep Learning on AWS with Apache MXNetAmazon Web Services
 
Optimizing training on Apache MXNet (January 2018)
Optimizing training on Apache MXNet (January 2018)Optimizing training on Apache MXNet (January 2018)
Optimizing training on Apache MXNet (January 2018)Julien SIMON
 

Semelhante a MCL309_Deep Learning on a Raspberry Pi (20)

[AWS Dev Day] 실습워크샵 | 모두를 위한 컴퓨터 비전 딥러닝 툴킷, GluonCV 따라하기
[AWS Dev Day] 실습워크샵 | 모두를 위한 컴퓨터 비전 딥러닝 툴킷, GluonCV 따라하기[AWS Dev Day] 실습워크샵 | 모두를 위한 컴퓨터 비전 딥러닝 툴킷, GluonCV 따라하기
[AWS Dev Day] 실습워크샵 | 모두를 위한 컴퓨터 비전 딥러닝 툴킷, GluonCV 따라하기
 
Time series modeling workd AMLD 2018 Lausanne
Time series modeling workd AMLD 2018 LausanneTime series modeling workd AMLD 2018 Lausanne
Time series modeling workd AMLD 2018 Lausanne
 
[NEW LAUNCH!] Introducing Amazon Elastic Inference: Reduce Deep Learning Infe...
[NEW LAUNCH!] Introducing Amazon Elastic Inference: Reduce Deep Learning Infe...[NEW LAUNCH!] Introducing Amazon Elastic Inference: Reduce Deep Learning Infe...
[NEW LAUNCH!] Introducing Amazon Elastic Inference: Reduce Deep Learning Infe...
 
MCL303-Deep Learning with Apache MXNet and Gluon
MCL303-Deep Learning with Apache MXNet and GluonMCL303-Deep Learning with Apache MXNet and Gluon
MCL303-Deep Learning with Apache MXNet and Gluon
 
Build Deep Learning Applications Using Apache MXNet - Featuring Chick-fil-A (...
Build Deep Learning Applications Using Apache MXNet - Featuring Chick-fil-A (...Build Deep Learning Applications Using Apache MXNet - Featuring Chick-fil-A (...
Build Deep Learning Applications Using Apache MXNet - Featuring Chick-fil-A (...
 
MCL310_Building Deep Learning Applications with Apache MXNet and Gluon
MCL310_Building Deep Learning Applications with Apache MXNet and GluonMCL310_Building Deep Learning Applications with Apache MXNet and Gluon
MCL310_Building Deep Learning Applications with Apache MXNet and Gluon
 
Build Deep Learning Applications Using Apache MXNet, Featuring Workday (AIM40...
Build Deep Learning Applications Using Apache MXNet, Featuring Workday (AIM40...Build Deep Learning Applications Using Apache MXNet, Featuring Workday (AIM40...
Build Deep Learning Applications Using Apache MXNet, Featuring Workday (AIM40...
 
MCL 322 Optimizing Training on Apache MXNet
MCL 322 Optimizing Training on Apache MXNet MCL 322 Optimizing Training on Apache MXNet
MCL 322 Optimizing Training on Apache MXNet
 
Optimize Your Machine Learning Workloads
Optimize Your Machine Learning WorkloadsOptimize Your Machine Learning Workloads
Optimize Your Machine Learning Workloads
 
Building Content Recommendation Systems Using Apache MXNet and Gluon - MCL402...
Building Content Recommendation Systems Using Apache MXNet and Gluon - MCL402...Building Content Recommendation Systems Using Apache MXNet and Gluon - MCL402...
Building Content Recommendation Systems Using Apache MXNet and Gluon - MCL402...
 
AWS 機器學習 II ─ 深度學習 Deep Learning & MXNet
AWS 機器學習 II ─ 深度學習 Deep Learning & MXNetAWS 機器學習 II ─ 深度學習 Deep Learning & MXNet
AWS 機器學習 II ─ 深度學習 Deep Learning & MXNet
 
AWS re:Invent 2018 - AIM401 - Deep Learning using Tensorflow
AWS re:Invent 2018 - AIM401 - Deep Learning using TensorflowAWS re:Invent 2018 - AIM401 - Deep Learning using Tensorflow
AWS re:Invent 2018 - AIM401 - Deep Learning using Tensorflow
 
[REPEAT] Deep Learning Applications Using TensorFlow (AIM401-R) - AWS re:Inve...
[REPEAT] Deep Learning Applications Using TensorFlow (AIM401-R) - AWS re:Inve...[REPEAT] Deep Learning Applications Using TensorFlow (AIM401-R) - AWS re:Inve...
[REPEAT] Deep Learning Applications Using TensorFlow (AIM401-R) - AWS re:Inve...
 
Speeding up Deep Learning training and inference
Speeding up Deep Learning training and inferenceSpeeding up Deep Learning training and inference
Speeding up Deep Learning training and inference
 
Start machine learning in 5 simple steps
Start machine learning in 5 simple stepsStart machine learning in 5 simple steps
Start machine learning in 5 simple steps
 
Deep Learning with Apache MXNet (September 2017)
Deep Learning with Apache MXNet (September 2017)Deep Learning with Apache MXNet (September 2017)
Deep Learning with Apache MXNet (September 2017)
 
Building Content Recommendation Systems using MXNet Gluon
Building Content Recommendation Systems using MXNet GluonBuilding Content Recommendation Systems using MXNet Gluon
Building Content Recommendation Systems using MXNet Gluon
 
ACDKOCHI19 - Demystifying amazon sagemaker
ACDKOCHI19 - Demystifying amazon sagemakerACDKOCHI19 - Demystifying amazon sagemaker
ACDKOCHI19 - Demystifying amazon sagemaker
 
Introduction to Scalable Deep Learning on AWS with Apache MXNet
Introduction to Scalable Deep Learning on AWS with Apache MXNetIntroduction to Scalable Deep Learning on AWS with Apache MXNet
Introduction to Scalable Deep Learning on AWS with Apache MXNet
 
Optimizing training on Apache MXNet (January 2018)
Optimizing training on Apache MXNet (January 2018)Optimizing training on Apache MXNet (January 2018)
Optimizing training on Apache MXNet (January 2018)
 

Mais de Amazon Web Services

Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...
Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...
Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...Amazon Web Services
 
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...Big Data per le Startup: come creare applicazioni Big Data in modalità Server...
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...Amazon Web Services
 
Esegui pod serverless con Amazon EKS e AWS Fargate
Esegui pod serverless con Amazon EKS e AWS FargateEsegui pod serverless con Amazon EKS e AWS Fargate
Esegui pod serverless con Amazon EKS e AWS FargateAmazon Web Services
 
Costruire Applicazioni Moderne con AWS
Costruire Applicazioni Moderne con AWSCostruire Applicazioni Moderne con AWS
Costruire Applicazioni Moderne con AWSAmazon Web Services
 
Come spendere fino al 90% in meno con i container e le istanze spot
Come spendere fino al 90% in meno con i container e le istanze spot Come spendere fino al 90% in meno con i container e le istanze spot
Come spendere fino al 90% in meno con i container e le istanze spot Amazon Web Services
 
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...Amazon Web Services
 
OpsWorks Configuration Management: automatizza la gestione e i deployment del...
OpsWorks Configuration Management: automatizza la gestione e i deployment del...OpsWorks Configuration Management: automatizza la gestione e i deployment del...
OpsWorks Configuration Management: automatizza la gestione e i deployment del...Amazon Web Services
 
Microsoft Active Directory su AWS per supportare i tuoi Windows Workloads
Microsoft Active Directory su AWS per supportare i tuoi Windows WorkloadsMicrosoft Active Directory su AWS per supportare i tuoi Windows Workloads
Microsoft Active Directory su AWS per supportare i tuoi Windows WorkloadsAmazon Web Services
 
Database Oracle e VMware Cloud on AWS i miti da sfatare
Database Oracle e VMware Cloud on AWS i miti da sfatareDatabase Oracle e VMware Cloud on AWS i miti da sfatare
Database Oracle e VMware Cloud on AWS i miti da sfatareAmazon Web Services
 
Crea la tua prima serverless ledger-based app con QLDB e NodeJS
Crea la tua prima serverless ledger-based app con QLDB e NodeJSCrea la tua prima serverless ledger-based app con QLDB e NodeJS
Crea la tua prima serverless ledger-based app con QLDB e NodeJSAmazon Web Services
 
API moderne real-time per applicazioni mobili e web
API moderne real-time per applicazioni mobili e webAPI moderne real-time per applicazioni mobili e web
API moderne real-time per applicazioni mobili e webAmazon Web Services
 
Database Oracle e VMware Cloud™ on AWS: i miti da sfatare
Database Oracle e VMware Cloud™ on AWS: i miti da sfatareDatabase Oracle e VMware Cloud™ on AWS: i miti da sfatare
Database Oracle e VMware Cloud™ on AWS: i miti da sfatareAmazon Web Services
 
Tools for building your MVP on AWS
Tools for building your MVP on AWSTools for building your MVP on AWS
Tools for building your MVP on AWSAmazon Web Services
 
How to Build a Winning Pitch Deck
How to Build a Winning Pitch DeckHow to Build a Winning Pitch Deck
How to Build a Winning Pitch DeckAmazon Web Services
 
Building a web application without servers
Building a web application without serversBuilding a web application without servers
Building a web application without serversAmazon Web Services
 
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...Amazon Web Services
 
Introduzione a Amazon Elastic Container Service
Introduzione a Amazon Elastic Container ServiceIntroduzione a Amazon Elastic Container Service
Introduzione a Amazon Elastic Container ServiceAmazon Web Services
 

Mais de Amazon Web Services (20)

Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...
Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...
Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...
 
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...Big Data per le Startup: come creare applicazioni Big Data in modalità Server...
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...
 
Esegui pod serverless con Amazon EKS e AWS Fargate
Esegui pod serverless con Amazon EKS e AWS FargateEsegui pod serverless con Amazon EKS e AWS Fargate
Esegui pod serverless con Amazon EKS e AWS Fargate
 
Costruire Applicazioni Moderne con AWS
Costruire Applicazioni Moderne con AWSCostruire Applicazioni Moderne con AWS
Costruire Applicazioni Moderne con AWS
 
Come spendere fino al 90% in meno con i container e le istanze spot
Come spendere fino al 90% in meno con i container e le istanze spot Come spendere fino al 90% in meno con i container e le istanze spot
Come spendere fino al 90% in meno con i container e le istanze spot
 
Open banking as a service
Open banking as a serviceOpen banking as a service
Open banking as a service
 
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
 
OpsWorks Configuration Management: automatizza la gestione e i deployment del...
OpsWorks Configuration Management: automatizza la gestione e i deployment del...OpsWorks Configuration Management: automatizza la gestione e i deployment del...
OpsWorks Configuration Management: automatizza la gestione e i deployment del...
 
Microsoft Active Directory su AWS per supportare i tuoi Windows Workloads
Microsoft Active Directory su AWS per supportare i tuoi Windows WorkloadsMicrosoft Active Directory su AWS per supportare i tuoi Windows Workloads
Microsoft Active Directory su AWS per supportare i tuoi Windows Workloads
 
Computer Vision con AWS
Computer Vision con AWSComputer Vision con AWS
Computer Vision con AWS
 
Database Oracle e VMware Cloud on AWS i miti da sfatare
Database Oracle e VMware Cloud on AWS i miti da sfatareDatabase Oracle e VMware Cloud on AWS i miti da sfatare
Database Oracle e VMware Cloud on AWS i miti da sfatare
 
Crea la tua prima serverless ledger-based app con QLDB e NodeJS
Crea la tua prima serverless ledger-based app con QLDB e NodeJSCrea la tua prima serverless ledger-based app con QLDB e NodeJS
Crea la tua prima serverless ledger-based app con QLDB e NodeJS
 
API moderne real-time per applicazioni mobili e web
API moderne real-time per applicazioni mobili e webAPI moderne real-time per applicazioni mobili e web
API moderne real-time per applicazioni mobili e web
 
Database Oracle e VMware Cloud™ on AWS: i miti da sfatare
Database Oracle e VMware Cloud™ on AWS: i miti da sfatareDatabase Oracle e VMware Cloud™ on AWS: i miti da sfatare
Database Oracle e VMware Cloud™ on AWS: i miti da sfatare
 
Tools for building your MVP on AWS
Tools for building your MVP on AWSTools for building your MVP on AWS
Tools for building your MVP on AWS
 
How to Build a Winning Pitch Deck
How to Build a Winning Pitch DeckHow to Build a Winning Pitch Deck
How to Build a Winning Pitch Deck
 
Building a web application without servers
Building a web application without serversBuilding a web application without servers
Building a web application without servers
 
Fundraising Essentials
Fundraising EssentialsFundraising Essentials
Fundraising Essentials
 
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
 
Introduzione a Amazon Elastic Container Service
Introduzione a Amazon Elastic Container ServiceIntroduzione a Amazon Elastic Container Service
Introduzione a Amazon Elastic Container Service
 

MCL309_Deep Learning on a Raspberry Pi

  • 1. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS re:INVENT MCL309 Deep Learning on a Raspberry Pi J u l i e n S i m o n , P r i n c i p a l A I / M L E v a n g e l i s t , E M E A @ j u l s i m o n M C L 3 0 9 N o v e m b e r 2 7 , 2 0 1 7
  • 2. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. What to expect from this workshop • Welcome and housekeeping—5 minutes • An introduction to the Apache MXNet API—20 minutes (slides) • Training an MXNet model—10 minutes • Setting up your Raspberry Pi—20 minutes • Using pre-trained models—30 minutes • Building an app with MXNet, Amazon Rekognition, and Amazon Polly—60 minutes • Wrap-up—5 minutes
  • 3. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Welcome! Matthieu Fuzellier, Sr. Consultant IoT, Professional Services (US) Stephan Hadinger, Senior Manager, Solution Architecture (France) Adrian Hornsby, Technical Evangelist (Nordics) Rudy Krol, Solutions Architect (France) Troy Larson, Sr. DevOps Cloud Architect, Professional Services (US) Nicolas Malaval, Consultant, Professional Services (France)
  • 4. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. An introduction to the Apache MXNet API
  • 5. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Apache MXNet: Open source l i brary for d eep l earni ng Programmable Portable High performance Near linear scaling across hundreds of GPUs Highly efficient models for mobile and IoT Simple syntax, multiple languages Most open Best On AWS Optimized for deep learning on AWS Accepted into the Apache Incubator mxnet.incubator.apache.org
  • 6. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Neural networks x = x11, x12, …. x1I x21, x22, …. x2I x…, x.., …. x.I xm1, xm2, …. xmI I features m samples y = y1 y2 y… ym m labels Total number of predictions Accuracy = Number of correct predictions
  • 7. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Training Training data set Training Trained neural network Number of epochs Batch size Learning rate Hyper parameters
  • 8. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Validation Validation data set Trained neural network Validation accuracy Prediction at the end of each epoch Stop training when validation accuracy stops increasing Saving parameters at the end of each epoch is a good idea ;)
  • 9. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. The Apache MXNet API • Storing and accessing data  multi-dimensional arrays: NDArray API • Neural network (layers, weights, activation functions)  Symbol API • Serving data during training and validation  Iterators • Data + neural network = model  Module API
  • 10. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Let’s build a data set of 1000 samples with 100 features each and belonging to one of 10 categories. We split it 80/20 for training and validation. sample_count = 1000 train_count = 800 valid_count = sample_count - train_count feature_count = 100 category_count = 10 X = mx.nd.uniform(low=0, high=1, shape=(sample_count,feature_count)) Y = mx.nd.empty((sample_count,)) for i in range(0,sample_count-1): Y[i] = np.random.randint(0,category_count) X_train = mx.nd.crop(X, begin=(0,0), end=(train_count,feature_count)) Y_train = Y[0:train_count] X_valid = mx.nd.crop(X, begin=(train_count,0), end=(sample_count,feature_count)) Y_valid = Y[train_count:sample_count] print(X.shape, Y.shape, X_train.shape, Y_train.shape, X_valid.shape, Y_valid.shape) NDArray API example h t t p s : / / m x n e t . i n c u b a t o r . a p a c h e . o r g / a p i / p y t h o n / n d a r r a y . h t m l
  • 11. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Let’s build a simple Multi-Layer Perceptron 1. Input layer 2. One hidden layer with 64 neurons, using the Rectified Linear Unit activation function 3. Output layer with 10 neurons, using the Softmax function to output probabilities data = mx.sym.Variable('data') fc1 = mx.sym.FullyConnected(data, name='fc1', num_hidden=64) relu1 = mx.sym.Activation(fc1, name='relu1', act_type="relu") fc2 = mx.sym.FullyConnected(relu1, name='fc2', num_hidden=category_count) out = mx.sym.SoftmaxOutput(fc2, name='softmax') mod = mx.mod.Module(out) Symbol API example h t t p s : / / m x n e t . i n c u b a t o r . a p a c h e . o r g / a p i / p y t h o n / s y m b o l . h t m l
  • 12. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. • Training is performed batch by batch • Iterators take care of this automatically  • MXNet provides iterators for NDArrays, image files, and more • You can also write your own batch = 10 train_iter = mx.io.NDArrayIter(data=X_train,label=Y_train,batch_size=batch) val_iter = mx.io.NDArrayIter(data=X_valid,label=Y_valid, batch_size=batch) Iterator API example h t t p s : / / m x n e t . i n c u b a t o r . a p a c h e . o r g / a p i / p y t h o n / i o . h t m l
  • 13. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. • This is where the rubber meets the road • Binding the data set to the network • Setting initialization and optimization parameters • Training the model • Saving the trained model nb_epochs=50 mod = mx.mod.Module(out) mod.bind(data_shapes=train_iter.provide_data, label_shapes=train_iter.provide_label) mod.init_params(initializer=mx.init.Xavier(magnitude=2.)) mod.init_optimizer(optimizer='sgd', optimizer_params=(('learning_rate', 0.1), )) mod.fit(train_iter, num_epoch=nb_epochs) mod.save_checkpoint(”myFirstModel", nb_epochs) Module API example h t t p s : / / m x n e t . i n c u b a t o r . a p a c h e . o r g / a p i / p y t h o n / m o d u l e . h t m l
  • 14. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. $ python introduction.py ((1000L, 100L), (1000L,), (800L, 100L), (800L,), (200L, 100L), (200L,)) INFO:root:Epoch[0] Train-accuracy=0.093750 INFO:root:Epoch[0] Time cost=0.051 . . . INFO:root:Epoch[49] Train-accuracy=0.995000 INFO:root:Epoch[49] Time cost=0.047 Validation accuracy: 0.12 • The model is able to perfectly learn our synthetic training set (universal approximation theorem) • Validation accuracy is what you need to look at Putting it all together 0 1 _ i n t r o d u c t i o n . p y
  • 15. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Training an MXNet model
  • 16. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. The MNIST data set • 70,000 hand-written digits • 28x28 grayscale images
  • 17. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. You have three options 1. Install on your own machine • Linux, MacOS, Docker—no Windows • https://mxnet.incubator.apache.org/get_started/install.html 2. Start an Amazon EC2 instance using the Deep Learning AMI in your own account • CPU or GPU, it’s up to you • Scripts are provided: ec2_setup.sh and ec2_cleanup.sh • Read them first! 3. Use the shared Amazon EC2 instance • Instructions will be provided • PLEASE work in your own folder: mkdir ~/firstname-lastname Setting up your MXNet machine
  • 18. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Training models on MNIST 0 2 _ m n i s t / • Download the data set • Either from the web: get_mnist_from_web.sh • Or from S3: get_mnist_from_s3.sh • Train two models • A Multi-Layer Perceptron: trainMlp.py • The LeNet Convolutional Neural Network: trainLeNet.py • How does training differ? • Use each model to predict new digits: predict.py • How does prediction differ?
  • 19. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Setting up your Raspberry Pi
  • 20. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Setting up the hardware & network • Instructions will be provided • Ask us for help if you’re blocked • Please be a good neighbor: help out other participants if you can 
  • 21. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Installing MXNet 0 3 _ p i S e t u p / • Install a pre-built version of MXNet: setup.sh • For reference only (>> 1 hour): build from source: build.sh • Detailed installation instructions: https://mxnet.incubator.apache.org/get_started/install.html
  • 22. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Using pre-trained models
  • 23. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Training MNIST on the Pi 0 2 _ m n i s t / • Download the data set • Either from the web: get_mnist_from_web.sh • Or from Amazon Simple Storage Service: get_mnist_from_s3.sh • Train two models • A Multi-Layer Perceptron: trainMlp.py • The LeNet Convolutional Neural Network: trainLeNet.py • What’s the problem? • Obviously, you wouldn’t want to train CNNs on a Raspberry Pi  • Even on a powerful system, training is not an easy task, which leads us to…
  • 24. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Why pre-trained models make sense • Training a complex model on a large data set can take days • Finding the right settings is not easy • A pre-trained model may be good enough to solve your problem • You can also fine-tune it on your own data to improve accuracy • Take a look at the MXNET model zoo • https://mxnet.incubator.apache.org/model_zoo/ • Two files: model definition (JSON), model weights (.params)
  • 25. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Using pre-trained models 0 4 _ p i M o d e l s / • Download three pre-trained models for image classification • Either from the web: get_models_from_web.sh • Or from Amazon S3: get_models_from_s3.sh • Read the code in classify.py. Make sure you understand how to: • Load a model • Load a single image from file and turn it into an NDArray • Build a ”fake” iterator with namedtuple • Collect results on the output layer and find the top classes • Run classify.py • What happens and why? Fix the problem • Try your own images
  • 26. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. B u i l d i n g a n a p p w i t h M X N e t , A m a z o n R e k o g n i t i o n a n d A m a z o n P o l l y
  • 27. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Connecting and testing the camera Power down the Pi first from picamera import PiCamera cam = PiCamera() cam.resolution=(640,480) cam.capture(”myimage.jpg”) cam.close() Copy the image on your laptop and check that it’s correct If not, you probably need to flip the cable  Your setup should look like this
  • 28. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Using a pre-trained MXNet model 0 5 _ p i M x n e t / 1. Add code to classify a picture taken by the camera 2. Take pictures and classify them: • Pictures with a single object • Pictures with nested objects (for example, a car on a book cover) • Pictures with multiple objects • Pictures of people • What works well and what doesn’t? Any idea why?
  • 29. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Adding Amazon Polly 0 6 _ p i P o l l y / • Amazon Polly is a text-to-speech service https://aws.amazon.com/polly • You can generate a sound file from a text string with a single API call https://docs.aws.amazon.com/polly/latest/dg/API_SynthesizeSpeech.html • Try the AWS Command Line Interface first: “aws polly…” • Using information returned by the MXNet model, we build a text string saying “I’m <score>% sure this is a <top category name>” • Play it with Amazon Polly • Try different voices
  • 30. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Adding Amazon Rekognition 0 7 _ p i R e k o g n i t i o n / • Amazon Rekognition is an object and face detection service https://aws.amazon.com/rekognition • You can detect objects or faces with a single API call https://docs.aws.amazon.com/rekognition/latest/dg/API_DetectLabels.html https://docs.aws.amazon.com/rekognition/latest/dg/API_DetectFaces.html • Try the AWS CLI first: “aws rekognition …” • Add code to run Amazon Rekognition on a picture • Use the output to build a text message and play it with Amazon Polly
  • 31. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Wrap-up
  • 32. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. • If you created an instance, don’t forget to terminate it (ec2_cleanup.sh) • You can keep the hardware  Build cool stuff with it and let us know. We’re always happy to share and retweet. • You also get $25 credits  Don’t forget them on your way out. • Please check out the other deep learning sessions (MCL322 *hint* *hint*) • Thank you very much. Have a GREAT re:Invent!
  • 33. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Resources https://aws.amazon.com/ai https://aws.amazon.com/blogs/ai https://mxnet.io https://github.com/apache/incubator-mxnet https://github.com/gluon-api https://github.com/awslabs/sockeye https://medium.com/@julsimon
  • 34. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Thank you! J u l i e n S i m o n , P r i n c i p a l A I / M L E v a n g e l i s t , E M E A @ j u l s i m o n