SlideShare a Scribd company logo
August 13, 2018
Catherine Diep, Paul Van Eck
Introduction to Running AI
Workloads on PowerAI
Agenda
•IBM PowerAI Overview
•AI Workload Demos using TensorFlow
•PyTorch Hands-On Lab
2
Icpp power ai-workshop 2018
More Information
4
Visit website: http://bit.ly/powericpp
Using PowerAI for your workloads
5
Activate the virtual environment for your framework to get started!
Example:
source /opt/DL/tensorflow/bin/tensorflow-activate
source /opt/DL/pytorch/bin/pytorch-activate
Deep learning overview
6
Deep Learning consists of algorithms that permit software to train itself— by
exposing multilayered neural networks to vast amounts of data.
• Map x → y
• Neural net is a graph
• Data flow: left to right
• Input(s) of the current cell are the
output(s) from previous cells
• Tweak all weights until output matches
expected outcome
Computation at a node
7
Training = tweak weights to minimize error (loss)
8
Repeat over and over and over ...
Let’s look at some TensorFlow workloads!
MNIST
The MNIST (Modified National Institute of Standards and Technology)
dataset consists of 60,000 images of handwritten digits like:
Each image has an associated label denoting which digit it is.
The above images would have labels 5, 0, 4, and 1.
Problem Description: Image Classification
We want to be able to train a deep learning model using the MNIST dataset that
will be able to look at images and predict what digits they are.
Computer Vision
How machines view images:
1. Download workload
=> cd
=> git clone https://github.com/pvaneck/tf_mnist
2. Training
=> cd tf_mnist
=> python ./train_basic_model.py
The training result will be saved in ~/tf_mnist/saved-model
13
Running the MNIST workload
Implement Placeholders
• Placeholders are input
• x is a 2D array for the images:
• Each row is one flattened 28x28 image
• First dimension is “None”, to be used to pull in a batch of images at a time
(more later)
• y_ is 2D array for the labels:
• Second dimension 10 for the one-hot representation
# Placeholder that will be fed image data.
x = tf.placeholder(tf.float32, [None, 784])
# Placeholder that will be fed the correct labels.
y_ = tf.placeholder(tf.float32, [None, 10])
Implement Weight and Bias
• Weight and Bias are variables: to be tweaked during training
• Weight is a 2D array: 784 x 10
• Bias is a vector: 10
• Initialized with certain values: important for optimization algorithm
def weight_variable(shape):
"""Generates a weight variable of a given shape."""
initial = tf.truncated_normal(shape, stddev=0.1)
return tf.Variable(initial)
def bias_variable(shape):
"""Generates a bias variable of a given shape."""
initial = tf.constant(0.1, shape=shape)
return tf.Variable(initial)
# Define weight and bias.
W = weight_variable([784, 10])
b = bias_variable([10])
Implement Regression and Loss Optimizer
• Neural network: Regression + SoftMax
• Loss function: how far off is the prediction from the label
• Optimizer algorithm: how to tweak the variables
# Here we define our model which utilizes the softmax regression.
y = tf.nn.softmax(tf.matmul(x, W) + b)
# Define our loss.
cross_entropy = tf.reduce_mean(-tf.reduce_sum(y_ * tf.log(y), reduction_indices=[1]))
# Define our optimizer.
train_step = tf.train.GradientDescentOptimizer(0.5).minimize(cross_entropy)
17
Basic Linear Regression MNIST
3. Prediction
18
Running the MNIST workload (continued)
Predict the class of an image using the models saved in the ~/tf_mnist/saved-model directory with a
sample image from ~/tf_mnist/sample-images directory.
=> python ./classify_mnist.py sample-images/img_1.jpg
# Sample image (img_1.jpg):
# This is the program output:
2 (confidence = 0.99987)
3 (confidence = 0.00010)
0 (confidence = 0.00003)
8 (confidence = 0.00000)
5 (confidence = 0.00000)
The result shows that the answer with the most confidence is “2”.
19
Convolutional Neural Net
● Neural network with series of convolutional, downsampling, and non-linear layers
● Are deployed in many practical applications
○ Image and speech recognition, video analysis, drug discovery
● Most commonly used for image classification
Extending MNIST concepts
Create a mobile handwritten Hangul translation app
https://developer.ibm.com/code/patterns/create-mobile-handwritten-hangul-translation-app/
Let’s try some PyTorch!
PyTorch
PyTorch is a relatively new deep learning framework. Yet, it has begun to gain
adoption especially among researchers and data scientists.
▪ Goal is to build a flexible deep learning research platform that supports
▪ Dynamic computation graphs
▪ Native Python packages
▪ Auto-differentiation (gradient computations)
▪ Open sourced January, 2017
▪ Rapid adoption one year in …
▪ 3,983 github repo mentioned PyTorch in their name or description
▪ Taught in universities classes (Stanford, Carnegie Mellon University, ....)
▪ Fast growing community
▪ 5,400 users wrote 21k posts discussing 5,200 topics on PyTorch forums
▪ Merged with Caffe2 March 30, 2018
▪ Currently at version 0.4.0
PyTorch Abstractions (Major API update in version 0.4.0)
● Tensor
○ Multi-dimensional arrays
○ Similar to NumPy (np) ndarrays, but can also be used on a GPU
○ Can easily convert from np arrays to torch tensor and vise versa
○ Support automatic differentiation for all operations on tensors.
○ Members includes .data (tensor), .grad (gradient w.r.t corresponding
.data), etc.
○ Package: “import torch”
○ Tensor tutorial
○ Autograd tutorial
● Module
○ Base class to build neural network.
○ Inputs & output for training are Tensors.
○ Store learnable weights & biases as parameters
○ May store states
○ Package: “import torch.nn.Module”
○ Module tutorial
● And many more ….
● Consult handouts for credentials and access information.
24
Open Jupyter notebooks

More Related Content

PDF
OpenPOWER Workshop in Silicon Valley
PDF
PyCon Estonia 2019
PDF
Keynote at Converge 2019
PDF
Standardizing arrays -- Microsoft Presentation
PPTX
Deep learning with Tensorflow in R
PDF
Array computing and the evolution of SciPy, NumPy, and PyData
PPTX
Scaling Python to CPUs and GPUs
PDF
SciPy Latin America 2019
OpenPOWER Workshop in Silicon Valley
PyCon Estonia 2019
Keynote at Converge 2019
Standardizing arrays -- Microsoft Presentation
Deep learning with Tensorflow in R
Array computing and the evolution of SciPy, NumPy, and PyData
Scaling Python to CPUs and GPUs
SciPy Latin America 2019

What's hot (20)

PPTX
Tensorflow
PDF
Deep Learning with PyTorch
PDF
Intro to TensorFlow and PyTorch Workshop at Tubular Labs
PPTX
Tensorflow - Intro (2017)
PDF
Introduction To TensorFlow | Deep Learning with TensorFlow | TensorFlow For B...
PDF
Machine Intelligence at Google Scale: TensorFlow
PDF
TensorFlow
PDF
Tensorflow presentation
PDF
Python NumPy Tutorial | NumPy Array | Edureka
PPTX
Tensorflow windows installation
PDF
TENSORFLOW: ARCHITECTURE AND USE CASE - NASA SPACE APPS CHALLENGE by Gema Par...
PDF
3 python packages
 
PDF
深層学習フレームワーク概要とChainerの事例紹介
PDF
TensorFlow and Keras: An Overview
PDF
TensorFlow Tutorial | Deep Learning Using TensorFlow | TensorFlow Tutorial Py...
PDF
TensorFlow In 10 Minutes | Deep Learning & TensorFlow | Edureka
PDF
Open source ai_technical_trend
PPTX
Neural Networks with Google TensorFlow
PDF
How to use tensorflow
PDF
Introduction to Neural Networks in Tensorflow
Tensorflow
Deep Learning with PyTorch
Intro to TensorFlow and PyTorch Workshop at Tubular Labs
Tensorflow - Intro (2017)
Introduction To TensorFlow | Deep Learning with TensorFlow | TensorFlow For B...
Machine Intelligence at Google Scale: TensorFlow
TensorFlow
Tensorflow presentation
Python NumPy Tutorial | NumPy Array | Edureka
Tensorflow windows installation
TENSORFLOW: ARCHITECTURE AND USE CASE - NASA SPACE APPS CHALLENGE by Gema Par...
3 python packages
 
深層学習フレームワーク概要とChainerの事例紹介
TensorFlow and Keras: An Overview
TensorFlow Tutorial | Deep Learning Using TensorFlow | TensorFlow Tutorial Py...
TensorFlow In 10 Minutes | Deep Learning & TensorFlow | Edureka
Open source ai_technical_trend
Neural Networks with Google TensorFlow
How to use tensorflow
Introduction to Neural Networks in Tensorflow
Ad

Similar to Icpp power ai-workshop 2018 (20)

PDF
Power ai tensorflowworkloadtutorial-20171117
PDF
A Tale of Three Deep Learning Frameworks: TensorFlow, Keras, & PyTorch with B...
PPTX
Demystifying-AI-Frameworks-TensorFlow-PyTorch-JAX-and-More (1).pptx
PDF
Neural Networks from Scratch - TensorFlow 101
PDF
Persian MNIST in 5 Minutes
PPTX
Deep Learning with TensorFlow: Understanding Tensors, Computations Graphs, Im...
PDF
A Tour of Tensorflow's APIs
PDF
Neural Networks in the Wild: Handwriting Recognition
PDF
ML in Android
PDF
maXbox starter65 machinelearning3
PDF
Deep-Learning-with-PydddddddddddddTorch.pdf
PDF
Machine learning with py torch
PDF
Introduction To Using TensorFlow & Deep Learning
PDF
TensorFlow example for AI Ukraine2016
PDF
implementing _Training_Neural_Network_with_PyTorch .pdf
PDF
Lucio Floretta - TensorFlow and Deep Learning without a PhD - Codemotion Mila...
PDF
Hand Written Digit Classification
PDF
0b85886e-4490-4af0-8b46-7ff3caf5dc2e.pdf
PDF
Dive Into PyTorch
PPTX
Teach a neural network to read handwriting
Power ai tensorflowworkloadtutorial-20171117
A Tale of Three Deep Learning Frameworks: TensorFlow, Keras, & PyTorch with B...
Demystifying-AI-Frameworks-TensorFlow-PyTorch-JAX-and-More (1).pptx
Neural Networks from Scratch - TensorFlow 101
Persian MNIST in 5 Minutes
Deep Learning with TensorFlow: Understanding Tensors, Computations Graphs, Im...
A Tour of Tensorflow's APIs
Neural Networks in the Wild: Handwriting Recognition
ML in Android
maXbox starter65 machinelearning3
Deep-Learning-with-PydddddddddddddTorch.pdf
Machine learning with py torch
Introduction To Using TensorFlow & Deep Learning
TensorFlow example for AI Ukraine2016
implementing _Training_Neural_Network_with_PyTorch .pdf
Lucio Floretta - TensorFlow and Deep Learning without a PhD - Codemotion Mila...
Hand Written Digit Classification
0b85886e-4490-4af0-8b46-7ff3caf5dc2e.pdf
Dive Into PyTorch
Teach a neural network to read handwriting
Ad

More from Ganesan Narayanasamy (20)

PDF
Empowering Engineering Faculties: Bridging the Gap with Emerging Technologies
PDF
Chip Design Curriculum development Residency program
PDF
Basics of Digital Design and Verilog
PDF
180 nm Tape out experience using Open POWER ISA
PDF
Workload Transformation and Innovations in POWER Architecture
PDF
OpenPOWER Workshop at IIT Roorkee
PDF
Deep Learning Use Cases using OpenPOWER systems
PDF
IBM BOA for POWER
PDF
OpenPOWER System Marconi100
PDF
OpenPOWER Latest Updates
PDF
POWER10 innovations for HPC
PDF
Deeplearningusingcloudpakfordata
PDF
OpenCAPI-based Image Analysis Pipeline for 18 GB/s kilohertz-framerate X-ray ...
PDF
AI in healthcare and Automobile Industry using OpenPOWER/IBM POWER9 systems
PDF
AI in healthcare - Use Cases
PDF
AI in Health Care using IBM Systems/OpenPOWER systems
PDF
AI in Healh Care using IBM POWER systems
PDF
Poster from NUS
PDF
SAP HANA on POWER9 systems
PPTX
Graphical Structure Learning accelerated with POWER9
Empowering Engineering Faculties: Bridging the Gap with Emerging Technologies
Chip Design Curriculum development Residency program
Basics of Digital Design and Verilog
180 nm Tape out experience using Open POWER ISA
Workload Transformation and Innovations in POWER Architecture
OpenPOWER Workshop at IIT Roorkee
Deep Learning Use Cases using OpenPOWER systems
IBM BOA for POWER
OpenPOWER System Marconi100
OpenPOWER Latest Updates
POWER10 innovations for HPC
Deeplearningusingcloudpakfordata
OpenCAPI-based Image Analysis Pipeline for 18 GB/s kilohertz-framerate X-ray ...
AI in healthcare and Automobile Industry using OpenPOWER/IBM POWER9 systems
AI in healthcare - Use Cases
AI in Health Care using IBM Systems/OpenPOWER systems
AI in Healh Care using IBM POWER systems
Poster from NUS
SAP HANA on POWER9 systems
Graphical Structure Learning accelerated with POWER9

Recently uploaded (20)

PDF
Approach and Philosophy of On baking technology
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PPTX
A Presentation on Artificial Intelligence
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Review of recent advances in non-invasive hemoglobin estimation
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
NewMind AI Monthly Chronicles - July 2025
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Modernizing your data center with Dell and AMD
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Approach and Philosophy of On baking technology
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Chapter 3 Spatial Domain Image Processing.pdf
A Presentation on Artificial Intelligence
The AUB Centre for AI in Media Proposal.docx
Reach Out and Touch Someone: Haptics and Empathic Computing
Review of recent advances in non-invasive hemoglobin estimation
Digital-Transformation-Roadmap-for-Companies.pptx
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Diabetes mellitus diagnosis method based random forest with bat algorithm
NewMind AI Monthly Chronicles - July 2025
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
MYSQL Presentation for SQL database connectivity
Agricultural_Statistics_at_a_Glance_2022_0.pdf
“AI and Expert System Decision Support & Business Intelligence Systems”
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Modernizing your data center with Dell and AMD
CIFDAQ's Market Insight: SEC Turns Pro Crypto
How UI/UX Design Impacts User Retention in Mobile Apps.pdf

Icpp power ai-workshop 2018

  • 1. August 13, 2018 Catherine Diep, Paul Van Eck Introduction to Running AI Workloads on PowerAI
  • 2. Agenda •IBM PowerAI Overview •AI Workload Demos using TensorFlow •PyTorch Hands-On Lab 2
  • 4. More Information 4 Visit website: http://bit.ly/powericpp
  • 5. Using PowerAI for your workloads 5 Activate the virtual environment for your framework to get started! Example: source /opt/DL/tensorflow/bin/tensorflow-activate source /opt/DL/pytorch/bin/pytorch-activate
  • 6. Deep learning overview 6 Deep Learning consists of algorithms that permit software to train itself— by exposing multilayered neural networks to vast amounts of data. • Map x → y • Neural net is a graph • Data flow: left to right • Input(s) of the current cell are the output(s) from previous cells • Tweak all weights until output matches expected outcome
  • 8. Training = tweak weights to minimize error (loss) 8 Repeat over and over and over ...
  • 9. Let’s look at some TensorFlow workloads!
  • 10. MNIST The MNIST (Modified National Institute of Standards and Technology) dataset consists of 60,000 images of handwritten digits like: Each image has an associated label denoting which digit it is. The above images would have labels 5, 0, 4, and 1.
  • 11. Problem Description: Image Classification We want to be able to train a deep learning model using the MNIST dataset that will be able to look at images and predict what digits they are.
  • 13. 1. Download workload => cd => git clone https://github.com/pvaneck/tf_mnist 2. Training => cd tf_mnist => python ./train_basic_model.py The training result will be saved in ~/tf_mnist/saved-model 13 Running the MNIST workload
  • 14. Implement Placeholders • Placeholders are input • x is a 2D array for the images: • Each row is one flattened 28x28 image • First dimension is “None”, to be used to pull in a batch of images at a time (more later) • y_ is 2D array for the labels: • Second dimension 10 for the one-hot representation # Placeholder that will be fed image data. x = tf.placeholder(tf.float32, [None, 784]) # Placeholder that will be fed the correct labels. y_ = tf.placeholder(tf.float32, [None, 10])
  • 15. Implement Weight and Bias • Weight and Bias are variables: to be tweaked during training • Weight is a 2D array: 784 x 10 • Bias is a vector: 10 • Initialized with certain values: important for optimization algorithm def weight_variable(shape): """Generates a weight variable of a given shape.""" initial = tf.truncated_normal(shape, stddev=0.1) return tf.Variable(initial) def bias_variable(shape): """Generates a bias variable of a given shape.""" initial = tf.constant(0.1, shape=shape) return tf.Variable(initial) # Define weight and bias. W = weight_variable([784, 10]) b = bias_variable([10])
  • 16. Implement Regression and Loss Optimizer • Neural network: Regression + SoftMax • Loss function: how far off is the prediction from the label • Optimizer algorithm: how to tweak the variables # Here we define our model which utilizes the softmax regression. y = tf.nn.softmax(tf.matmul(x, W) + b) # Define our loss. cross_entropy = tf.reduce_mean(-tf.reduce_sum(y_ * tf.log(y), reduction_indices=[1])) # Define our optimizer. train_step = tf.train.GradientDescentOptimizer(0.5).minimize(cross_entropy)
  • 18. 3. Prediction 18 Running the MNIST workload (continued) Predict the class of an image using the models saved in the ~/tf_mnist/saved-model directory with a sample image from ~/tf_mnist/sample-images directory. => python ./classify_mnist.py sample-images/img_1.jpg # Sample image (img_1.jpg): # This is the program output: 2 (confidence = 0.99987) 3 (confidence = 0.00010) 0 (confidence = 0.00003) 8 (confidence = 0.00000) 5 (confidence = 0.00000) The result shows that the answer with the most confidence is “2”.
  • 19. 19 Convolutional Neural Net ● Neural network with series of convolutional, downsampling, and non-linear layers ● Are deployed in many practical applications ○ Image and speech recognition, video analysis, drug discovery ● Most commonly used for image classification
  • 20. Extending MNIST concepts Create a mobile handwritten Hangul translation app https://developer.ibm.com/code/patterns/create-mobile-handwritten-hangul-translation-app/
  • 21. Let’s try some PyTorch!
  • 22. PyTorch PyTorch is a relatively new deep learning framework. Yet, it has begun to gain adoption especially among researchers and data scientists. ▪ Goal is to build a flexible deep learning research platform that supports ▪ Dynamic computation graphs ▪ Native Python packages ▪ Auto-differentiation (gradient computations) ▪ Open sourced January, 2017 ▪ Rapid adoption one year in … ▪ 3,983 github repo mentioned PyTorch in their name or description ▪ Taught in universities classes (Stanford, Carnegie Mellon University, ....) ▪ Fast growing community ▪ 5,400 users wrote 21k posts discussing 5,200 topics on PyTorch forums ▪ Merged with Caffe2 March 30, 2018 ▪ Currently at version 0.4.0
  • 23. PyTorch Abstractions (Major API update in version 0.4.0) ● Tensor ○ Multi-dimensional arrays ○ Similar to NumPy (np) ndarrays, but can also be used on a GPU ○ Can easily convert from np arrays to torch tensor and vise versa ○ Support automatic differentiation for all operations on tensors. ○ Members includes .data (tensor), .grad (gradient w.r.t corresponding .data), etc. ○ Package: “import torch” ○ Tensor tutorial ○ Autograd tutorial ● Module ○ Base class to build neural network. ○ Inputs & output for training are Tensors. ○ Store learnable weights & biases as parameters ○ May store states ○ Package: “import torch.nn.Module” ○ Module tutorial ● And many more ….
  • 24. ● Consult handouts for credentials and access information. 24 Open Jupyter notebooks