SlideShare une entreprise Scribd logo
1  sur  70
TUTORIAL ON KERAS
STUDENT NAME : MAHMUT KAMALAK
LECTURE : INTRODUCTION TO PYTHON
PROFESSOR : PROF. DR. BAHADIR AKTUĞ
ID NUMBER :16290155
OBJECTIVE OF THE TUTORIAL
I decided to prepare a tutorial about Keras , because I am
interested in Deep Learning for months ,and I am working on a
project which is about ECG arythmia classification. In my
opinion; before start to learn Keras, there are some pre-requires
that are deep learning theory, basic python knowledge, basic
linear algebra ,basic statisctics and probabilty. I strongly advice;
after supply pre-requires , new learners should go deep projects
and articles.These days, Deep Learning is so popular by
researchers and companies in many field because of the
capability of artifial intelligence. Especially I would like to say
deep learning will take amazing responsibility of diognastic and
imaging on medical ındustry. From my view , Deep Learning has
a deep way but, there are huge magical things.
OVERVIEW OF THE TUTORIAL
A. Introduction
B. Installation
C. Backend Configuration
D. Overview of Deep Learning
E. Deep Learning with Keras
F. Modules
G. Layers
H. Model Compilation
I. Convolution Neural Network
J. LSTM – RNN
K. Applications
A.INTRODUCTION
What is Keras ?
• Keras is a deep learning libriary for Python.
• Keras is a so effective to build deep learning model and
training the models.
• This libriary makes less time-consuming to do practice for
researchers.
• It is capable of running on top of TensorFlow.
• It was developed as part of the research effort of project
ONEIROS (Open-ended Neuro-Electronic Intelligent Robot
Operating System), and its primary author and maintainer is
François Chollet, a Google engineer.
A.INTRODUCTION
WHY USE KERAS ?
• Keras allows to run the code without any change on both CPU
and GPU.
• High-level neural networks API.
• Useful for fast prototyping, ignoring the details of implenting
backprop or writing optimization procedure.
• Provides to work Convolution , Recurrent layer and combination
of both.
• Most of architecture is designed by using this framework.
• Keras and Python gives a amazing power to developer as
A.INTRODUCTION
• Keras is usually used for small datasets as it is comparitively
slower. On the other hand, TensorFlow and PyTorch are used
for high performance models and large datasets that require
fast execution.
• We can differentiate Keras like that Keras tops the list
followed by TensorFlow.Keras gained amazing popularity due
to its simplicity.
A.INTRODUCTION
• In the world ,
250,000
Keras Developers
B.INSTALLATION
1) PREREQUISITES
You must satisfy the following requirements:
• Any kind of OS (Windows, Linux or Mac)
• Python version 3.5 or higher.
• Keras is python based neural network library so python must be
installed on your machine. If python is properly installed on
your machine, then open your terminal and type python, you
can check as specified below :
B.INSTALLATION
Step 1: Create virtual environment
• Virtualenv is used to manage Python packages for different
projects. This will be helpful to avoid breaking the packages
installed in the other environments. So, it is always recommended
to use a virtual environment while developing Python
applications.
• Linux or mac OS users, go to your project root directory and type
the below command to create virtual environment :
« python3 -m venv kerasenv «
• Windows user can use the below command :
« py -m venv keras »
B.INSTALLATION
Step 2: Activate the environment
This step will configure python and pip executables in your shell
path.
Linux/Mac OS
• Now we have created a virtual environment named “kerasvenv”.
Move to the folder and type the below command,
«$ cd kerasvenv
kerasvenv $ source bin/activate «
Windows users move inside the “kerasenv” folder and type the
below command:
«.envScriptsactivate «
B.INSTALLATION
Step 3: Python libraries
Keras depends on the following python libraries : Numpy , Pandas
, Scikit-learn , Matplotlib , Scipy , Seaborn.
When you installed the keras, u have already installed these
libriaries on your computer.But If there is a problem about any
libriary , we can install these one by one . As below structure
which is on command window :
« pip install ‘name of libriary’ «
B.INSTALLATION
• Example for Step-3 : If you have already installed , you will get
:
If you havent done before, you will get :
B.INSTALLATION
Step 4 : Keras Installation Using Python
As of now, we have completed basic requirements for the
installtion of Keras. Now, install the Keras using same procedure
on the command as specified below:
« pip install keras «
*** Quit virtual environment ***
After finishing all your changes in your project, then simply run
the below command to quit the environment:
« deactivate »
C.BACKEND CONFIGURATION
• This step explains Keras backend implementations TensorFlow
and Theano .
TensorFlow
TensorFlow is an open source machine learning library used for
numerical computational tasks developed by Google. Keras is a
high level API built on top of TensorFlow or Theano. We know
already how to install TensorFlow using pip.
« pip install theano «
Theano
Theano is an open source deep learning library that allows you to
evaluate multi-dimensional arrays effectively. We can easily install
D. OVERVIEW OF DEEP LEARNING
• We can define like that Deep Learning is consisting of layers
which are follows each other to get useful features.
• Deep learning is sub-branch of machine learning.
• ‘Deep’ means that it does not mean that get deeeeeep magicful
knowledge.This word means that multi-layers and amount of
layers point out the depth of a model.
• Modern deep learning algortithms have thousunds layers.
• This layered notation is called ‘ Neural Networks ‘ which is
inspired neurobiology but , we can say that this model
process does not exactly match with neuro-science even some
articles show opposite idea.
D. OVERVIEW OF
DEEP LEARNING
In deep learning, a computer
model learns to perform
classification tasks directly from
images, text, or sound. Deep
learning models can achieve
state-of-the-art accuracy,
sometimes exceeding human-
level performance. Models are
trained by using a large set of
labeled data and neural network
architectures that contain many
layers..On the right side , you
can see the single perception of
deep learning.
D. OVERVIEW OF
DEEP LEARNING
Multi-Layer perceptron is the
simplest form of ANN. It consists
of a single input layer, one or
more hidden layer and finally an
output layer. A layer consists of
a collection of perceptron. Input
layer is basically one or more
features of the input data. Every
hidden layer consists of one or
more neurons and process
certain aspect of the feature and
send the processed information
into the next hidden layer. The
output layer process receives the
data from last hidden layer and
D. OVERVIEW OF DEEP LEARNING
General pipeline for implementing an ANN (Artifical NEURAL
NETWORKS):
We can simply define the procedure like that ;
• DECIDE WHICH DEEP LEARNING ARCITECHTURE YOU NEED (CNN ?
,RNN ? ) !!!
• Firstly we need labeled data ( as much as big data).And do not worry
about how your code understand which part of data is necessary for
your train., Keras handle it.
• After defining how we need input and output data shape.( datas
should be seperated as x_train, y_train , x_test , y_train).
• Train and test datas should be different each other.
• Design a architecture model to catch maximum accurucy.(Do not
forget our goal is reaching max accurucy without overfitting)
• Choose the correct optimizers ,actication function ,loss function.
E. DEEP LEARNING WITH KERAS
Implementing a neural network in Keras :
• Preparing the input and specify the input dimension (size)
• •Define the model architecture and build the computational
graph
• •Specify the optimizer and configure the learning process
• •Specify the Inputs, Outputs of the computational graph
(model) and the Loss function
• Train and test the model on the dataset
E. DEEP LEARNING WITH KERAS
• In Keras, every ANN is represented by Keras Models. In turn, every
Keras Model is composition of Keras Layers and represents ANN layers
like input, hidden layer, output layers, convolution layer, pooling layer,
etc., Keras model and layer access Keras modules for activation
function, loss function, regularization function, etc., Using Keras
model, Keras Layer, and Keras modules, any ANN algorithm (CNN, RNN,
etc.,) can be represented in a simple and efficient manner. The
following diagram depicts the relationship between model, layer and
core modules:
F. MODULE
Keras modules cosist of classes, functions and variables.These are pre-defined,The modules make simpler
to build model.
List of Modules :
• Initializers
• Constrains
• Activations
• Utilities
• Backend:
• Sequence processing
• Image processing
• Text processing
• Optimizers
• Callback
• Metrics
• Losses
G.LAYERS
• As I pointed out , Keras layers are the essentials for the Keras
models. Each layer takes input what previous layer provide as
output, and this circle keeps on the untill last layer.
• A layer needs to know shape of the input to get structue of the
input data.
• Layers also needs to know number of neurons , initializers,
regularizers, constraints and activation function.
G.LAYERS
Let us create a simple Keras layer using Sequential model API to get the
idea of how Keras model ;
EXAMPLE - 1 :
NOTE : Google Colaboratory is
used to execute.Google gives
us free Cpu and Gpu.
G.LAYERS
Example 1 :
G.LAYERS
Activations
• The activation function makes input data non linear , and model
learn better.
• The output of a perceptron (neuron) is simply the result of the
activation function, which accepts the summation of all input
multiplied with its corresponding weight plus overall bias. (result
= Activation(SUMOF(input * weight) + bias)
• Activation Function in the keras module = linear , elu , selu , relu
, softmax , softplus , softsign , tanh , sigmoid , hard_sigmoid ,
exponential .
G.LAYERS
Dense Layer
• Dense layer does the below operation on the input and return the
output.
• output = activation(dot(input, kernel) + bias)
EXAMPLE 2- Lets find a result with using input and kernel :
Let us consider sample input and weights as below and try to find
the result:
• input as 2 x 2 matrix [ [1, 2], [3, 4] ]
• kernel as 2 x 2 matrix [ [0.5, 0.75], [0.25, 0.5] ]
• bias value as 0
G.LAYERS
• Example 2 –Solution =
G.LAYERS
Dropout Layers
Dropout layer is used generally in most of models, to prevent
overfitting.Dropout layer deletes a noise which node has . We can
simply define that when we train the model, yes we want to teach
to model essential things to predict correctly. But ıf models
memorize the labeled input data ,the model works on only what
model see before. The model should work on not even see before
test data. Memorizing and overfitting are similar things.
G.LAYERS
• Dropout has three arguments and they are as follows:
« keras.layers.Dropout(rate, noise_shape=None, seed=None) «
rate represent the fraction of the input unit to be dropped. It will
be from 0 to 1.
• noise_shape represent the dimension of the shape in which the
dropout to be applied. For example, the input shape is
(batch_size, timesteps, features). Then, to apply dropout in the
timesteps, (batch_size, 1, features) need to be specified as
noise_shape
• seed - random seed.
G.LAYERS
Flatten Layers
• Flatten layers also are used to get results together on the one
row or one column .Most of time have been on before last layer.
• For example, if flatten is applied to layer having input shape as
(batch_size, 2,2), then the output shape of the layer will be
(batch_size, 4) .
• « keras.layers.Flatten(data_format=None) «
G.LAYERS
Flatten Layer
Example -3 :
H.MODEL COMPILATION
• Now, how to compile the model will be explained .
• The compilation is the final part of building a model.
Loss = Loss function is used to find error or deviation in the
learning process. Keras requires loss function during model
compilation process. Keras have pre-defined some loss
functions. We chooce one of these depends on our desire.
H.MODEL COMPILATION
Optimizer = Optimization is a vital , when training. This is for
optimizing the input weights by comparing the prediction and
loss function results.
For example ; Stochastic gradient descent optimizer , Adam
optimizer , Adamax optimizer ..
Metrics = Always we try to get better and better result. To do
this , we need to observe the performance of model.
Metrics is used to evaluate the performance , it is similar to loss
function, but not used in training process.
• For example ; accuracy , categorical_accuracy ..
H.MODEL COMPILATION
• Keras model provides a method, compile() to compile the
model.
• The argument and default value of the compile() method is as
follows:
« compile(optimizer, loss=None, metrics=None,
loss_weights=None, sample_weight_mode=None,
weighted_metrics=None, target_tensors=None) »
H.MODEL COMPILATION
Model Training
Models are trained by NumPy arrays using fit(). The main
purpose of this fit function is used to evaluate your model on
training. This can be also used for graphing model performance .
« model.fit(X, y, epochs=, batch_size=) »
• X, y - It is a tuple to evaluate your data.
• epochs - no of times the model is needed to be evaluated
during training.
• batch_size - training instances
H.MODEL COMPILATION
Lets see one example about model compilation ;
Example 4 :
H.MODEL COMPILATION
• Example 4 :
H.MODEL COMPILATION
Example 5 : Let us choose a simple multi-layer perceptron (MLP) as represented
below and try to create the model using Keras ;
The core features of the model are as follows:
• Input layer consists of 784 values (28 x 28 = 784).
• First hidden layer, Dense consists of 512 neurons and ‘relu’ activation function.
• Second hidden layer, Dropout has 0.2 as its value.
• Third hidden layer, again Dense consists of 512 neurons and ‘relu’ activation
function.
• Fourth hidden layer, Dropout has 0.2 as its value.
• Fifth and final layer consists of 10 neurons and ‘softmax’ activation function.
• Use categorical_crossentropy as loss function.
• Use RMSprop() as Optimizer
• Use accuracy as metrics.
• Use 128 as batch size.
H.MODEL COMPILATION
• Example 5 :
H.MODEL COMPILATION
• Example 5 :
H.MODEL COMPILATION
• Example 5 :
I. CONVOLUTIONAL NEURAL NETWORK
(CNN)
• The difference between CNN and ANN is that ANN is trained by
global image , but CNN learns partially for example; if there is
a image which is 10x10 , with cnn model learn 2 x2 , 2x2 ,
2x2.. Its similar to signal filtering.
• As you predict that there will be more details , and it causes
better accuracy.
• CNN is used most of time for images.
I. CONVOLUTIONAL NEURAL NETWORK
(CNN)
We will observe CNN with a example which is like ‘ hello world ‘ of
deep learning .
We will use mnist dataset that consists of 70,000 images
handwritten digits from 0 to 9 . Lets do the example to idetify them
using a CNN.
Example 6 : Mini-project idetify handwritten number
I. CONVOLUTIONAL NEURAL NETWORK
(CNN)
• Example 6 :
I. CONVOLUTIONAL NEURAL NETWORK
(CNN)
Example 6 :
I. CONVOLUTIONAL NEURAL NETWORK
(CNN)
Example 6 :
I. CONVOLUTIONAL NEURAL NETWORK
(CNN)
Example 6 :
I. CONVOLUTIONAL NEURAL NETWORK
(CNN)
Example 6 :
J. LSTM – RNN
• RNNs can use their internal state (memory) to process sequences of
inputs. This makes them applicable to tasks such as unsegmented,
connected handwriting recognition or speech recognition. In other
neural networks, all the inputs are independent of each other. But in
RNN, all the inputs are related to each other.
Advantages of Recurrent Neural Network
• RNN can model sequence of data so that each sample can be
assumed to be dependent on previous ones
• Recurrent neural network are even used with convolutional layers to
extend the effective pixel neighbourhood.
Disadvantages of Recurrent Neural Network
• Gradient vanishing and exploding problems.
• Training an RNN is a very difficult task.
• It cannot process very long sequences if using tanh or relu as an
activation function.
J. LSTM – RNN
• Long Short-Term Memory (LSTM) networks are a modified
version of recurrent neural networks, which makes it easier to
remember past data in memory.
• LSTM is well-suited to classify, process and predict time series
given time lags of unknown duration. It trains the model by
using back-propagation.
• Lets see this part with an example which is that while
predicting the actual price of a stock is an uphill climb, we can
build a model that will predict whether the price will go up or
down. The data and notebook used for this tutorial can be
found (https://github.com/mwitiderrick/stockprice). It’s
important to note that there are always other factors that affect
J. LSTM – RNN
Example 7 :
J. LSTM – RNN
Example 7 :
J. LSTM – RNN
Example 7 :
J. LSTM – RNN
Example 7 :
J. LSTM – RNN
Example 7 :
J. LSTM – RNN
Example 7 :
K.APPLICATIONS
As ı said before; more data , more accuracy. But if you have small
dataset for images . What will you do ?! There is a solution which
is Data Augmentation. That means that we play game with
images like ;symetry , rotation , zoom …
We need to just use ImageDataGenerator module. Lets see with
one example ...
Example -8 : We have 1 image and we want to much more
data.Here is our images that is by Ara Guler :
K.APPLICATIONS
• Example -8 :
K.APPLICATIONS
• Example- 8 :
And, augmented images were loaded in my drive , as below ;
K.APPLICATIONS
• Example-9 :
K.APPLICATIONS
Example-9 :
K.APPLICATIONS
Example-9 :
K.APPLICATIONS
Example- 10 : This time lets predict house prices ;
K.APPLICATIONS
Example 10 :
K.APPLICATIONS
Example 10 :
K.APPLICATIONS
Example 10 :
K.APPLICATIONS
Example 10 :
K.APPLICATIONS
Example 10 :
We got
loss graph.
CONCLUSION
To sum up , the tutorial shows us that there are so many
parameters to adjuct on your model, this skill will be gained by
project experience . We can think like that we are in labaratory ,
we are doing experiment as building our deep learning model. I
gained a experience also about learning and teaching when
preparing the tutorial.In addition , I saw my weakness on some
points which I will fix these as soon as possible. Finally, after
working on this tutorial with much more detail, I will upload on my
github account.
REFERENCES
• Deep Learning with Python-François Chollet-Manning
Publications Company, 2017
• Keras.io
• https://www.kdnuggets.com/
• https://www.mathworks.com/
• medium.com

Contenu connexe

Tendances

Introduction to TensorFlow 2.0
Introduction to TensorFlow 2.0Introduction to TensorFlow 2.0
Introduction to TensorFlow 2.0Databricks
 
Introduction to Neural Networks in Tensorflow
Introduction to Neural Networks in TensorflowIntroduction to Neural Networks in Tensorflow
Introduction to Neural Networks in TensorflowNicholas McClure
 
Image Classification using deep learning
Image Classification using deep learning Image Classification using deep learning
Image Classification using deep learning Asma-AH
 
An Introduction to Deep Learning
An Introduction to Deep LearningAn Introduction to Deep Learning
An Introduction to Deep LearningPoo Kuan Hoong
 
Introduction To TensorFlow
Introduction To TensorFlowIntroduction To TensorFlow
Introduction To TensorFlowSpotle.ai
 
Deep learning - A Visual Introduction
Deep learning - A Visual IntroductionDeep learning - A Visual Introduction
Deep learning - A Visual IntroductionLukas Masuch
 
Activation functions and Training Algorithms for Deep Neural network
Activation functions and Training Algorithms for Deep Neural networkActivation functions and Training Algorithms for Deep Neural network
Activation functions and Training Algorithms for Deep Neural networkGayatri Khanvilkar
 
Introduction to Deep Learning, Keras, and TensorFlow
Introduction to Deep Learning, Keras, and TensorFlowIntroduction to Deep Learning, Keras, and TensorFlow
Introduction to Deep Learning, Keras, and TensorFlowSri Ambati
 
Introduction to Deep learning
Introduction to Deep learningIntroduction to Deep learning
Introduction to Deep learningleopauly
 
Deep Learning - Convolutional Neural Networks
Deep Learning - Convolutional Neural NetworksDeep Learning - Convolutional Neural Networks
Deep Learning - Convolutional Neural NetworksChristian Perone
 
Deep Learning With Python Tutorial | Edureka
Deep Learning With Python Tutorial | EdurekaDeep Learning With Python Tutorial | Edureka
Deep Learning With Python Tutorial | EdurekaEdureka!
 
Deep Learning Explained
Deep Learning ExplainedDeep Learning Explained
Deep Learning ExplainedMelanie Swan
 
openCV with python
openCV with pythonopenCV with python
openCV with pythonWei-Wen Hsu
 
Image classification using CNN
Image classification using CNNImage classification using CNN
Image classification using CNNNoura Hussein
 
Tensorflow presentation
Tensorflow presentationTensorflow presentation
Tensorflow presentationAhmed rebai
 
Advance Java Topics (J2EE)
Advance Java Topics (J2EE)Advance Java Topics (J2EE)
Advance Java Topics (J2EE)slire
 

Tendances (20)

Introduction to TensorFlow 2.0
Introduction to TensorFlow 2.0Introduction to TensorFlow 2.0
Introduction to TensorFlow 2.0
 
Keras and TensorFlow
Keras and TensorFlowKeras and TensorFlow
Keras and TensorFlow
 
Introduction to Neural Networks in Tensorflow
Introduction to Neural Networks in TensorflowIntroduction to Neural Networks in Tensorflow
Introduction to Neural Networks in Tensorflow
 
Cassandra Database
Cassandra DatabaseCassandra Database
Cassandra Database
 
Image Classification using deep learning
Image Classification using deep learning Image Classification using deep learning
Image Classification using deep learning
 
Python OOPs
Python OOPsPython OOPs
Python OOPs
 
An Introduction to Deep Learning
An Introduction to Deep LearningAn Introduction to Deep Learning
An Introduction to Deep Learning
 
Introduction To TensorFlow
Introduction To TensorFlowIntroduction To TensorFlow
Introduction To TensorFlow
 
Deep learning - A Visual Introduction
Deep learning - A Visual IntroductionDeep learning - A Visual Introduction
Deep learning - A Visual Introduction
 
Activation functions and Training Algorithms for Deep Neural network
Activation functions and Training Algorithms for Deep Neural networkActivation functions and Training Algorithms for Deep Neural network
Activation functions and Training Algorithms for Deep Neural network
 
Introduction to Deep Learning, Keras, and TensorFlow
Introduction to Deep Learning, Keras, and TensorFlowIntroduction to Deep Learning, Keras, and TensorFlow
Introduction to Deep Learning, Keras, and TensorFlow
 
Introduction to Deep learning
Introduction to Deep learningIntroduction to Deep learning
Introduction to Deep learning
 
Deep Learning - Convolutional Neural Networks
Deep Learning - Convolutional Neural NetworksDeep Learning - Convolutional Neural Networks
Deep Learning - Convolutional Neural Networks
 
Java Basic Oops Concept
Java Basic Oops ConceptJava Basic Oops Concept
Java Basic Oops Concept
 
Deep Learning With Python Tutorial | Edureka
Deep Learning With Python Tutorial | EdurekaDeep Learning With Python Tutorial | Edureka
Deep Learning With Python Tutorial | Edureka
 
Deep Learning Explained
Deep Learning ExplainedDeep Learning Explained
Deep Learning Explained
 
openCV with python
openCV with pythonopenCV with python
openCV with python
 
Image classification using CNN
Image classification using CNNImage classification using CNN
Image classification using CNN
 
Tensorflow presentation
Tensorflow presentationTensorflow presentation
Tensorflow presentation
 
Advance Java Topics (J2EE)
Advance Java Topics (J2EE)Advance Java Topics (J2EE)
Advance Java Topics (J2EE)
 

Similaire à KERAS Python Tutorial

Final training course
Final training courseFinal training course
Final training courseNoor Dhiya
 
DeepLearning001&ApacheMXNetWithSparkForInference-ACNA2018
DeepLearning001&ApacheMXNetWithSparkForInference-ACNA2018DeepLearning001&ApacheMXNetWithSparkForInference-ACNA2018
DeepLearning001&ApacheMXNetWithSparkForInference-ACNA2018Apache MXNet
 
DLT UNIT-3.docx
DLT  UNIT-3.docxDLT  UNIT-3.docx
DLT UNIT-3.docx0567Padma
 
Training course lect1
Training course lect1Training course lect1
Training course lect1Noor Dhiya
 
A Deeper Dive into Apache MXNet - March 2017 AWS Online Tech Talks
A Deeper Dive into Apache MXNet - March 2017 AWS Online Tech TalksA Deeper Dive into Apache MXNet - March 2017 AWS Online Tech Talks
A Deeper Dive into Apache MXNet - March 2017 AWS Online Tech TalksAmazon Web Services
 
A Deeper Dive into Apache MXNet - March 2017 AWS Online Tech Talks
A Deeper Dive into Apache MXNet - March 2017 AWS Online Tech TalksA Deeper Dive into Apache MXNet - March 2017 AWS Online Tech Talks
A Deeper Dive into Apache MXNet - March 2017 AWS Online Tech TalksAmazon Web Services
 
TENSORFLOW: ARCHITECTURE AND USE CASE - NASA SPACE APPS CHALLENGE by Gema Par...
TENSORFLOW: ARCHITECTURE AND USE CASE - NASA SPACE APPS CHALLENGE by Gema Par...TENSORFLOW: ARCHITECTURE AND USE CASE - NASA SPACE APPS CHALLENGE by Gema Par...
TENSORFLOW: ARCHITECTURE AND USE CASE - NASA SPACE APPS CHALLENGE by Gema Par...Big Data Spain
 
Synthetic dialogue generation with Deep Learning
Synthetic dialogue generation with Deep LearningSynthetic dialogue generation with Deep Learning
Synthetic dialogue generation with Deep LearningS N
 
Transfer Learning (20230516)
Transfer Learning (20230516)Transfer Learning (20230516)
Transfer Learning (20230516)FEG
 
Keras: A versatile modeling layer for deep learning
Keras: A versatile modeling layer for deep learningKeras: A versatile modeling layer for deep learning
Keras: A versatile modeling layer for deep learningDr. Ananth Krishnamoorthy
 
Smart Data Conference: DL4J and DataVec
Smart Data Conference: DL4J and DataVecSmart Data Conference: DL4J and DataVec
Smart Data Conference: DL4J and DataVecJosh Patterson
 
Machine Learning with ML.NET and Azure - Andy Cross
Machine Learning with ML.NET and Azure - Andy CrossMachine Learning with ML.NET and Azure - Andy Cross
Machine Learning with ML.NET and Azure - Andy CrossAndrew Flatters
 
Deep Learning Made Easy with Deep Features
Deep Learning Made Easy with Deep FeaturesDeep Learning Made Easy with Deep Features
Deep Learning Made Easy with Deep FeaturesTuri, Inc.
 
Distributed Inference with MXNet and Spark
Distributed Inference with MXNet and SparkDistributed Inference with MXNet and Spark
Distributed Inference with MXNet and SparkApache MXNet
 
Distributed Inference on Large Datasets Using Apache MXNet and Apache Spark ...
 Distributed Inference on Large Datasets Using Apache MXNet and Apache Spark ... Distributed Inference on Large Datasets Using Apache MXNet and Apache Spark ...
Distributed Inference on Large Datasets Using Apache MXNet and Apache Spark ...Databricks
 
Build a simple image recognition system with tensor flow
Build a simple image recognition system with tensor flowBuild a simple image recognition system with tensor flow
Build a simple image recognition system with tensor flowDebasisMohanty37
 
Using Deep Learning on Apache Spark to Diagnose Thoracic Pathology from Chest...
Using Deep Learning on Apache Spark to Diagnose Thoracic Pathology from Chest...Using Deep Learning on Apache Spark to Diagnose Thoracic Pathology from Chest...
Using Deep Learning on Apache Spark to Diagnose Thoracic Pathology from Chest...Databricks
 

Similaire à KERAS Python Tutorial (20)

Final training course
Final training courseFinal training course
Final training course
 
DeepLearning001&ApacheMXNetWithSparkForInference-ACNA2018
DeepLearning001&ApacheMXNetWithSparkForInference-ACNA2018DeepLearning001&ApacheMXNetWithSparkForInference-ACNA2018
DeepLearning001&ApacheMXNetWithSparkForInference-ACNA2018
 
DLT UNIT-3.docx
DLT  UNIT-3.docxDLT  UNIT-3.docx
DLT UNIT-3.docx
 
Training course lect1
Training course lect1Training course lect1
Training course lect1
 
A Deeper Dive into Apache MXNet - March 2017 AWS Online Tech Talks
A Deeper Dive into Apache MXNet - March 2017 AWS Online Tech TalksA Deeper Dive into Apache MXNet - March 2017 AWS Online Tech Talks
A Deeper Dive into Apache MXNet - March 2017 AWS Online Tech Talks
 
A Deeper Dive into Apache MXNet - March 2017 AWS Online Tech Talks
A Deeper Dive into Apache MXNet - March 2017 AWS Online Tech TalksA Deeper Dive into Apache MXNet - March 2017 AWS Online Tech Talks
A Deeper Dive into Apache MXNet - March 2017 AWS Online Tech Talks
 
TENSORFLOW: ARCHITECTURE AND USE CASE - NASA SPACE APPS CHALLENGE by Gema Par...
TENSORFLOW: ARCHITECTURE AND USE CASE - NASA SPACE APPS CHALLENGE by Gema Par...TENSORFLOW: ARCHITECTURE AND USE CASE - NASA SPACE APPS CHALLENGE by Gema Par...
TENSORFLOW: ARCHITECTURE AND USE CASE - NASA SPACE APPS CHALLENGE by Gema Par...
 
Synthetic dialogue generation with Deep Learning
Synthetic dialogue generation with Deep LearningSynthetic dialogue generation with Deep Learning
Synthetic dialogue generation with Deep Learning
 
Transfer Learning (20230516)
Transfer Learning (20230516)Transfer Learning (20230516)
Transfer Learning (20230516)
 
Keras: A versatile modeling layer for deep learning
Keras: A versatile modeling layer for deep learningKeras: A versatile modeling layer for deep learning
Keras: A versatile modeling layer for deep learning
 
Amazon Deep Learning
Amazon Deep LearningAmazon Deep Learning
Amazon Deep Learning
 
Smart Data Conference: DL4J and DataVec
Smart Data Conference: DL4J and DataVecSmart Data Conference: DL4J and DataVec
Smart Data Conference: DL4J and DataVec
 
MXNet Workshop
MXNet WorkshopMXNet Workshop
MXNet Workshop
 
Machine Learning with ML.NET and Azure - Andy Cross
Machine Learning with ML.NET and Azure - Andy CrossMachine Learning with ML.NET and Azure - Andy Cross
Machine Learning with ML.NET and Azure - Andy Cross
 
Dl
DlDl
Dl
 
Deep Learning Made Easy with Deep Features
Deep Learning Made Easy with Deep FeaturesDeep Learning Made Easy with Deep Features
Deep Learning Made Easy with Deep Features
 
Distributed Inference with MXNet and Spark
Distributed Inference with MXNet and SparkDistributed Inference with MXNet and Spark
Distributed Inference with MXNet and Spark
 
Distributed Inference on Large Datasets Using Apache MXNet and Apache Spark ...
 Distributed Inference on Large Datasets Using Apache MXNet and Apache Spark ... Distributed Inference on Large Datasets Using Apache MXNet and Apache Spark ...
Distributed Inference on Large Datasets Using Apache MXNet and Apache Spark ...
 
Build a simple image recognition system with tensor flow
Build a simple image recognition system with tensor flowBuild a simple image recognition system with tensor flow
Build a simple image recognition system with tensor flow
 
Using Deep Learning on Apache Spark to Diagnose Thoracic Pathology from Chest...
Using Deep Learning on Apache Spark to Diagnose Thoracic Pathology from Chest...Using Deep Learning on Apache Spark to Diagnose Thoracic Pathology from Chest...
Using Deep Learning on Apache Spark to Diagnose Thoracic Pathology from Chest...
 

Dernier

Decoding the Heart: Student Presentation on Heart Attack Prediction with Data...
Decoding the Heart: Student Presentation on Heart Attack Prediction with Data...Decoding the Heart: Student Presentation on Heart Attack Prediction with Data...
Decoding the Heart: Student Presentation on Heart Attack Prediction with Data...Boston Institute of Analytics
 
Data Analysis Project : Targeting the Right Customers, Presentation on Bank M...
Data Analysis Project : Targeting the Right Customers, Presentation on Bank M...Data Analysis Project : Targeting the Right Customers, Presentation on Bank M...
Data Analysis Project : Targeting the Right Customers, Presentation on Bank M...Boston Institute of Analytics
 
Effects of Smartphone Addiction on the Academic Performances of Grades 9 to 1...
Effects of Smartphone Addiction on the Academic Performances of Grades 9 to 1...Effects of Smartphone Addiction on the Academic Performances of Grades 9 to 1...
Effects of Smartphone Addiction on the Academic Performances of Grades 9 to 1...limedy534
 
Predictive Analysis for Loan Default Presentation : Data Analysis Project PPT
Predictive Analysis for Loan Default  Presentation : Data Analysis Project PPTPredictive Analysis for Loan Default  Presentation : Data Analysis Project PPT
Predictive Analysis for Loan Default Presentation : Data Analysis Project PPTBoston Institute of Analytics
 
Statistics, Data Analysis, and Decision Modeling, 5th edition by James R. Eva...
Statistics, Data Analysis, and Decision Modeling, 5th edition by James R. Eva...Statistics, Data Analysis, and Decision Modeling, 5th edition by James R. Eva...
Statistics, Data Analysis, and Decision Modeling, 5th edition by James R. Eva...ssuserf63bd7
 
原版1:1定制南十字星大学毕业证(SCU毕业证)#文凭成绩单#真实留信学历认证永久存档
原版1:1定制南十字星大学毕业证(SCU毕业证)#文凭成绩单#真实留信学历认证永久存档原版1:1定制南十字星大学毕业证(SCU毕业证)#文凭成绩单#真实留信学历认证永久存档
原版1:1定制南十字星大学毕业证(SCU毕业证)#文凭成绩单#真实留信学历认证永久存档208367051
 
Consent & Privacy Signals on Google *Pixels* - MeasureCamp Amsterdam 2024
Consent & Privacy Signals on Google *Pixels* - MeasureCamp Amsterdam 2024Consent & Privacy Signals on Google *Pixels* - MeasureCamp Amsterdam 2024
Consent & Privacy Signals on Google *Pixels* - MeasureCamp Amsterdam 2024thyngster
 
Generative AI for Social Good at Open Data Science East 2024
Generative AI for Social Good at Open Data Science East 2024Generative AI for Social Good at Open Data Science East 2024
Generative AI for Social Good at Open Data Science East 2024Colleen Farrelly
 
毕业文凭制作#回国入职#diploma#degree澳洲中央昆士兰大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree
毕业文凭制作#回国入职#diploma#degree澳洲中央昆士兰大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree毕业文凭制作#回国入职#diploma#degree澳洲中央昆士兰大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree
毕业文凭制作#回国入职#diploma#degree澳洲中央昆士兰大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degreeyuu sss
 
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort servicejennyeacort
 
LLMs, LMMs, their Improvement Suggestions and the Path towards AGI
LLMs, LMMs, their Improvement Suggestions and the Path towards AGILLMs, LMMs, their Improvement Suggestions and the Path towards AGI
LLMs, LMMs, their Improvement Suggestions and the Path towards AGIThomas Poetter
 
Easter Eggs From Star Wars and in cars 1 and 2
Easter Eggs From Star Wars and in cars 1 and 2Easter Eggs From Star Wars and in cars 1 and 2
Easter Eggs From Star Wars and in cars 1 and 217djon017
 
Identifying Appropriate Test Statistics Involving Population Mean
Identifying Appropriate Test Statistics Involving Population MeanIdentifying Appropriate Test Statistics Involving Population Mean
Identifying Appropriate Test Statistics Involving Population MeanMYRABACSAFRA2
 
科罗拉多大学波尔得分校毕业证学位证成绩单-可办理
科罗拉多大学波尔得分校毕业证学位证成绩单-可办理科罗拉多大学波尔得分校毕业证学位证成绩单-可办理
科罗拉多大学波尔得分校毕业证学位证成绩单-可办理e4aez8ss
 
办美国阿肯色大学小石城分校毕业证成绩单pdf电子版制作修改#真实留信入库#永久存档#真实可查#diploma#degree
办美国阿肯色大学小石城分校毕业证成绩单pdf电子版制作修改#真实留信入库#永久存档#真实可查#diploma#degree办美国阿肯色大学小石城分校毕业证成绩单pdf电子版制作修改#真实留信入库#永久存档#真实可查#diploma#degree
办美国阿肯色大学小石城分校毕业证成绩单pdf电子版制作修改#真实留信入库#永久存档#真实可查#diploma#degreeyuu sss
 
GA4 Without Cookies [Measure Camp AMS]
GA4 Without Cookies [Measure Camp AMS]GA4 Without Cookies [Measure Camp AMS]
GA4 Without Cookies [Measure Camp AMS]📊 Markus Baersch
 
How we prevented account sharing with MFA
How we prevented account sharing with MFAHow we prevented account sharing with MFA
How we prevented account sharing with MFAAndrei Kaleshka
 
Semantic Shed - Squashing and Squeezing.pptx
Semantic Shed - Squashing and Squeezing.pptxSemantic Shed - Squashing and Squeezing.pptx
Semantic Shed - Squashing and Squeezing.pptxMike Bennett
 
Biometric Authentication: The Evolution, Applications, Benefits and Challenge...
Biometric Authentication: The Evolution, Applications, Benefits and Challenge...Biometric Authentication: The Evolution, Applications, Benefits and Challenge...
Biometric Authentication: The Evolution, Applications, Benefits and Challenge...GQ Research
 
April 2024 - NLIT Cloudera Real-Time LLM Streaming 2024
April 2024 - NLIT Cloudera Real-Time LLM Streaming 2024April 2024 - NLIT Cloudera Real-Time LLM Streaming 2024
April 2024 - NLIT Cloudera Real-Time LLM Streaming 2024Timothy Spann
 

Dernier (20)

Decoding the Heart: Student Presentation on Heart Attack Prediction with Data...
Decoding the Heart: Student Presentation on Heart Attack Prediction with Data...Decoding the Heart: Student Presentation on Heart Attack Prediction with Data...
Decoding the Heart: Student Presentation on Heart Attack Prediction with Data...
 
Data Analysis Project : Targeting the Right Customers, Presentation on Bank M...
Data Analysis Project : Targeting the Right Customers, Presentation on Bank M...Data Analysis Project : Targeting the Right Customers, Presentation on Bank M...
Data Analysis Project : Targeting the Right Customers, Presentation on Bank M...
 
Effects of Smartphone Addiction on the Academic Performances of Grades 9 to 1...
Effects of Smartphone Addiction on the Academic Performances of Grades 9 to 1...Effects of Smartphone Addiction on the Academic Performances of Grades 9 to 1...
Effects of Smartphone Addiction on the Academic Performances of Grades 9 to 1...
 
Predictive Analysis for Loan Default Presentation : Data Analysis Project PPT
Predictive Analysis for Loan Default  Presentation : Data Analysis Project PPTPredictive Analysis for Loan Default  Presentation : Data Analysis Project PPT
Predictive Analysis for Loan Default Presentation : Data Analysis Project PPT
 
Statistics, Data Analysis, and Decision Modeling, 5th edition by James R. Eva...
Statistics, Data Analysis, and Decision Modeling, 5th edition by James R. Eva...Statistics, Data Analysis, and Decision Modeling, 5th edition by James R. Eva...
Statistics, Data Analysis, and Decision Modeling, 5th edition by James R. Eva...
 
原版1:1定制南十字星大学毕业证(SCU毕业证)#文凭成绩单#真实留信学历认证永久存档
原版1:1定制南十字星大学毕业证(SCU毕业证)#文凭成绩单#真实留信学历认证永久存档原版1:1定制南十字星大学毕业证(SCU毕业证)#文凭成绩单#真实留信学历认证永久存档
原版1:1定制南十字星大学毕业证(SCU毕业证)#文凭成绩单#真实留信学历认证永久存档
 
Consent & Privacy Signals on Google *Pixels* - MeasureCamp Amsterdam 2024
Consent & Privacy Signals on Google *Pixels* - MeasureCamp Amsterdam 2024Consent & Privacy Signals on Google *Pixels* - MeasureCamp Amsterdam 2024
Consent & Privacy Signals on Google *Pixels* - MeasureCamp Amsterdam 2024
 
Generative AI for Social Good at Open Data Science East 2024
Generative AI for Social Good at Open Data Science East 2024Generative AI for Social Good at Open Data Science East 2024
Generative AI for Social Good at Open Data Science East 2024
 
毕业文凭制作#回国入职#diploma#degree澳洲中央昆士兰大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree
毕业文凭制作#回国入职#diploma#degree澳洲中央昆士兰大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree毕业文凭制作#回国入职#diploma#degree澳洲中央昆士兰大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree
毕业文凭制作#回国入职#diploma#degree澳洲中央昆士兰大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree
 
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service
 
LLMs, LMMs, their Improvement Suggestions and the Path towards AGI
LLMs, LMMs, their Improvement Suggestions and the Path towards AGILLMs, LMMs, their Improvement Suggestions and the Path towards AGI
LLMs, LMMs, their Improvement Suggestions and the Path towards AGI
 
Easter Eggs From Star Wars and in cars 1 and 2
Easter Eggs From Star Wars and in cars 1 and 2Easter Eggs From Star Wars and in cars 1 and 2
Easter Eggs From Star Wars and in cars 1 and 2
 
Identifying Appropriate Test Statistics Involving Population Mean
Identifying Appropriate Test Statistics Involving Population MeanIdentifying Appropriate Test Statistics Involving Population Mean
Identifying Appropriate Test Statistics Involving Population Mean
 
科罗拉多大学波尔得分校毕业证学位证成绩单-可办理
科罗拉多大学波尔得分校毕业证学位证成绩单-可办理科罗拉多大学波尔得分校毕业证学位证成绩单-可办理
科罗拉多大学波尔得分校毕业证学位证成绩单-可办理
 
办美国阿肯色大学小石城分校毕业证成绩单pdf电子版制作修改#真实留信入库#永久存档#真实可查#diploma#degree
办美国阿肯色大学小石城分校毕业证成绩单pdf电子版制作修改#真实留信入库#永久存档#真实可查#diploma#degree办美国阿肯色大学小石城分校毕业证成绩单pdf电子版制作修改#真实留信入库#永久存档#真实可查#diploma#degree
办美国阿肯色大学小石城分校毕业证成绩单pdf电子版制作修改#真实留信入库#永久存档#真实可查#diploma#degree
 
GA4 Without Cookies [Measure Camp AMS]
GA4 Without Cookies [Measure Camp AMS]GA4 Without Cookies [Measure Camp AMS]
GA4 Without Cookies [Measure Camp AMS]
 
How we prevented account sharing with MFA
How we prevented account sharing with MFAHow we prevented account sharing with MFA
How we prevented account sharing with MFA
 
Semantic Shed - Squashing and Squeezing.pptx
Semantic Shed - Squashing and Squeezing.pptxSemantic Shed - Squashing and Squeezing.pptx
Semantic Shed - Squashing and Squeezing.pptx
 
Biometric Authentication: The Evolution, Applications, Benefits and Challenge...
Biometric Authentication: The Evolution, Applications, Benefits and Challenge...Biometric Authentication: The Evolution, Applications, Benefits and Challenge...
Biometric Authentication: The Evolution, Applications, Benefits and Challenge...
 
April 2024 - NLIT Cloudera Real-Time LLM Streaming 2024
April 2024 - NLIT Cloudera Real-Time LLM Streaming 2024April 2024 - NLIT Cloudera Real-Time LLM Streaming 2024
April 2024 - NLIT Cloudera Real-Time LLM Streaming 2024
 

KERAS Python Tutorial

  • 1. TUTORIAL ON KERAS STUDENT NAME : MAHMUT KAMALAK LECTURE : INTRODUCTION TO PYTHON PROFESSOR : PROF. DR. BAHADIR AKTUĞ ID NUMBER :16290155
  • 2. OBJECTIVE OF THE TUTORIAL I decided to prepare a tutorial about Keras , because I am interested in Deep Learning for months ,and I am working on a project which is about ECG arythmia classification. In my opinion; before start to learn Keras, there are some pre-requires that are deep learning theory, basic python knowledge, basic linear algebra ,basic statisctics and probabilty. I strongly advice; after supply pre-requires , new learners should go deep projects and articles.These days, Deep Learning is so popular by researchers and companies in many field because of the capability of artifial intelligence. Especially I would like to say deep learning will take amazing responsibility of diognastic and imaging on medical ındustry. From my view , Deep Learning has a deep way but, there are huge magical things.
  • 3. OVERVIEW OF THE TUTORIAL A. Introduction B. Installation C. Backend Configuration D. Overview of Deep Learning E. Deep Learning with Keras F. Modules G. Layers H. Model Compilation I. Convolution Neural Network J. LSTM – RNN K. Applications
  • 4. A.INTRODUCTION What is Keras ? • Keras is a deep learning libriary for Python. • Keras is a so effective to build deep learning model and training the models. • This libriary makes less time-consuming to do practice for researchers. • It is capable of running on top of TensorFlow. • It was developed as part of the research effort of project ONEIROS (Open-ended Neuro-Electronic Intelligent Robot Operating System), and its primary author and maintainer is François Chollet, a Google engineer.
  • 5. A.INTRODUCTION WHY USE KERAS ? • Keras allows to run the code without any change on both CPU and GPU. • High-level neural networks API. • Useful for fast prototyping, ignoring the details of implenting backprop or writing optimization procedure. • Provides to work Convolution , Recurrent layer and combination of both. • Most of architecture is designed by using this framework. • Keras and Python gives a amazing power to developer as
  • 6. A.INTRODUCTION • Keras is usually used for small datasets as it is comparitively slower. On the other hand, TensorFlow and PyTorch are used for high performance models and large datasets that require fast execution. • We can differentiate Keras like that Keras tops the list followed by TensorFlow.Keras gained amazing popularity due to its simplicity.
  • 7. A.INTRODUCTION • In the world , 250,000 Keras Developers
  • 8. B.INSTALLATION 1) PREREQUISITES You must satisfy the following requirements: • Any kind of OS (Windows, Linux or Mac) • Python version 3.5 or higher. • Keras is python based neural network library so python must be installed on your machine. If python is properly installed on your machine, then open your terminal and type python, you can check as specified below :
  • 9. B.INSTALLATION Step 1: Create virtual environment • Virtualenv is used to manage Python packages for different projects. This will be helpful to avoid breaking the packages installed in the other environments. So, it is always recommended to use a virtual environment while developing Python applications. • Linux or mac OS users, go to your project root directory and type the below command to create virtual environment : « python3 -m venv kerasenv « • Windows user can use the below command : « py -m venv keras »
  • 10. B.INSTALLATION Step 2: Activate the environment This step will configure python and pip executables in your shell path. Linux/Mac OS • Now we have created a virtual environment named “kerasvenv”. Move to the folder and type the below command, «$ cd kerasvenv kerasvenv $ source bin/activate « Windows users move inside the “kerasenv” folder and type the below command: «.envScriptsactivate «
  • 11. B.INSTALLATION Step 3: Python libraries Keras depends on the following python libraries : Numpy , Pandas , Scikit-learn , Matplotlib , Scipy , Seaborn. When you installed the keras, u have already installed these libriaries on your computer.But If there is a problem about any libriary , we can install these one by one . As below structure which is on command window : « pip install ‘name of libriary’ «
  • 12. B.INSTALLATION • Example for Step-3 : If you have already installed , you will get : If you havent done before, you will get :
  • 13. B.INSTALLATION Step 4 : Keras Installation Using Python As of now, we have completed basic requirements for the installtion of Keras. Now, install the Keras using same procedure on the command as specified below: « pip install keras « *** Quit virtual environment *** After finishing all your changes in your project, then simply run the below command to quit the environment: « deactivate »
  • 14. C.BACKEND CONFIGURATION • This step explains Keras backend implementations TensorFlow and Theano . TensorFlow TensorFlow is an open source machine learning library used for numerical computational tasks developed by Google. Keras is a high level API built on top of TensorFlow or Theano. We know already how to install TensorFlow using pip. « pip install theano « Theano Theano is an open source deep learning library that allows you to evaluate multi-dimensional arrays effectively. We can easily install
  • 15. D. OVERVIEW OF DEEP LEARNING • We can define like that Deep Learning is consisting of layers which are follows each other to get useful features. • Deep learning is sub-branch of machine learning. • ‘Deep’ means that it does not mean that get deeeeeep magicful knowledge.This word means that multi-layers and amount of layers point out the depth of a model. • Modern deep learning algortithms have thousunds layers. • This layered notation is called ‘ Neural Networks ‘ which is inspired neurobiology but , we can say that this model process does not exactly match with neuro-science even some articles show opposite idea.
  • 16. D. OVERVIEW OF DEEP LEARNING In deep learning, a computer model learns to perform classification tasks directly from images, text, or sound. Deep learning models can achieve state-of-the-art accuracy, sometimes exceeding human- level performance. Models are trained by using a large set of labeled data and neural network architectures that contain many layers..On the right side , you can see the single perception of deep learning.
  • 17. D. OVERVIEW OF DEEP LEARNING Multi-Layer perceptron is the simplest form of ANN. It consists of a single input layer, one or more hidden layer and finally an output layer. A layer consists of a collection of perceptron. Input layer is basically one or more features of the input data. Every hidden layer consists of one or more neurons and process certain aspect of the feature and send the processed information into the next hidden layer. The output layer process receives the data from last hidden layer and
  • 18. D. OVERVIEW OF DEEP LEARNING General pipeline for implementing an ANN (Artifical NEURAL NETWORKS): We can simply define the procedure like that ; • DECIDE WHICH DEEP LEARNING ARCITECHTURE YOU NEED (CNN ? ,RNN ? ) !!! • Firstly we need labeled data ( as much as big data).And do not worry about how your code understand which part of data is necessary for your train., Keras handle it. • After defining how we need input and output data shape.( datas should be seperated as x_train, y_train , x_test , y_train). • Train and test datas should be different each other. • Design a architecture model to catch maximum accurucy.(Do not forget our goal is reaching max accurucy without overfitting) • Choose the correct optimizers ,actication function ,loss function.
  • 19. E. DEEP LEARNING WITH KERAS Implementing a neural network in Keras : • Preparing the input and specify the input dimension (size) • •Define the model architecture and build the computational graph • •Specify the optimizer and configure the learning process • •Specify the Inputs, Outputs of the computational graph (model) and the Loss function • Train and test the model on the dataset
  • 20. E. DEEP LEARNING WITH KERAS • In Keras, every ANN is represented by Keras Models. In turn, every Keras Model is composition of Keras Layers and represents ANN layers like input, hidden layer, output layers, convolution layer, pooling layer, etc., Keras model and layer access Keras modules for activation function, loss function, regularization function, etc., Using Keras model, Keras Layer, and Keras modules, any ANN algorithm (CNN, RNN, etc.,) can be represented in a simple and efficient manner. The following diagram depicts the relationship between model, layer and core modules:
  • 21. F. MODULE Keras modules cosist of classes, functions and variables.These are pre-defined,The modules make simpler to build model. List of Modules : • Initializers • Constrains • Activations • Utilities • Backend: • Sequence processing • Image processing • Text processing • Optimizers • Callback • Metrics • Losses
  • 22. G.LAYERS • As I pointed out , Keras layers are the essentials for the Keras models. Each layer takes input what previous layer provide as output, and this circle keeps on the untill last layer. • A layer needs to know shape of the input to get structue of the input data. • Layers also needs to know number of neurons , initializers, regularizers, constraints and activation function.
  • 23. G.LAYERS Let us create a simple Keras layer using Sequential model API to get the idea of how Keras model ; EXAMPLE - 1 : NOTE : Google Colaboratory is used to execute.Google gives us free Cpu and Gpu.
  • 25. G.LAYERS Activations • The activation function makes input data non linear , and model learn better. • The output of a perceptron (neuron) is simply the result of the activation function, which accepts the summation of all input multiplied with its corresponding weight plus overall bias. (result = Activation(SUMOF(input * weight) + bias) • Activation Function in the keras module = linear , elu , selu , relu , softmax , softplus , softsign , tanh , sigmoid , hard_sigmoid , exponential .
  • 26. G.LAYERS Dense Layer • Dense layer does the below operation on the input and return the output. • output = activation(dot(input, kernel) + bias) EXAMPLE 2- Lets find a result with using input and kernel : Let us consider sample input and weights as below and try to find the result: • input as 2 x 2 matrix [ [1, 2], [3, 4] ] • kernel as 2 x 2 matrix [ [0.5, 0.75], [0.25, 0.5] ] • bias value as 0
  • 27. G.LAYERS • Example 2 –Solution =
  • 28. G.LAYERS Dropout Layers Dropout layer is used generally in most of models, to prevent overfitting.Dropout layer deletes a noise which node has . We can simply define that when we train the model, yes we want to teach to model essential things to predict correctly. But ıf models memorize the labeled input data ,the model works on only what model see before. The model should work on not even see before test data. Memorizing and overfitting are similar things.
  • 29. G.LAYERS • Dropout has three arguments and they are as follows: « keras.layers.Dropout(rate, noise_shape=None, seed=None) « rate represent the fraction of the input unit to be dropped. It will be from 0 to 1. • noise_shape represent the dimension of the shape in which the dropout to be applied. For example, the input shape is (batch_size, timesteps, features). Then, to apply dropout in the timesteps, (batch_size, 1, features) need to be specified as noise_shape • seed - random seed.
  • 30. G.LAYERS Flatten Layers • Flatten layers also are used to get results together on the one row or one column .Most of time have been on before last layer. • For example, if flatten is applied to layer having input shape as (batch_size, 2,2), then the output shape of the layer will be (batch_size, 4) . • « keras.layers.Flatten(data_format=None) «
  • 32. H.MODEL COMPILATION • Now, how to compile the model will be explained . • The compilation is the final part of building a model. Loss = Loss function is used to find error or deviation in the learning process. Keras requires loss function during model compilation process. Keras have pre-defined some loss functions. We chooce one of these depends on our desire.
  • 33. H.MODEL COMPILATION Optimizer = Optimization is a vital , when training. This is for optimizing the input weights by comparing the prediction and loss function results. For example ; Stochastic gradient descent optimizer , Adam optimizer , Adamax optimizer .. Metrics = Always we try to get better and better result. To do this , we need to observe the performance of model. Metrics is used to evaluate the performance , it is similar to loss function, but not used in training process. • For example ; accuracy , categorical_accuracy ..
  • 34. H.MODEL COMPILATION • Keras model provides a method, compile() to compile the model. • The argument and default value of the compile() method is as follows: « compile(optimizer, loss=None, metrics=None, loss_weights=None, sample_weight_mode=None, weighted_metrics=None, target_tensors=None) »
  • 35. H.MODEL COMPILATION Model Training Models are trained by NumPy arrays using fit(). The main purpose of this fit function is used to evaluate your model on training. This can be also used for graphing model performance . « model.fit(X, y, epochs=, batch_size=) » • X, y - It is a tuple to evaluate your data. • epochs - no of times the model is needed to be evaluated during training. • batch_size - training instances
  • 36. H.MODEL COMPILATION Lets see one example about model compilation ; Example 4 :
  • 38. H.MODEL COMPILATION Example 5 : Let us choose a simple multi-layer perceptron (MLP) as represented below and try to create the model using Keras ; The core features of the model are as follows: • Input layer consists of 784 values (28 x 28 = 784). • First hidden layer, Dense consists of 512 neurons and ‘relu’ activation function. • Second hidden layer, Dropout has 0.2 as its value. • Third hidden layer, again Dense consists of 512 neurons and ‘relu’ activation function. • Fourth hidden layer, Dropout has 0.2 as its value. • Fifth and final layer consists of 10 neurons and ‘softmax’ activation function. • Use categorical_crossentropy as loss function. • Use RMSprop() as Optimizer • Use accuracy as metrics. • Use 128 as batch size.
  • 42. I. CONVOLUTIONAL NEURAL NETWORK (CNN) • The difference between CNN and ANN is that ANN is trained by global image , but CNN learns partially for example; if there is a image which is 10x10 , with cnn model learn 2 x2 , 2x2 , 2x2.. Its similar to signal filtering. • As you predict that there will be more details , and it causes better accuracy. • CNN is used most of time for images.
  • 43. I. CONVOLUTIONAL NEURAL NETWORK (CNN) We will observe CNN with a example which is like ‘ hello world ‘ of deep learning . We will use mnist dataset that consists of 70,000 images handwritten digits from 0 to 9 . Lets do the example to idetify them using a CNN. Example 6 : Mini-project idetify handwritten number
  • 44. I. CONVOLUTIONAL NEURAL NETWORK (CNN) • Example 6 :
  • 45. I. CONVOLUTIONAL NEURAL NETWORK (CNN) Example 6 :
  • 46. I. CONVOLUTIONAL NEURAL NETWORK (CNN) Example 6 :
  • 47. I. CONVOLUTIONAL NEURAL NETWORK (CNN) Example 6 :
  • 48. I. CONVOLUTIONAL NEURAL NETWORK (CNN) Example 6 :
  • 49. J. LSTM – RNN • RNNs can use their internal state (memory) to process sequences of inputs. This makes them applicable to tasks such as unsegmented, connected handwriting recognition or speech recognition. In other neural networks, all the inputs are independent of each other. But in RNN, all the inputs are related to each other. Advantages of Recurrent Neural Network • RNN can model sequence of data so that each sample can be assumed to be dependent on previous ones • Recurrent neural network are even used with convolutional layers to extend the effective pixel neighbourhood. Disadvantages of Recurrent Neural Network • Gradient vanishing and exploding problems. • Training an RNN is a very difficult task. • It cannot process very long sequences if using tanh or relu as an activation function.
  • 50. J. LSTM – RNN • Long Short-Term Memory (LSTM) networks are a modified version of recurrent neural networks, which makes it easier to remember past data in memory. • LSTM is well-suited to classify, process and predict time series given time lags of unknown duration. It trains the model by using back-propagation. • Lets see this part with an example which is that while predicting the actual price of a stock is an uphill climb, we can build a model that will predict whether the price will go up or down. The data and notebook used for this tutorial can be found (https://github.com/mwitiderrick/stockprice). It’s important to note that there are always other factors that affect
  • 51. J. LSTM – RNN Example 7 :
  • 52. J. LSTM – RNN Example 7 :
  • 53. J. LSTM – RNN Example 7 :
  • 54. J. LSTM – RNN Example 7 :
  • 55. J. LSTM – RNN Example 7 :
  • 56. J. LSTM – RNN Example 7 :
  • 57. K.APPLICATIONS As ı said before; more data , more accuracy. But if you have small dataset for images . What will you do ?! There is a solution which is Data Augmentation. That means that we play game with images like ;symetry , rotation , zoom … We need to just use ImageDataGenerator module. Lets see with one example ... Example -8 : We have 1 image and we want to much more data.Here is our images that is by Ara Guler :
  • 59. K.APPLICATIONS • Example- 8 : And, augmented images were loaded in my drive , as below ;
  • 63. K.APPLICATIONS Example- 10 : This time lets predict house prices ;
  • 69. CONCLUSION To sum up , the tutorial shows us that there are so many parameters to adjuct on your model, this skill will be gained by project experience . We can think like that we are in labaratory , we are doing experiment as building our deep learning model. I gained a experience also about learning and teaching when preparing the tutorial.In addition , I saw my weakness on some points which I will fix these as soon as possible. Finally, after working on this tutorial with much more detail, I will upload on my github account.
  • 70. REFERENCES • Deep Learning with Python-François Chollet-Manning Publications Company, 2017 • Keras.io • https://www.kdnuggets.com/ • https://www.mathworks.com/ • medium.com