** AI & Deep Learning Training: https://www.edureka.co/ai-deep-learning-with-tensorflow ** )
This Edureka Tutorial on "Keras Tutorial" (Deep Learning Blog Series: https://goo.gl/4zxMfU) provides you a quick and insightful tutorial on the working of Keras along with an interesting use-case! We will be checking out the following topics:
Agenda:
What is Keras?
Who makes Keras?
Who uses Keras?
What Makes Keras special?
Working principle of Keras
Keras Models
Understanding Execution
Implementing a Neural Network
Use-Case with Keras
Coding in Colaboratory
Session in a minute
Check out our Deep Learning blog series: https://bit.ly/2xVIMe1
Check out our complete Youtube playlist here: https://bit.ly/2OhZEpz
Follow us to never miss an update in the future.
Instagram: https://www.instagram.com/edureka_learning/
Facebook: https://www.facebook.com/edurekaIN/
Twitter: https://twitter.com/edurekain
LinkedIn: https://www.linkedin.com/company/edureka
Advantages of Hiring UIUX Design Service Providers for Your Business
Keras Tutorial For Beginners | Creating Deep Learning Models Using Keras In Python | Edureka
1. AI & Deep Learning Training www.edureka.co/ai-deep-learning-with-tensorflow
2. AI & Deep Learning Training www.edureka.co/ai-deep-learning-with-tensorflow
Agenda
What is Keras?
Contributors for Keras
Keras Models
Implementing a Neural Network
Use-Case
Summary
4. AI & Deep Learning Training www.edureka.co/ai-deep-learning-with-tensorflow
What Is Keras?
Keras - Modular
• Building models is as simple
as stacking layers and
connecting graphs.
Open Source
• Actively developed by contributors across
the world!
• Good amount of documentation
Deep Learning Library
• High-level Neural Network API
• Runs on top of TensorFlow,
Theano or CNTK.
High Performance
• High performing API used to
specify and train differentiable
programs.
6. AI & Deep Learning Training www.edureka.co/ai-deep-learning-with-tensorflow
Who Makes Keras?
4800+ Contributors
250,000
Keras developers
> 2x
Year-on-year growth
Start-ups
Good amount of traction
10. AI & Deep Learning Training www.edureka.co/ai-deep-learning-with-tensorflow
What Makes Keras Special?
Large adoption in the industry
Multi-backend, multi-platform
Focus on user experience
Research community4
Easy to grasp all concepts5
Fast prototyping6
Runs seamlessly on CPU and GPU7
Freedom to design any architecture8
Simple to get started9
Easy production of models10
11. AI & Deep Learning Training www.edureka.co/ai-deep-learning-with-tensorflow
Keras User Experience
API Designed for Humans
• Keras follows best practices for
reducing cognitive load
• Offers consistent and simple APIs
Not Designed for Machines
• Minimizes number of user actions required
for common use cases
• Provides clear feedback upon user error
Easy to Learn & Easy to Use
• More productive
• Try more ideas than your competition
• Helps you win competitions
High Flexibility
• Keras integrates with lower-level
Deep Learning languages like
TensorFlow
• Implement anything which was
built in base language.
1
3
2
4
12. AI & Deep Learning Training www.edureka.co/ai-deep-learning-with-tensorflow
Multi-Backend & Multi-Platform
01 02 03
Development
Develop in Python, R
Run the code with:
• TensorFlow
• CNTK
• Theano
• MXNet
• CPU
• NVIDIA GPU
• AMD GPU
• TPU
• Etc..
Producing Models
• TF-Serving
• GPU acceleration
(WebKeras, Keras.js)
• Android (TF, TF Lite)
• iOS (Native CoreML)
• Raspberry Pi
{code}
Run The Code
14. AI & Deep Learning Training www.edureka.co/ai-deep-learning-with-tensorflow
Working Principle – Backend
• e = c*d where, “c = a+b” and “d = b+1”
• So, e = (a+b)*(b+1)
• Here “a” ,“b” are inputs
01
02
03
04
Expressing complex expressions as a
combination of simple operations
Useful for calculating derivatives
during backpropagation
Easier to implement distributed
computation
Just specify the inputs, outputs and
make sure the graph is connected
Computational Graphs
As easy as that!
16. AI & Deep Learning Training www.edureka.co/ai-deep-learning-with-tensorflow
Keras Models
Sequential Model
• Linear stack of layers
• Useful for building simple models
• Simple classification network
• Encoder – Decoder models
• The model we all know and love!
• Treat each layer as object that feeds into the next.
17. AI & Deep Learning Training www.edureka.co/ai-deep-learning-with-tensorflow
Keras Models
Functional Model
• Like playing with Lego bricks
• Good for 95% of use cases
Multi-input, multi-output and arbitrary static graph
topologies
Multi – input and Multi – output models
Complex models which forks into 2 or more
branches
Models with shared (Weights) layers
01
02
03
04
18. AI & Deep Learning Training www.edureka.co/ai-deep-learning-with-tensorflow
Keras Models
Functional Model (Domain Adaption)
• Train on Domain A and Test on Domain B
• Results in poor performance on test set
• The data are from different domains
We will be looking at a very interesting use case
using the functional model in the upcoming slides
Solution: Adapt the model to both the domains
20. AI & Deep Learning Training www.edureka.co/ai-deep-learning-with-tensorflow
Execution – Two Types
Deferred (symbolic)
• We use Python to build a
computation graph first
• The compiled graph then
gets executed later
Eager ( imperative)
• Here, the Python runtime
is the execution runtime
• It is similar to execution
with Numpy
• Symbolic tensors don’t have a value in the Python code (yet)
• Eager tensors have a value in the Python code
• With eager execution, value-dependent dynamic topologies
(tree-RNNs) can be used.
On the whole
22. AI & Deep Learning Training www.edureka.co/ai-deep-learning-with-tensorflow
Implementing A Neural Network
1. Prepare Input
• Preparing the input and
specify the input dimension
(size)
• Images, videos, text and audio
2. Define the ANN Model
• Define the model architecture and
build the computational graph
• Sequential or Functional Style
• MLP, CNN, RNN 3. Optimizers
• Specify the optimizer and configure
the learning process
• SGD, RMSprop, Adam
5. Train and Evaluate Model
• Train the model based on the
training data
• Test the model on the dataset
with the testing data
4. Loss Function
• Specify the Inputs, Outputs of the
computational graph (model) and
the Loss function
• MSE, Cross Entropy, Hinge
24. AI & Deep Learning Training www.edureka.co/ai-deep-learning-with-tensorflow
Use Case – Problem Statement
“Predicting the price of wine with the Keras Functional API and TensorFlow”
Building a wide and deep network using Keras (tf.Keras)
to predict the price of wine from its description
Predict the price of a bottle of wine
just from its description and variety?
• This problem is well suited for wide & deep learning
• It involves text input and there isn’t any correlation
between a wine’s description and its price
25. AI & Deep Learning Training www.edureka.co/ai-deep-learning-with-tensorflow
Use Case – Model
A good use-case for the Functional API is implementing a
wide and deep network in Keras!
A lot of Keras models are built using the Sequential model API
BUT Let’s try to solve our use-case with the Functional API
The Sequential API is the best way to get started with Keras
Because it lets you easily define models as a stack of layers
The Functional API allows for more flexibility and is best
suited for models with multiple inputs or combined models
Wide models are models with
sparse feature vectors or
vectors with mostly zero values
Multi-layer deep networks
do well on tasks like image
or speech recognition
26. AI & Deep Learning Training www.edureka.co/ai-deep-learning-with-tensorflow
Use Case – Dataset
DATASET
Country1
2 Description
3 Designation
4 Points
5 Price
6 Region_1
Region_27
8 Taster Name
9
Taster Twitter
Handle
10 Title
Variety11
Winery12
The overall goal is to create a model that
can identify the variety, winery and
location of a wine based on a description
This dataset offers some great
opportunities for sentiment analysis
and other text related predictive models
27. AI & Deep Learning Training www.edureka.co/ai-deep-learning-with-tensorflow
Use Case – Sample
Description:
• Powerful vanilla scents rise from the glass, but the fruit, even in this difficult vintage, comes out
immediately.
• It’s tart and sharp, with a strong herbal component, and the wine snaps into focus quickly with fruit, acid,
tannin, herb and vanilla in equal proportion.
• Firm and tight, still quite young, this wine needs decanting and/or further bottle age to show its best.
Variety: Pinot Noir
Prediction:
Price — $45
28. AI & Deep Learning Training www.edureka.co/ai-deep-learning-with-tensorflow
Use Case – Prerequisites
29. AI & Deep Learning Training www.edureka.co/ai-deep-learning-with-tensorflow
Use Case – Prerequisites
Here are all the imports we’ll need to build this model!
Test presence of TensorFlow by printing the version
Download the data and convert it to a Pandas Data Frame
30. AI & Deep Learning Training www.edureka.co/ai-deep-learning-with-tensorflow
Use Case – Let’s See Code!
Google Colaboratory
31. AI & Deep Learning Training www.edureka.co/ai-deep-learning-with-tensorflow
Session In A Minute
What is Keras? Contributors Specialty of Keras
Implementing a Neural Network Use-Case ImplementationKeras Models