Unit Ii
Unit Ii
Keras
UNIT-II
Ker
as
• A python package (Python 2.7-3.6)
• Sits on top of TensorFlow or Theano (Stopped)
• High-level neural network API
• Runs seamlessly on CPU and GPU
• Open source with user manual (https://keras.io/)
• Less coding lines required to build/run a model
TensorFl
ow
• Inherit from Theano (data flow graph)
• A python(3.5-3.7) package/C++ library
• Running on CPU or NVIDIA CUDA GPU
• End-2-End platform for machine/deep learning
• Multi platform (desktop, web by TF.js, mobile by TF
Lite)
• Open source with user manual
(https://www.tensorflow.org/)
• Expect to have
answer 3
Installation
Confirmed
• Keras requires backend setting for Windows users:
• https://keras.io/backend/
• Setting in keras.json:
“backend”: “tensorflow”
• Keras test code:
import keras
• Expect to see
Using TensorFlow backend
Keras
Models
• Two main types of models available
• The Sequential model (easy to learn, high-level API)
• A linear stack of layers
• Need to specify what input shape it should expect (input dimension)
• https://keras.io/getting-started/sequential-model-guide/
• The Model class used with the functional API (similar to tensorflow2.0)
• https://keras.io/models/about-keras-models/
• https://keras.io/getting-started/functional-api-guide/
Keras Sequential
Model
• Define a sequential model • Training
• model = Sequential() model = model.fit(data, one_hot_labels,
mode.add(Dense(32, input_dim=784)) epoch=10, batch_size=32)
model.add(Activation(‘relu’)) • Predition
model.add(Dense(10)) Y = model.predict(X)
• model.add(Activation(‘softmax’))
• Compilation
• model.compile(optimizer=‘rmsprop’,
• loss=‘binary_crossentropy’,
metrics=[‘accuray’])
Keras: Layers
Input:
input_img = Input(shape=(rows , cols , channels))
Dense:
x = Dense(num_of_units , activation=‘activation_function’)
Conv2D:
x = Conv2D(num_of_filters, kernel_size , stride,
activation=‘activation_function’,padding=‘type_of_padding’)
MaxPool2D:
x = MaxPool2D(kernel_size)
Flatten:
Dropout:
x = Dropout(value_of_dropout)
11
Keras: Optimizers
SGD
RMSProp
AdaGrad
Adam
…
12
Keras: Activation Functions
Sigmoid
Tanh
Relu
LeakyRelu
ELU
Softmax
…
13
Keras: Cost Functions
Mean Squared Error (‘mse’)
…
14
Keras: Defining the architecture
There are two ways to define the architecture:
15
Keras: Defining the architecture
There are two ways to define the architecture:
16
Exercises:
Exercise 1:
Define the network architecture following the LeNet-5 model.
Exercise 2:
Evaluate the network performance in terms of accuracy in relation to the
change of:
1. Learning rate: 0.1 and 0.001.
2. Activation functions: ReLU and Sigmoid.
3. Dropout values: 0.25, 0.5 and 0.75
17
Layer
s
• linea
r
• sigmoi
d
• tan
h
• rel
u
• PReLU
• Leaky
ReLU
• SReLU
• L1 weight
penalty
• L2 weight
penalty
https://github.com/vdumoulin/
conv_arithmetic
https://github.com/vdumoulin/
conv_arithmetic
border_mode = ‘valid’
no strides: subsample=
(1,1)
https://github.com/vdumoulin/
conv_arithmetic
border_mode =
‘same’ no strides:
subsample= (1,1)
https://github.com/vdumoulin/
conv_arithmetic
border_mode =
‘valid’ 2x2 strides:
subsample= (2,2)
https://github.com/vdumoulin/
conv_arithmetic
border_mode = ‘same’
2x2 strides: subsample=
(2,2)
Initializatio
ns
RMSPro
Adam
• Solving a problem with deep learning often follows a pipeline that includes feature engineering,
model selection, training by tuning hyperparameters, and validation.
• Autotuning is an active research area that involves automated search techniques to find
an optimal solution.
• A few popular autotuning algorithms are Grid Search, Random Search, Bayesian
Optimization, and Gradient-based Optimization.
https://keras.io/keras_tuner/
• Grid search of the hyperparameter space is a popular method which is simple to implement and
parallelize, and provides insight into the search space.
• Ongoing research suggests that automated random search optimization is a more efficient alternative
that often yields as good or better models than manual methods due to their ability to search larger
configuration spaces.
where,
Conta
ct In Great Britain:
Sky Blue Microsystems Zerif Technologies Ltd.
GmbH Winnington House, 2 Woodberry
Geisenhausenerstr. 18 Grove
81379 Munich, Germany Finchley, London N12 0DR
+49 89 780 2970, +44 115 855 7883,
[email protected] [email protected] www.zerif.co.uk
www.skyblue.de
2
https://www.youtube.com/watch?v=MY7jZGZw9vA
ANALYTICS INFERENCE
CLUSTER CLUSTER https://www.youtube.com/watch?v=ZevjEbu8N3E
G
r
6 172 a
p
X
X h
216 E
Sequences/s d
g
e
58 s
TOPS /
8x DGX
CPU DGX s
V100 A100 CPU Server DGX
FP32 TF32 Cluster A100
A100
Training Analytic
NLP: BERT- s
Large Inference
PageRan
BERT Pre-Training Throughput using PyTorch including Peak Compute
(2/3)Phase 1 and (1/3)Phase 2 | Phase 1 Seq Len = 128, k
13
CPU Server: 2x Intel Platinum 8280 using INT8 3000x CPU Servers vs. 4x DGX A100
Phase 2 Seq Len = 512 V100: DGX-1 with 8x V100 using DGX A100: DGX A100 with 8x A100 using INT8 with Published Common Crawl Data Set: 128B Edges,
FP32 precision Structural Sparsity 2.6TB Graph
DGX A100: DGX A100 with 8x A100 using TF32 precision
N. Shawki: On Automating Hyperparameter Optimization for Deep Learning Applications 7 73
NEW
FEATURES
8
DGX A100: NEW A100 GPUS AND
2X FASTER NVSWITCH
5 PetaFLOPS AI Performance
4x
A100s
DL
Training
2x A100s
Data
Analytics
Instance Instance
8 14
TRT TRT TRT TRT TRTT TRT TRT
bandwidth
Self-Encrypted Drives
(SED) to protect data at
rest
GPU
Board
CPU Secure
Boar of
Update
Firmware
d
BM
C
1
N. Shawki: On Automating Hyperparameter Optimization for Deep Learning Applications 2 78
INTRODUCING: NVIDIA DGXpert
With Every DGX system - Your Trusted Navigator in AI
Transformation
7
9
14,000+
AI-Fluent
Experts
DESIGN| PLAN | BUILD | TEST | DEPLOY | OPERATE| MONITOR
With you every step of the way - Included with every DGX
system
N. Shawki: On Automating Hyperparameter Optimization for Deep Learning Applications 79
DGX: DELIVERING AI FOR
BUSINESS
Backed by 1000’s of Data Scientists, Engineers &
SATURNV
Plan AI Deploy Optimize
• System Sizing
MAGLE
• HPL System testing • DLI for Workflow
new features
Lifecycle Data
• Network Design
Ingestion •Analytics
Data
Cluster Tools Setup • App Code Reviews
Management
• Secure AI Guidance • System Runbook • Technology Upgrades
Services Management
V
MAGLE DL Data
SW with HPC SW Data
Data Analytics
Workflow
SW
Optimized TF32Ingestion Optimized with Managementwith RAPIDS
Analytics
Software
8
0
Highest
Performance
Systems
4 PB of high-performance storage
N. Shawki: On Automating Hyperparameter Optimization for Deep Learning Applications 700 PFLOPS of power to train the previously 81
MORE THAN A SERVER
– NVIDIA’S
COMMITMENT TO
DELIVERING AI
SUCCESS
Backed by a Global Team of DGXperts
14,000+ of “AI-fluent” practitioners with a
decade
FPO of experience
1
N. Shawki: On Automating Hyperparameter Optimization for Deep Learning Applications 7 83
Contac
t In Great Britain:
Sky Blue Microsystems Zerif Technologies Ltd.
GmbH Winnington House, 2 Woodberry
Geisenhausenerstr. 18 Grove
81379 Munich, Germany Finchley, London N12 0DR
+49 89 780 2970, +44 115 855 7883,
[email protected] [email protected] www.zerif.co.uk
www.skyblue.de
2