DL Lab Manual
DL Lab Manual
INTRODUCTION
TO DEEP LEARNING
WITH KERAS AND TENSORFLOW
LEARNING GOALS
Main goal:
Become familiar with main ideas and
process
2
INTRO TO DL, PART 1 LAB 1: CNNs AND KERAS 1:50-2:30 ET
101 LAB 2: TROPICAL CYCLONES
Data
Nice to
meet you! • US Naval Research Laboratory (NRL)
• 2000 to 2016
• ~30 minute interval
• Pacific and Atlantic
• Multiple geostationary satellites
• GOES, Himawari, MTSAT, etc…
• ~45,000 images
DL
Source: https://www.nrlmry.navy.mil/tcdat/tc05/ATL/12L.KATRINA/ir/geo/1km/
AGENDA
3
DEEP LEARNING ANALOGIES
What is this deep learning thing, anyway?
4
A NEW WAY TO BUILD SOFTWARE
Traditional Programming vs Machine Learning
5
A DIFFERENT WAY TO BUILD SOFTWARE
Traditional Programming vs Machine Learning
SOFTWARE 2.0:
Machine Learning
6
A DIFFERENT WAY TO BUILD SOFTWARE
Hand written vs leanred functions.
Function1(T,P,Q) Function1(T,P,Q)
return y return y
FUNCTION 5
7
A DIFFERENT WAY TO BUILD SOFTWARE
The two approaches are complimentary
MANUAL
MACHINE LEARNING
PROGRAMMING
“SOFTWARE 2.0”
“SOFTWARE 1.0”
REVERSE-ENGINEERED
ENGINEERED
AUTOMATIC
LABOR INTENSIVE
IMPLICIT
EXPLICIT
SUBTLE
EXPLAINABLE
COMPLEX
SIMPLE
FROM EXAMPLES
FROM EXPERTISE
8
A DIFFERENT WAY TO BUILD SOFTWARE
Complex phenomena are best described implicitly.
EXAMPLE: ATMOSPHERIC
-3- RIVER
9
A GENERALIZATION OF CURVE FITTING
Curve fitting provides the starting intution
y=f(x)
x
10
A GENERALIZATION OF CURVE FITTING
Differences from traditional curve fitting
𝒙1 𝒚𝟏 0 1
𝒙2 𝒚𝟐
0 1
𝒙 𝒚
𝒙3 𝒚𝟑
𝒇(𝒙) 0 1
𝒙4 𝒚𝟒
0 1
Deep 𝒙6
Millions of parameters
𝒚𝟔 0 1
Learning
11
EXAMPLES
12
RECOGNITION/CLASSIFICATION -> FILTER
De-noising gravitational waves
14
CONVERGED HPC
REVOLUTIONIZING DRUG DISCOVERY
Background
It takes 14 years and $2.5 Billon to develop 1 drug
Higher than 99.5% failure rate after the drug discovery phase
Challenge
QC simulation is computationally expensive - it takes 5 years to
compute on CPUs
So researchers use approximations, compromising on accuracy.
To screen 10M drug candidates,.
Solution
Researchers at the University of Florida and the University of
North Carolina leveraged GPU deep learning to develop a custom
framework ANAKIN-ME, to reproduce molecular energy surfaces
with super speed (microseconds versus several minutes),
extremely high (DFT) accuracy, and at up to 6 orders of
magnitude improvement in speed.
Impact
Speed and accuracy could start a revolution in computational
chemistry — and forever change the way we discover the
medicines of the future
15
EXAMPLE APPLICATIONS
2018: LUNAR CRATER IDENTIFICATION VIA DEEP LEARNING
https://arxiv.org/pdf/1803.02192.pdf
https://phys.org/news/2018-03-technique-ai-craters-moon.html
16
IMPLEMENTATION BASICS
17
AUTO-ML
Eventually, the optimizer might be able to do everything for you
18
WHAT YOU NEED TO MAKE DEEP LEARNING WORK
You need three main ingredients (and some skill)
KERAS + TENSFORFLOW
19
DEEP LEARNING FRAMEWORKS
Many frameworks to choose from (but not for Fortran)
20
DEVELOPMENT ENVIRONMENT
JUPYTER NOTEBOOKS
21
NVIDIA GPU CLOUD REGISTRY
CONTAINERIZED SOFTWARE
Singularity
DEEP HPC HPC
LEARNING APPS VISUALIZATION
22
LINEAR REGRESSION
With Scikit Learn
23
LINEAR REGRESSION
With Tensorflow and Keras
24
TRAINING
25
TRAINING VS INFERENCE
INFERENCE PHASE
TRAINING PHASE
ONLINE
LEARNING
26
TRAINING: THE PLAYERS
DATA, MODEL, LOSS, AND OPTIMIZER
OPTIMIZER
LOSS FCN
DATA
MODEL
27
TRAINING: GRADIENT DESCENT
Finding as solution is as easy as falling down a hill
Start with
random weights
Compute the gradient
and follow it downhill
Stop when
the error is small
28
OPTIMIZERS
Many variations on stochastic gradient descent
29
TRAINING: BACKPROPAGATION
Compute the gradient, by efficiently assigning blame
Error
Prediction
AUTOGRAD
AUTOGRAD
Let a framework keep track of your gradient, so you don’t have to
31
23
AI, MACHINE LEARNING, DEEP LEARNING
EXPERT SYSTEMS
EXPERT SYSTEMS
EXECUTE HAND-WRITTEN ALGORITHMS AT HIGH SPEED
EXECUTE HAND-WRITTEN ALGORITHMS AT HIGH SPEED
TRADITIONAL ML
LEARN FROM EXAMPLES USING HAND-CRAFTED
FEATURES
32
DEEP LEARNING VS. MACHINE LEARNING
When should I use deep learning vs traditional machine learning?
33
ARTIFICIAL NEURONS
Simple equations with adjustable parameters
w1 w2 w3
x1 x2 x3
https://towardsdatascience.com/the-differences-between-artificial-and-biological-neural-networks-a8b46db828b7
CURVE FIT WITH SINGLE LAYER NEURAL NETWORK
35
DATA SPLITTING
KEEP TEST, TRAINING, AND VALIDATION DATA SEPERATE
Data
36
MODEL CAPACITY
AND REGULARIZATION
37
MODEL CAPACITY
A good model is one that generalizes to new data
38
GOOD-FIT
Checking for Generalization
OVER-FITTING
Captures training data, but generalizes poorly
42
CHALLENGES AND
POTENTIAL SOLUTIONS
43
LABELLING LARGE QUANTITIES OF DATA
How can we overcome the need for manual labelling?
44
TRANSFER LEARNING: DON’T START FROM SCRATCH
45
ENFORCING PHYSICAL CONSTRAINTS
Conservation of Mass, Momentum, Energy, Incompressibility, Lagrange multipliers (penalization), Hard Constraints,
Turbulent Energy Spectra, Translational Invariance Projective Methods, Differentiable Programming
46
INTERPRETABILITY: EXPLAINABLE AI
https://lrpserver.hhi.fraunhofer.de/image-classification
47
USING YOUR GPU
48
GPUS MAKE MACHINE LEARNING PRACTICAL
Train in a day, or a month?
PILLARS OF DATA SCIENCE PERFORMANCE
PYTHON
6x RAPIDS DL
NVLink FRAMEWORKS
DASK
cuDF cuML cuGraph
NVSwitch cuDNN
CUDA-X
Massively Parallel Processing High Speed Connecting between NVIDIA GPU Acceleration Libraries
GPUs for Distributed Algorithms for Data Science and AI
50
LEARNED FUNCTIONS ARE GPU ACCELERATED
Next level software. No porting required.
51
HOW CAN I GET ACCESS TO A POWERFUL GPU?
Many way to take advantage of NVIDIA GPUs for Deep Learning
52
VERIFYING YOUR GPU
Keras
TensorFlow
PyTorch
Julia
53
Keras
Automatically uses GPU if available
Julia
TRAINING ON
A SINGLE GPU
PyTorch
54
NVIDIA-SMI
System Management Interface
Memory Processor
Utilizaiton Utilization
Process
Info
55
LEVELS OF AI ENGAGEMENT
LEVEL 1 LEVEL 2 LEVEL 3 LEVEL 4 LEVEL 5
AI in a supporting AI and main AI takes over parts AI replaces The system is
role, but production system of the main significant parts designed with AI
decoupled from influence each production system of the main in mind from the
main production other but are system, classical start; classical
system largely stand-alone parts play algorithms
supporting role generate training
data
Data
Analytics
Numerical
Simulation
Signal Processing
Visualization
…
56
COMPUTATIONAL
SCIENCES Create
Inputs Mathematical
Outputs
Model, First Principles
Create
57
CAN THIS WORK ∀? ABOLUTELY, YES!
Proof: Universal Approximation Theorem
𝛼∗
𝛽∗
• Anecdotal Evidence: ∃ scientific cases where NNs seem to do work extremely well
• Currently I think it is fair to say we don’t understand this domain very well
• But: Each individual case promising 10x, 100x,1000x performance
improvement is probably worth exploring; those can be groundbreaking!
59
WHAT MAKES
AI * HPC SPECIAL? Create
Inputs Mathematical
Outputs
Model
Create
60
WHAT MAKES
AI * HPC SPECIAL? Create
Inputs Mathematical
Outputs
Model
Training Labels
Outputs
Inputs Efficient Implementation
Backpropagation
61
HOW TO FILL IN THE ?
Experience, Intuition, and Art Guided Design New Approaches
timestep
Tridiagonal solve
Advection Step
+ Tools Support
Halo Exchange
Pressure Projection
1) Hidden Fluid Mechanics: A Navier-Stokes Informed Deep Learning Framework, M. Raissi et al.
2) Neural Ordinary Differential Equations, R.T.Q. Chen et al. 62
IS A ML MODEL USEFUL FOR SCIENCE?
63
6 STEPS APPROACH