SlideShare a Scribd company logo
TensorFlow & Keras
Deep Learning Framework
Overview: TensorFlow
What is TensorFlow?
• URL: https://www.tensorflow.org/
• Released under the open source license on
November 9, 2015
• Current version 1.2
• Open source software library for numerical
computation using data flow graphs
• Originally developed by Google Brain Team to
conduct machine learning and deep neural
networks research
• General enough to be applicable in a wide
variety of other domains as well
• TensorFlow provides an extensive suite of
functions and classes that allow users to build
various models from scratch.
Most popular on Github
https://github.com/tensorflow/tensorflow
TensorFlow architecture
• Core in C++
• Low overhead
• Different front ends for specifying/driving the computation
• Python, C++, R and many more
CPU - GPU
• In TensorFlow, the
supported device types
are CPU and GPU. They are
represented as strings. For
example:
• "/cpu:0": The CPU of your
machine.
• "/gpu:0": The GPU of
your machine, if you have one.
• "/gpu:1": The second
GPU of your machine, etc.
What is a Tensor?
Why it is called TensorFlow?
● TensorFlow is based on computation
data flow graph
● TensorFlow separates definition of
computations from their execution
TensorFlow Graph
Learn Parameters: Optimization
● The Optimizer base class provides
methods to compute gradients for a loss
and apply gradients to variables.
● A collection of subclasses implement
classic optimization algorithms such as
GradientDescent and Adagrad.
● TensorFlow provides functions to
compute the derivatives for a given
TensorFlow computation graph, adding
operations to the graph.
Learn Parameters: Optimization
TensorBoard
• Visualize your TensorFlow
graph
• Plot quantitative metrics about
the execution of your graph
• Show additional data like
images that pass through it
TensorFlow Models
https://github.com/tensorflow/models
Models
• adversarial_crypto: protecting communications with adversarial neural cryptography.
• adversarial_text: semi-supervised sequence learning with adversarial training.
• attention_ocr: a model for real-world image text extraction.
• autoencoder: various autoencoders.
• cognitive_mapping_and_planning: implementation of a spatial memory based mapping and planning
architecture for visual navigation.
• compression: compressing and decompressing images using a pre-trained Residual GRU network.
• differential_privacy: privacy-preserving student models from multiple teachers.
• domain_adaptation: domain separation networks.
• im2txt: image-to-text neural network for image captioning.
• inception: deep convolutional networks for computer vision.
TensorFlow Serving
•Flexible, high-performance
serving system for machine
learning models, designed for
production environments.
•Easy to deploy new algorithms
and experiments, while
keeping the same server
architecture and APIs
Code snippet
import tensorflow as tf
# build a linear model where y = w * x + b
w = tf.Variable([0.2], tf.float32, name='weight')
b = tf.Variable([0.3], tf.float32, name='bias')
X = tf.placeholder(tf.float32, name="X")
Y = tf.placeholder(tf.float32, name='Y')
# the training values for x and y
x = ([2.,3.,4.,5.])
y = ([-1.,-2.,-3.,-4.])
# define the linear model
linear_model = w*X+b
# define the loss function
square_delta = tf.square(linear_model - Y)
loss = tf.reduce_sum(square_delta)
#set the learning rate and training epoch
learning_rate = 0.01
training_epoch = 1000
# optimizer
optimizer = tf.train.GradientDescentOptimizer(learning_rate)
train = optimizer.minimize(loss)
# start a session
init = tf.global_variables_initializer()
with tf.Session() as sess:
sess.run(init)
for i in range(training_epoch):
sess.run(train, feed_dict={X:x,Y:y})
# evaluate training accuracy
curr_w, curr_b, curr_loss = sess.run([w, b, loss], {X:x,Y:y})
print('w: %f b: %f loss: %f '%(curr_w, curr_b, curr_loss))
TensorFlow: Installation
• pip3 install tensorflow
or
• Anaconda: conda install -c conda-forge tensorflow
Overview: Keras
Keras
•https://keras.io/
•Minimalist, highly modular neural
networks library
•Written in Python
•Capable of running on top of either
TensorFlow/Theano and CNTK
•Developed with a focus on enabling
fast experimentation
Guiding Principles
•Modularity
• A model is understood as a sequence or a graph of standalone,
fully-configurable modules that can be plugged together with as little
restrictions as possible
•Minimalism
• Each module should be kept short and simple
•Easy extensibility
• New modules can be easily added and extended
•Python
• Supports Python
General Design
•General idea is to based on layers and their input/output
• Prepare your inputs and output tensors
• Create first layer to handle input tensor
• Create output layer to handle targets
• Build virtually any model you like in between
Layers
•Keras has a number of pre-built layers. Notable examples include:
• Regular dense, MLP type
keras.layers.core.Dense(units, activation=None, use_bias=True,
kernel_initializer='glorot_uniform', bias_initializer='zeros',
kernel_regularizer=None, bias_regularizer=None,
activity_regularizer=None, kernel_constraint=None, bias_constraint=None)
• Recurrent layers, LTSM, GRU, etc
keras.layers.recurrent.Recurrent(return_sequences=False,
return_state=False, go_backwards=False, stateful=False, unroll=False,
implementation=0)
Layers
• 1D Convolutional layers
keras.layers.convolutional.Conv1D(filters, kernel_size, strides=1, padding='valid',
dilation_rate=1, activation=None, use_bias=True, kernel_initializer='glorot_uniform',
bias_initializer='zeros', kernel_regularizer=None, bias_regularizer=None,
activity_regularizer=None, kernel_constraint=None, bias_constraint=None)
• 2D Convolutional layers
keras.layers.convolutional.Conv2D(filters, kernel_size, strides=(1, 1), padding='valid',
data_format=None, dilation_rate=(1, 1), activation=None, use_bias=True,
kernel_initializer='glorot_uniform', bias_initializer='zeros', kernel_regularizer=None,
bias_regularizer=None, activity_regularizer=None, kernel_constraint=None,
bias_constraint=None)
Why use Keras?
•Easy and fast prototyping (through total modularity, minimalism, and
extensibility).
•Supports both convolutional networks and recurrent networks and
combinations of the two.
•Supports arbitrary connectivity schemes (including multi-input and
multi-output training).
•Runs seamlessly on CPU and GPU.
Keras Code examples
•The core data structure of Keras is a model
•Model → a way to organize layers
Model
Sequential Graph
Code-snippet
import numpy as np
from keras.models import Sequential
from keras.layers.core import Activation, Dense
from keras.optimizers import SGD
X = np.array([[0,0],[0,1],[1,0],[1,1]])
y = np.array([[0],[1],[1],[0]])
model = Sequential()
model.add(Dense(2, input_dim=2, activation='sigmoid'))
model.add(Dense(1, activation='sigmoid'))
sgd = SGD(lr=0.1, decay=1e-6, momentum=0.9, nesterov=True)
model.compile(loss='mean_squared_error', optimizer=sgd)
history = model.fit(X, y, nb_epoch=10000, batch_size=4)
Keras: Installation
• Theano :
• pip3 install Theano
• CNTK
• $ export CNTK_BINARY_URL=... [choose link here]
• pip3 install $CNTK_BINARY_URL
• TensorFlow :
• $ export TF_BINARY_URL=... [choose link here]
• pip3 install $TF_BINARY_URL
• Keras :
• pip3 install keras
• To enable GPU computing :
• NVidia Cuda
• CuDNN
• CNMeM
Demo
Slides & Codes available from Github:
https://github.com/kuanhoong/Magic_DeepLearning

More Related Content

What's hot (20)

PPTX
What is TensorFlow? | Introduction to TensorFlow | TensorFlow Tutorial For Be...
Simplilearn
 
PDF
Introduction to TensorFlow
Matthias Feys
 
PDF
Tensorflow presentation
Ahmed rebai
 
PDF
Introduction to TensorFlow 2.0
Databricks
 
PPTX
TensorFlow Tutorial | Deep Learning With TensorFlow | TensorFlow Tutorial For...
Simplilearn
 
PDF
Deep Learning - Convolutional Neural Networks
Christian Perone
 
PPTX
Deep Learning, Keras, and TensorFlow
Oswald Campesato
 
PDF
Keras Tutorial For Beginners | Creating Deep Learning Models Using Keras In P...
Edureka!
 
PPTX
Deep Learning Tutorial | Deep Learning TensorFlow | Deep Learning With Neural...
Simplilearn
 
PDF
Machine Intelligence at Google Scale: TensorFlow
DataWorks Summit/Hadoop Summit
 
PPTX
Introduction to Deep learning
leopauly
 
PPTX
Deep Learning Workflows: Training and Inference
NVIDIA
 
PDF
Transformer Introduction (Seminar Material)
Yuta Niki
 
PDF
Generative adversarial networks
남주 김
 
PDF
Deep learning - A Visual Introduction
Lukas Masuch
 
PDF
An introduction to the Transformers architecture and BERT
Suman Debnath
 
PPTX
Introduction to Transformer Model
Nuwan Sriyantha Bandara
 
PPTX
Convolutional neural network from VGG to DenseNet
SungminYou
 
PPTX
Pytorch
ehsan tr
 
What is TensorFlow? | Introduction to TensorFlow | TensorFlow Tutorial For Be...
Simplilearn
 
Introduction to TensorFlow
Matthias Feys
 
Tensorflow presentation
Ahmed rebai
 
Introduction to TensorFlow 2.0
Databricks
 
TensorFlow Tutorial | Deep Learning With TensorFlow | TensorFlow Tutorial For...
Simplilearn
 
Deep Learning - Convolutional Neural Networks
Christian Perone
 
Deep Learning, Keras, and TensorFlow
Oswald Campesato
 
Keras Tutorial For Beginners | Creating Deep Learning Models Using Keras In P...
Edureka!
 
Deep Learning Tutorial | Deep Learning TensorFlow | Deep Learning With Neural...
Simplilearn
 
Machine Intelligence at Google Scale: TensorFlow
DataWorks Summit/Hadoop Summit
 
Introduction to Deep learning
leopauly
 
Deep Learning Workflows: Training and Inference
NVIDIA
 
Transformer Introduction (Seminar Material)
Yuta Niki
 
Generative adversarial networks
남주 김
 
Deep learning - A Visual Introduction
Lukas Masuch
 
An introduction to the Transformers architecture and BERT
Suman Debnath
 
Introduction to Transformer Model
Nuwan Sriyantha Bandara
 
Convolutional neural network from VGG to DenseNet
SungminYou
 
Pytorch
ehsan tr
 

Similar to TensorFlow and Keras: An Overview (20)

PPTX
Demystifying-AI-Frameworks-TensorFlow-PyTorch-JAX-and-More (1).pptx
Anant Garg
 
PDF
The Flow of TensorFlow
Jeongkyu Shin
 
PDF
TensorFlow meetup: Keras - Pytorch - TensorFlow.js
Stijn Decubber
 
PPTX
python_libraries_for_artificial_intelligence.pptx
salehaalsaleh602
 
PPTX
Machine Learning Toolssssssssssssss.pptx
salehaalsaleh602
 
PDF
Lecture 4: Deep Learning Frameworks
Mohamed Loey
 
PPTX
Deep learning with keras
MOHITKUMAR1379
 
PDF
Neural Networks from Scratch - TensorFlow 101
Gerold Bausch
 
PPTX
slide-keras-tf.pptx
RithikRaj25
 
PDF
1645 goldenberg using our laptop
Rising Media, Inc.
 
PDF
OpenPOWER Workshop in Silicon Valley
Ganesan Narayanasamy
 
PDF
Tensor flow 2.0 what's new
Poo Kuan Hoong
 
PDF
A Tale of Three Deep Learning Frameworks: TensorFlow, Keras, & PyTorch with B...
Databricks
 
PDF
Keras and TensorFlow
NopphawanTamkuan
 
PPTX
Neural Networks with Google TensorFlow
Darshan Patel
 
PDF
Tensorflow 2.0 and Coral Edge TPU
Andrés Leonardo Martinez Ortiz
 
DOCX
DLT UNIT-3.docx
0567Padma
 
PDF
A Tour of Tensorflow's APIs
Dean Wyatte
 
PPTX
H2 o berkeleydltf
Oswald Campesato
 
Demystifying-AI-Frameworks-TensorFlow-PyTorch-JAX-and-More (1).pptx
Anant Garg
 
The Flow of TensorFlow
Jeongkyu Shin
 
TensorFlow meetup: Keras - Pytorch - TensorFlow.js
Stijn Decubber
 
python_libraries_for_artificial_intelligence.pptx
salehaalsaleh602
 
Machine Learning Toolssssssssssssss.pptx
salehaalsaleh602
 
Lecture 4: Deep Learning Frameworks
Mohamed Loey
 
Deep learning with keras
MOHITKUMAR1379
 
Neural Networks from Scratch - TensorFlow 101
Gerold Bausch
 
slide-keras-tf.pptx
RithikRaj25
 
1645 goldenberg using our laptop
Rising Media, Inc.
 
OpenPOWER Workshop in Silicon Valley
Ganesan Narayanasamy
 
Tensor flow 2.0 what's new
Poo Kuan Hoong
 
A Tale of Three Deep Learning Frameworks: TensorFlow, Keras, & PyTorch with B...
Databricks
 
Keras and TensorFlow
NopphawanTamkuan
 
Neural Networks with Google TensorFlow
Darshan Patel
 
Tensorflow 2.0 and Coral Edge TPU
Andrés Leonardo Martinez Ortiz
 
DLT UNIT-3.docx
0567Padma
 
A Tour of Tensorflow's APIs
Dean Wyatte
 
H2 o berkeleydltf
Oswald Campesato
 
Ad

More from Poo Kuan Hoong (20)

PDF
Build an efficient Machine Learning model with LightGBM
Poo Kuan Hoong
 
PDF
The future outlook and the path to be Data Scientist
Poo Kuan Hoong
 
PDF
Data Driven Organization and Data Commercialization
Poo Kuan Hoong
 
PDF
Explore and Have Fun with TensorFlow: Transfer Learning
Poo Kuan Hoong
 
PDF
Deep Learning with R
Poo Kuan Hoong
 
PDF
Explore and have fun with TensorFlow: An introductory to TensorFlow
Poo Kuan Hoong
 
PDF
The path to be a Data Scientist
Poo Kuan Hoong
 
PPTX
Deep Learning with Microsoft R Open
Poo Kuan Hoong
 
PPTX
Microsoft APAC Machine Learning & Data Science Community Bootcamp
Poo Kuan Hoong
 
PDF
Customer Churn Analytics using Microsoft R Open
Poo Kuan Hoong
 
PDF
Machine Learning and Deep Learning with R
Poo Kuan Hoong
 
PDF
The path to be a data scientist
Poo Kuan Hoong
 
PDF
MDEC Data Matters Series: machine learning and Deep Learning, A Primer
Poo Kuan Hoong
 
PDF
Big Data Malaysia - A Primer on Deep Learning
Poo Kuan Hoong
 
PDF
Handwritten Recognition using Deep Learning with R
Poo Kuan Hoong
 
PDF
An Introduction to Deep Learning
Poo Kuan Hoong
 
PDF
Machine learning and big data
Poo Kuan Hoong
 
PDF
DSRLab seminar Introduction to deep learning
Poo Kuan Hoong
 
PDF
Context Aware Road Traffic Speech Information System from Social Media
Poo Kuan Hoong
 
PDF
Virtual Interaction Using Myo And Google Cardboard (slides)
Poo Kuan Hoong
 
Build an efficient Machine Learning model with LightGBM
Poo Kuan Hoong
 
The future outlook and the path to be Data Scientist
Poo Kuan Hoong
 
Data Driven Organization and Data Commercialization
Poo Kuan Hoong
 
Explore and Have Fun with TensorFlow: Transfer Learning
Poo Kuan Hoong
 
Deep Learning with R
Poo Kuan Hoong
 
Explore and have fun with TensorFlow: An introductory to TensorFlow
Poo Kuan Hoong
 
The path to be a Data Scientist
Poo Kuan Hoong
 
Deep Learning with Microsoft R Open
Poo Kuan Hoong
 
Microsoft APAC Machine Learning & Data Science Community Bootcamp
Poo Kuan Hoong
 
Customer Churn Analytics using Microsoft R Open
Poo Kuan Hoong
 
Machine Learning and Deep Learning with R
Poo Kuan Hoong
 
The path to be a data scientist
Poo Kuan Hoong
 
MDEC Data Matters Series: machine learning and Deep Learning, A Primer
Poo Kuan Hoong
 
Big Data Malaysia - A Primer on Deep Learning
Poo Kuan Hoong
 
Handwritten Recognition using Deep Learning with R
Poo Kuan Hoong
 
An Introduction to Deep Learning
Poo Kuan Hoong
 
Machine learning and big data
Poo Kuan Hoong
 
DSRLab seminar Introduction to deep learning
Poo Kuan Hoong
 
Context Aware Road Traffic Speech Information System from Social Media
Poo Kuan Hoong
 
Virtual Interaction Using Myo And Google Cardboard (slides)
Poo Kuan Hoong
 
Ad

Recently uploaded (20)

PDF
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
PPTX
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
PDF
NLJUG Speaker academy 2025 - first session
Bert Jan Schrijver
 
PDF
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
PPTX
Agentforce World Tour Toronto '25 - Supercharge MuleSoft Development with Mod...
Alexandra N. Martinez
 
PPTX
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
PPTX
MuleSoft MCP Support (Model Context Protocol) and Use Case Demo
shyamraj55
 
PDF
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
PDF
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
PPTX
Agentforce World Tour Toronto '25 - MCP with MuleSoft
Alexandra N. Martinez
 
PPTX
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 
PDF
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
PPTX
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
PPTX
Seamless Tech Experiences Showcasing Cross-Platform App Design.pptx
presentifyai
 
PDF
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
PDF
Future-Proof or Fall Behind? 10 Tech Trends You Can’t Afford to Ignore in 2025
DIGITALCONFEX
 
DOCX
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
PDF
Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
PPTX
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
 
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
NLJUG Speaker academy 2025 - first session
Bert Jan Schrijver
 
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
Agentforce World Tour Toronto '25 - Supercharge MuleSoft Development with Mod...
Alexandra N. Martinez
 
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
MuleSoft MCP Support (Model Context Protocol) and Use Case Demo
shyamraj55
 
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
Agentforce World Tour Toronto '25 - MCP with MuleSoft
Alexandra N. Martinez
 
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
Seamless Tech Experiences Showcasing Cross-Platform App Design.pptx
presentifyai
 
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
Future-Proof or Fall Behind? 10 Tech Trends You Can’t Afford to Ignore in 2025
DIGITALCONFEX
 
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
 

TensorFlow and Keras: An Overview

  • 4. What is TensorFlow? • URL: https://www.tensorflow.org/ • Released under the open source license on November 9, 2015 • Current version 1.2 • Open source software library for numerical computation using data flow graphs • Originally developed by Google Brain Team to conduct machine learning and deep neural networks research • General enough to be applicable in a wide variety of other domains as well • TensorFlow provides an extensive suite of functions and classes that allow users to build various models from scratch.
  • 5. Most popular on Github https://github.com/tensorflow/tensorflow
  • 6. TensorFlow architecture • Core in C++ • Low overhead • Different front ends for specifying/driving the computation • Python, C++, R and many more
  • 7. CPU - GPU • In TensorFlow, the supported device types are CPU and GPU. They are represented as strings. For example: • "/cpu:0": The CPU of your machine. • "/gpu:0": The GPU of your machine, if you have one. • "/gpu:1": The second GPU of your machine, etc.
  • 8. What is a Tensor?
  • 9. Why it is called TensorFlow? ● TensorFlow is based on computation data flow graph ● TensorFlow separates definition of computations from their execution
  • 11. Learn Parameters: Optimization ● The Optimizer base class provides methods to compute gradients for a loss and apply gradients to variables. ● A collection of subclasses implement classic optimization algorithms such as GradientDescent and Adagrad. ● TensorFlow provides functions to compute the derivatives for a given TensorFlow computation graph, adding operations to the graph.
  • 13. TensorBoard • Visualize your TensorFlow graph • Plot quantitative metrics about the execution of your graph • Show additional data like images that pass through it
  • 14. TensorFlow Models https://github.com/tensorflow/models Models • adversarial_crypto: protecting communications with adversarial neural cryptography. • adversarial_text: semi-supervised sequence learning with adversarial training. • attention_ocr: a model for real-world image text extraction. • autoencoder: various autoencoders. • cognitive_mapping_and_planning: implementation of a spatial memory based mapping and planning architecture for visual navigation. • compression: compressing and decompressing images using a pre-trained Residual GRU network. • differential_privacy: privacy-preserving student models from multiple teachers. • domain_adaptation: domain separation networks. • im2txt: image-to-text neural network for image captioning. • inception: deep convolutional networks for computer vision.
  • 15. TensorFlow Serving •Flexible, high-performance serving system for machine learning models, designed for production environments. •Easy to deploy new algorithms and experiments, while keeping the same server architecture and APIs
  • 16. Code snippet import tensorflow as tf # build a linear model where y = w * x + b w = tf.Variable([0.2], tf.float32, name='weight') b = tf.Variable([0.3], tf.float32, name='bias') X = tf.placeholder(tf.float32, name="X") Y = tf.placeholder(tf.float32, name='Y') # the training values for x and y x = ([2.,3.,4.,5.]) y = ([-1.,-2.,-3.,-4.]) # define the linear model linear_model = w*X+b # define the loss function square_delta = tf.square(linear_model - Y) loss = tf.reduce_sum(square_delta) #set the learning rate and training epoch learning_rate = 0.01 training_epoch = 1000 # optimizer optimizer = tf.train.GradientDescentOptimizer(learning_rate) train = optimizer.minimize(loss) # start a session init = tf.global_variables_initializer() with tf.Session() as sess: sess.run(init) for i in range(training_epoch): sess.run(train, feed_dict={X:x,Y:y}) # evaluate training accuracy curr_w, curr_b, curr_loss = sess.run([w, b, loss], {X:x,Y:y}) print('w: %f b: %f loss: %f '%(curr_w, curr_b, curr_loss))
  • 17. TensorFlow: Installation • pip3 install tensorflow or • Anaconda: conda install -c conda-forge tensorflow
  • 19. Keras •https://keras.io/ •Minimalist, highly modular neural networks library •Written in Python •Capable of running on top of either TensorFlow/Theano and CNTK •Developed with a focus on enabling fast experimentation
  • 20. Guiding Principles •Modularity • A model is understood as a sequence or a graph of standalone, fully-configurable modules that can be plugged together with as little restrictions as possible •Minimalism • Each module should be kept short and simple •Easy extensibility • New modules can be easily added and extended •Python • Supports Python
  • 21. General Design •General idea is to based on layers and their input/output • Prepare your inputs and output tensors • Create first layer to handle input tensor • Create output layer to handle targets • Build virtually any model you like in between
  • 22. Layers •Keras has a number of pre-built layers. Notable examples include: • Regular dense, MLP type keras.layers.core.Dense(units, activation=None, use_bias=True, kernel_initializer='glorot_uniform', bias_initializer='zeros', kernel_regularizer=None, bias_regularizer=None, activity_regularizer=None, kernel_constraint=None, bias_constraint=None) • Recurrent layers, LTSM, GRU, etc keras.layers.recurrent.Recurrent(return_sequences=False, return_state=False, go_backwards=False, stateful=False, unroll=False, implementation=0)
  • 23. Layers • 1D Convolutional layers keras.layers.convolutional.Conv1D(filters, kernel_size, strides=1, padding='valid', dilation_rate=1, activation=None, use_bias=True, kernel_initializer='glorot_uniform', bias_initializer='zeros', kernel_regularizer=None, bias_regularizer=None, activity_regularizer=None, kernel_constraint=None, bias_constraint=None) • 2D Convolutional layers keras.layers.convolutional.Conv2D(filters, kernel_size, strides=(1, 1), padding='valid', data_format=None, dilation_rate=(1, 1), activation=None, use_bias=True, kernel_initializer='glorot_uniform', bias_initializer='zeros', kernel_regularizer=None, bias_regularizer=None, activity_regularizer=None, kernel_constraint=None, bias_constraint=None)
  • 24. Why use Keras? •Easy and fast prototyping (through total modularity, minimalism, and extensibility). •Supports both convolutional networks and recurrent networks and combinations of the two. •Supports arbitrary connectivity schemes (including multi-input and multi-output training). •Runs seamlessly on CPU and GPU.
  • 25. Keras Code examples •The core data structure of Keras is a model •Model → a way to organize layers Model Sequential Graph
  • 26. Code-snippet import numpy as np from keras.models import Sequential from keras.layers.core import Activation, Dense from keras.optimizers import SGD X = np.array([[0,0],[0,1],[1,0],[1,1]]) y = np.array([[0],[1],[1],[0]]) model = Sequential() model.add(Dense(2, input_dim=2, activation='sigmoid')) model.add(Dense(1, activation='sigmoid')) sgd = SGD(lr=0.1, decay=1e-6, momentum=0.9, nesterov=True) model.compile(loss='mean_squared_error', optimizer=sgd) history = model.fit(X, y, nb_epoch=10000, batch_size=4)
  • 27. Keras: Installation • Theano : • pip3 install Theano • CNTK • $ export CNTK_BINARY_URL=... [choose link here] • pip3 install $CNTK_BINARY_URL • TensorFlow : • $ export TF_BINARY_URL=... [choose link here] • pip3 install $TF_BINARY_URL • Keras : • pip3 install keras • To enable GPU computing : • NVidia Cuda • CuDNN • CNMeM
  • 28. Demo Slides & Codes available from Github: https://github.com/kuanhoong/Magic_DeepLearning