SlideShare a Scribd company logo
1 of 20
Introduction for Deep Neural
Network DNN with Python
Asst. Prof. Dr.
Noor Dhia Al-Shakarchy
May 2021
Lecture 2
Outlines/ First Project in DNN
 The steps for first project are as follows:
1. Load Data.
2. Define Keras Model.
3. Compile Keras Model.
4. Fit Keras Model.
5. Evaluate Keras Model.
6. Make Predictions
2
First Project in DNN
1. Load Data.
 Download the dataset and place it in your local
working directory,
as your first project, The Pima Indians onset of
diabetes dataset. It describes patient medical
record data for Pima Indians and whether they had
an onset of diabetes within five years.
 It is “csv file” contains 8 attributes, plus class
 The problem is a binary classification (onset of
diabetes as 1 or not as 0).
3
First Project in DNN
4
 The dataset is available from here:
 Dataset CSV File (pima-indians-
diabetes.csv)
 Dataset Details
• inside the file, you should see rows of
data like the following
First Project in DNN
5
 We can now load the file as a matrix of numbers
using the NumPy function loadtxt().
 There are eight input variables and one output
variable (the last column).
 We will be learning a model to map rows of input
variables (X) to an output variable (y), which we
often summarize as:
y = f(X).
First Project in DNN
6
 Once the CSV file is loaded then split the columns of
data into input and output variables.
 The data will be stored in a 2D array [rows,
columns].
 Split the array into two arrays.
 Select the first 8 columns from index 0 to index 7 via
the slice 0:8.
 Select the output column (the 9th variable) via index
8.
code
7
# first neural network with keras tutorial
from numpy import loadtxt
from keras.models import Sequential
from keras.layers import Dense
# load the dataset
dataset = loadtxt('pima-indians-diabetes.data.csv', delimiter=',')
# split into input (X) and output (y) variables
X = dataset[:,0:8] # training subset
y = dataset[:,8] # label
2. Define Keras Model
 Models in Keras are defined as a sequence
of layers.
 We create a Sequential model and add
layers one at a time until we are happy
with our network architecture.
8
2. Define Keras Model
# define the keras model
model = Sequential()
model.add(Dense(8, input_dim=8, activation='relu'))
model.add(Dense(6, activation='relu'))
model.add(Dense(1, activation='sigmoid'))
model.summary()
 The model summary table reports the strength of the
relationship between the model and the dependent
variable.
9
No. of
nodes
3. Compile Keras Model
 Now that the model is defined, we can compile it.
 Training a network means finding the best set of
weights to map inputs to outputs in our dataset.
 We must specify the loss function to use to
evaluate a set of weights, the optimizer is used to
search through different weights for the network
and any optional metrics we would like to collect
and report during training.
10
3. Compile Keras Model
 In a binary classification problems, we will use
cross entropy as the loss argument, which is
defined in Keras as “binary_crossentropy“.
 We will define the optimizer as the efficient
stochastic gradient descent algorithm “adam“.
This is a popular version of gradient descent
because it automatically tunes itself and gives
good results in a wide range of problems.
 Finally, because it is a classification problem, we
will collect and report the classification accuracy,
defined via the metrics argument
11
3. Compile Keras Model
# compile the keras model
model.compile(loss='binary_crossentropy',
optimizer='adam', metrics=['accuracy'])
Or:
sgd = SGD(lr=0.001, decay=1e-6, momentum=0.9,
nesterov=True)
model.compile(loss='mse', optimizer=sgd,
metrics=['accuracy'])
print("construction DNN done")
12
4. Fit Keras Model
 It is ready for efficient computation.
 Now it is time to execute the model on some data
by train or fit our model on our loaded data by
calling the fit() function on the model.
 Training occurs over epochs and each epoch is
split into batches.
 Epoch: One pass through all of the rows in the
training dataset.
 Batch: One or more samples considered by the
model within an epoch before weights are
updated.
13
4. Fit Keras Model
 It The training process will run for a fixed number
of iterations through the dataset called epochs,
that we must specify using the epochs argument.
 We must also set the number of dataset rows that
are considered before the model weights are
updated within each epoch, called the batch size
and set using the batch_size argument.
 For this problem,
number of epochs =150
batch size = 10.
14
4. Fit Keras Model
 We want to train the model enough so that it learns
a good (or good enough) mapping of rows of input
data to the output classification.
 The model will always have some error, but the
amount of error will level out after some point for
a given model configuration. This is called model
convergence.
15
4. Fit Keras Model
# fit the keras model on the dataset
model.fit(X, y, epochs=150, batch_size=10)
16
5. Evaluate Keras Model
 You can evaluate your model on your
training dataset using
the evaluate() function on your model
and pass it the same input and output
used to train the model.
# evaluate the keras model
_, accuracy = model.evaluate(X, y)
print('Accuracy: %.2f' % (accuracy*100))
17
6. Make Predictions
18
 how can use the model to make predictions on
new data?
 Making predictions in a new dataset we have not
seen before is as easy as calling
the predict() function on the model.
 we can call the predict_classes() function on the
model to predict crisp classes directly
6. Make Predictions/ code
19
# make probability predictions with the model
predictions = model.predict(X)
for i in range(5):
print('%s => %d (expected %d)' % (X[i].tolist(),
predictions[i], y[i]))
# make class predictions with the model
predictions = model.predict_classes(X)
for i in range(5):
print('%s => %d (expected %d)' % (X[i].tolist(),
predictions[i], y[i]))
THANK YOU

More Related Content

What's hot

Introduction of Xgboost
Introduction of XgboostIntroduction of Xgboost
Introduction of Xgboostmichiaki ito
 
Gradient Boosted trees
Gradient Boosted treesGradient Boosted trees
Gradient Boosted treesNihar Ranjan
 
Introduction to XGBoost
Introduction to XGBoostIntroduction to XGBoost
Introduction to XGBoostJoonyoung Yi
 
Kaggle talk series top 0.2% kaggler on amazon employee access challenge
Kaggle talk series  top 0.2% kaggler on amazon employee access challengeKaggle talk series  top 0.2% kaggler on amazon employee access challenge
Kaggle talk series top 0.2% kaggler on amazon employee access challengeVivian S. Zhang
 
GBM package in r
GBM package in rGBM package in r
GBM package in rmark_landry
 
Reinforcement learning Research experiments OpenAI
Reinforcement learning Research experiments OpenAIReinforcement learning Research experiments OpenAI
Reinforcement learning Research experiments OpenAIRaouf KESKES
 
Machine learning and_nlp
Machine learning and_nlpMachine learning and_nlp
Machine learning and_nlpankit_ppt
 
Bank of pecunia mortgage risk model
Bank of pecunia mortgage risk modelBank of pecunia mortgage risk model
Bank of pecunia mortgage risk modelRui Cao
 
Bt0082, visual basic
Bt0082, visual basicBt0082, visual basic
Bt0082, visual basicsmumbahelp
 
Nyc open-data-2015-andvanced-sklearn-expanded
Nyc open-data-2015-andvanced-sklearn-expandedNyc open-data-2015-andvanced-sklearn-expanded
Nyc open-data-2015-andvanced-sklearn-expandedVivian S. Zhang
 
XGBoost @ Fyber
XGBoost @ FyberXGBoost @ Fyber
XGBoost @ FyberDaniel Hen
 
Lab 2: Classification and Regression Prediction Models, training and testing ...
Lab 2: Classification and Regression Prediction Models, training and testing ...Lab 2: Classification and Regression Prediction Models, training and testing ...
Lab 2: Classification and Regression Prediction Models, training and testing ...Yao Yao
 
Competition 1 (blog 1)
Competition 1 (blog 1)Competition 1 (blog 1)
Competition 1 (blog 1)TarunPaparaju
 
Introduction to Machine Learning in Python using Scikit-Learn
Introduction to Machine Learning in Python using Scikit-LearnIntroduction to Machine Learning in Python using Scikit-Learn
Introduction to Machine Learning in Python using Scikit-LearnAmol Agrawal
 
Logistic Regression using Mahout
Logistic Regression using MahoutLogistic Regression using Mahout
Logistic Regression using Mahouttanuvir
 
Caret Package for R
Caret Package for RCaret Package for R
Caret Package for Rkmettler
 
Classification with Naive Bayes
Classification with Naive BayesClassification with Naive Bayes
Classification with Naive BayesJosh Patterson
 
Machine teaching tbo_20190518
Machine teaching tbo_20190518Machine teaching tbo_20190518
Machine teaching tbo_20190518Yi-Fan Liou
 

What's hot (20)

Introduction of Xgboost
Introduction of XgboostIntroduction of Xgboost
Introduction of Xgboost
 
Gradient Boosted trees
Gradient Boosted treesGradient Boosted trees
Gradient Boosted trees
 
Introduction to XGBoost
Introduction to XGBoostIntroduction to XGBoost
Introduction to XGBoost
 
Kaggle talk series top 0.2% kaggler on amazon employee access challenge
Kaggle talk series  top 0.2% kaggler on amazon employee access challengeKaggle talk series  top 0.2% kaggler on amazon employee access challenge
Kaggle talk series top 0.2% kaggler on amazon employee access challenge
 
Demystifying Xgboost
Demystifying XgboostDemystifying Xgboost
Demystifying Xgboost
 
GBM package in r
GBM package in rGBM package in r
GBM package in r
 
Reinforcement learning Research experiments OpenAI
Reinforcement learning Research experiments OpenAIReinforcement learning Research experiments OpenAI
Reinforcement learning Research experiments OpenAI
 
Machine learning and_nlp
Machine learning and_nlpMachine learning and_nlp
Machine learning and_nlp
 
Bank of pecunia mortgage risk model
Bank of pecunia mortgage risk modelBank of pecunia mortgage risk model
Bank of pecunia mortgage risk model
 
Ppt shuai
Ppt shuaiPpt shuai
Ppt shuai
 
Bt0082, visual basic
Bt0082, visual basicBt0082, visual basic
Bt0082, visual basic
 
Nyc open-data-2015-andvanced-sklearn-expanded
Nyc open-data-2015-andvanced-sklearn-expandedNyc open-data-2015-andvanced-sklearn-expanded
Nyc open-data-2015-andvanced-sklearn-expanded
 
XGBoost @ Fyber
XGBoost @ FyberXGBoost @ Fyber
XGBoost @ Fyber
 
Lab 2: Classification and Regression Prediction Models, training and testing ...
Lab 2: Classification and Regression Prediction Models, training and testing ...Lab 2: Classification and Regression Prediction Models, training and testing ...
Lab 2: Classification and Regression Prediction Models, training and testing ...
 
Competition 1 (blog 1)
Competition 1 (blog 1)Competition 1 (blog 1)
Competition 1 (blog 1)
 
Introduction to Machine Learning in Python using Scikit-Learn
Introduction to Machine Learning in Python using Scikit-LearnIntroduction to Machine Learning in Python using Scikit-Learn
Introduction to Machine Learning in Python using Scikit-Learn
 
Logistic Regression using Mahout
Logistic Regression using MahoutLogistic Regression using Mahout
Logistic Regression using Mahout
 
Caret Package for R
Caret Package for RCaret Package for R
Caret Package for R
 
Classification with Naive Bayes
Classification with Naive BayesClassification with Naive Bayes
Classification with Naive Bayes
 
Machine teaching tbo_20190518
Machine teaching tbo_20190518Machine teaching tbo_20190518
Machine teaching tbo_20190518
 

Similar to Training course lect2

Unsupervised Aspect Based Sentiment Analysis at Scale
Unsupervised Aspect Based Sentiment Analysis at ScaleUnsupervised Aspect Based Sentiment Analysis at Scale
Unsupervised Aspect Based Sentiment Analysis at ScaleAaron (Ari) Bornstein
 
evaluation.py# Handwritten digit recognition for MNIST data
evaluation.py# Handwritten digit recognition for MNIST dataevaluation.py# Handwritten digit recognition for MNIST data
evaluation.py# Handwritten digit recognition for MNIST dataBetseyCalderon89
 
How to Build a Neural Network and Make Predictions
How to Build a Neural Network and Make PredictionsHow to Build a Neural Network and Make Predictions
How to Build a Neural Network and Make PredictionsDeveloper Helps
 
Mini-lab 1: Stochastic Gradient Descent classifier, Optimizing Logistic Regre...
Mini-lab 1: Stochastic Gradient Descent classifier, Optimizing Logistic Regre...Mini-lab 1: Stochastic Gradient Descent classifier, Optimizing Logistic Regre...
Mini-lab 1: Stochastic Gradient Descent classifier, Optimizing Logistic Regre...Yao Yao
 
Viktor Tsykunov: Azure Machine Learning Service
Viktor Tsykunov: Azure Machine Learning ServiceViktor Tsykunov: Azure Machine Learning Service
Viktor Tsykunov: Azure Machine Learning ServiceLviv Startup Club
 
maXbox starter65 machinelearning3
maXbox starter65 machinelearning3maXbox starter65 machinelearning3
maXbox starter65 machinelearning3Max Kleiner
 
Image classification using cnn
Image classification using cnnImage classification using cnn
Image classification using cnnDebarko De
 
Start machine learning in 5 simple steps
Start machine learning in 5 simple stepsStart machine learning in 5 simple steps
Start machine learning in 5 simple stepsRenjith M P
 
Intro to DL with Keras - chapter3 - datacamp.pdf
Intro to DL with Keras - chapter3 - datacamp.pdfIntro to DL with Keras - chapter3 - datacamp.pdf
Intro to DL with Keras - chapter3 - datacamp.pdfavivnur2023
 
ML-Ops how to bring your data science to production
ML-Ops  how to bring your data science to productionML-Ops  how to bring your data science to production
ML-Ops how to bring your data science to productionHerman Wu
 
Final training course
Final training courseFinal training course
Final training courseNoor Dhiya
 
Log Analytics in Datacenter with Apache Spark and Machine Learning
Log Analytics in Datacenter with Apache Spark and Machine LearningLog Analytics in Datacenter with Apache Spark and Machine Learning
Log Analytics in Datacenter with Apache Spark and Machine LearningPiotr Tylenda
 
Log Analytics in Datacenter with Apache Spark and Machine Learning
Log Analytics in Datacenter with Apache Spark and Machine LearningLog Analytics in Datacenter with Apache Spark and Machine Learning
Log Analytics in Datacenter with Apache Spark and Machine LearningAgnieszka Potulska
 
maxbox starter60 machine learning
maxbox starter60 machine learningmaxbox starter60 machine learning
maxbox starter60 machine learningMax Kleiner
 
DataStax | Data Science with DataStax Enterprise (Brian Hess) | Cassandra Sum...
DataStax | Data Science with DataStax Enterprise (Brian Hess) | Cassandra Sum...DataStax | Data Science with DataStax Enterprise (Brian Hess) | Cassandra Sum...
DataStax | Data Science with DataStax Enterprise (Brian Hess) | Cassandra Sum...DataStax
 
wepik-breaking-down-spam-detection-a-deep-learning-approach-with-tensorflow-a...
wepik-breaking-down-spam-detection-a-deep-learning-approach-with-tensorflow-a...wepik-breaking-down-spam-detection-a-deep-learning-approach-with-tensorflow-a...
wepik-breaking-down-spam-detection-a-deep-learning-approach-with-tensorflow-a...NANDHINIS900805
 
maXbox starter69 Machine Learning VII
maXbox starter69 Machine Learning VIImaXbox starter69 Machine Learning VII
maXbox starter69 Machine Learning VIIMax Kleiner
 
Session 4 start coding Tensorflow 2.0
Session 4 start coding Tensorflow 2.0Session 4 start coding Tensorflow 2.0
Session 4 start coding Tensorflow 2.0Rajagopal A
 
Yufeng Guo | Coding the 7 steps of machine learning | Codemotion Madrid 2018
Yufeng Guo |  Coding the 7 steps of machine learning | Codemotion Madrid 2018 Yufeng Guo |  Coding the 7 steps of machine learning | Codemotion Madrid 2018
Yufeng Guo | Coding the 7 steps of machine learning | Codemotion Madrid 2018 Codemotion
 

Similar to Training course lect2 (20)

Unsupervised Aspect Based Sentiment Analysis at Scale
Unsupervised Aspect Based Sentiment Analysis at ScaleUnsupervised Aspect Based Sentiment Analysis at Scale
Unsupervised Aspect Based Sentiment Analysis at Scale
 
evaluation.py# Handwritten digit recognition for MNIST data
evaluation.py# Handwritten digit recognition for MNIST dataevaluation.py# Handwritten digit recognition for MNIST data
evaluation.py# Handwritten digit recognition for MNIST data
 
How to Build a Neural Network and Make Predictions
How to Build a Neural Network and Make PredictionsHow to Build a Neural Network and Make Predictions
How to Build a Neural Network and Make Predictions
 
Mini-lab 1: Stochastic Gradient Descent classifier, Optimizing Logistic Regre...
Mini-lab 1: Stochastic Gradient Descent classifier, Optimizing Logistic Regre...Mini-lab 1: Stochastic Gradient Descent classifier, Optimizing Logistic Regre...
Mini-lab 1: Stochastic Gradient Descent classifier, Optimizing Logistic Regre...
 
Viktor Tsykunov: Azure Machine Learning Service
Viktor Tsykunov: Azure Machine Learning ServiceViktor Tsykunov: Azure Machine Learning Service
Viktor Tsykunov: Azure Machine Learning Service
 
maXbox starter65 machinelearning3
maXbox starter65 machinelearning3maXbox starter65 machinelearning3
maXbox starter65 machinelearning3
 
Image classification using cnn
Image classification using cnnImage classification using cnn
Image classification using cnn
 
Start machine learning in 5 simple steps
Start machine learning in 5 simple stepsStart machine learning in 5 simple steps
Start machine learning in 5 simple steps
 
Intro to DL with Keras - chapter3 - datacamp.pdf
Intro to DL with Keras - chapter3 - datacamp.pdfIntro to DL with Keras - chapter3 - datacamp.pdf
Intro to DL with Keras - chapter3 - datacamp.pdf
 
ML-Ops how to bring your data science to production
ML-Ops  how to bring your data science to productionML-Ops  how to bring your data science to production
ML-Ops how to bring your data science to production
 
Final training course
Final training courseFinal training course
Final training course
 
Log Analytics in Datacenter with Apache Spark and Machine Learning
Log Analytics in Datacenter with Apache Spark and Machine LearningLog Analytics in Datacenter with Apache Spark and Machine Learning
Log Analytics in Datacenter with Apache Spark and Machine Learning
 
Log Analytics in Datacenter with Apache Spark and Machine Learning
Log Analytics in Datacenter with Apache Spark and Machine LearningLog Analytics in Datacenter with Apache Spark and Machine Learning
Log Analytics in Datacenter with Apache Spark and Machine Learning
 
maxbox starter60 machine learning
maxbox starter60 machine learningmaxbox starter60 machine learning
maxbox starter60 machine learning
 
DataStax | Data Science with DataStax Enterprise (Brian Hess) | Cassandra Sum...
DataStax | Data Science with DataStax Enterprise (Brian Hess) | Cassandra Sum...DataStax | Data Science with DataStax Enterprise (Brian Hess) | Cassandra Sum...
DataStax | Data Science with DataStax Enterprise (Brian Hess) | Cassandra Sum...
 
wepik-breaking-down-spam-detection-a-deep-learning-approach-with-tensorflow-a...
wepik-breaking-down-spam-detection-a-deep-learning-approach-with-tensorflow-a...wepik-breaking-down-spam-detection-a-deep-learning-approach-with-tensorflow-a...
wepik-breaking-down-spam-detection-a-deep-learning-approach-with-tensorflow-a...
 
maXbox starter69 Machine Learning VII
maXbox starter69 Machine Learning VIImaXbox starter69 Machine Learning VII
maXbox starter69 Machine Learning VII
 
Session 4 start coding Tensorflow 2.0
Session 4 start coding Tensorflow 2.0Session 4 start coding Tensorflow 2.0
Session 4 start coding Tensorflow 2.0
 
BPstudy sklearn 20180925
BPstudy sklearn 20180925BPstudy sklearn 20180925
BPstudy sklearn 20180925
 
Yufeng Guo | Coding the 7 steps of machine learning | Codemotion Madrid 2018
Yufeng Guo |  Coding the 7 steps of machine learning | Codemotion Madrid 2018 Yufeng Guo |  Coding the 7 steps of machine learning | Codemotion Madrid 2018
Yufeng Guo | Coding the 7 steps of machine learning | Codemotion Madrid 2018
 

Recently uploaded

SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxupamatechverse
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxupamatechverse
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Dr.Costas Sachpazis
 
Analog to Digital and Digital to Analog Converter
Analog to Digital and Digital to Analog ConverterAnalog to Digital and Digital to Analog Converter
Analog to Digital and Digital to Analog ConverterAbhinavSharma374939
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escortsranjana rawat
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSSIVASHANKAR N
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)Suman Mia
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSRajkumarAkumalla
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidNikhilNagaraju
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...Soham Mondal
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Christo Ananth
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations120cr0395
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝soniya singh
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130Suhani Kapoor
 

Recently uploaded (20)

SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptx
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptx
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
 
Analog to Digital and Digital to Analog Converter
Analog to Digital and Digital to Analog ConverterAnalog to Digital and Digital to Analog Converter
Analog to Digital and Digital to Analog Converter
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfid
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
 
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINEDJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
 

Training course lect2

  • 1. Introduction for Deep Neural Network DNN with Python Asst. Prof. Dr. Noor Dhia Al-Shakarchy May 2021 Lecture 2
  • 2. Outlines/ First Project in DNN  The steps for first project are as follows: 1. Load Data. 2. Define Keras Model. 3. Compile Keras Model. 4. Fit Keras Model. 5. Evaluate Keras Model. 6. Make Predictions 2
  • 3. First Project in DNN 1. Load Data.  Download the dataset and place it in your local working directory, as your first project, The Pima Indians onset of diabetes dataset. It describes patient medical record data for Pima Indians and whether they had an onset of diabetes within five years.  It is “csv file” contains 8 attributes, plus class  The problem is a binary classification (onset of diabetes as 1 or not as 0). 3
  • 4. First Project in DNN 4  The dataset is available from here:  Dataset CSV File (pima-indians- diabetes.csv)  Dataset Details • inside the file, you should see rows of data like the following
  • 5. First Project in DNN 5  We can now load the file as a matrix of numbers using the NumPy function loadtxt().  There are eight input variables and one output variable (the last column).  We will be learning a model to map rows of input variables (X) to an output variable (y), which we often summarize as: y = f(X).
  • 6. First Project in DNN 6  Once the CSV file is loaded then split the columns of data into input and output variables.  The data will be stored in a 2D array [rows, columns].  Split the array into two arrays.  Select the first 8 columns from index 0 to index 7 via the slice 0:8.  Select the output column (the 9th variable) via index 8.
  • 7. code 7 # first neural network with keras tutorial from numpy import loadtxt from keras.models import Sequential from keras.layers import Dense # load the dataset dataset = loadtxt('pima-indians-diabetes.data.csv', delimiter=',') # split into input (X) and output (y) variables X = dataset[:,0:8] # training subset y = dataset[:,8] # label
  • 8. 2. Define Keras Model  Models in Keras are defined as a sequence of layers.  We create a Sequential model and add layers one at a time until we are happy with our network architecture. 8
  • 9. 2. Define Keras Model # define the keras model model = Sequential() model.add(Dense(8, input_dim=8, activation='relu')) model.add(Dense(6, activation='relu')) model.add(Dense(1, activation='sigmoid')) model.summary()  The model summary table reports the strength of the relationship between the model and the dependent variable. 9 No. of nodes
  • 10. 3. Compile Keras Model  Now that the model is defined, we can compile it.  Training a network means finding the best set of weights to map inputs to outputs in our dataset.  We must specify the loss function to use to evaluate a set of weights, the optimizer is used to search through different weights for the network and any optional metrics we would like to collect and report during training. 10
  • 11. 3. Compile Keras Model  In a binary classification problems, we will use cross entropy as the loss argument, which is defined in Keras as “binary_crossentropy“.  We will define the optimizer as the efficient stochastic gradient descent algorithm “adam“. This is a popular version of gradient descent because it automatically tunes itself and gives good results in a wide range of problems.  Finally, because it is a classification problem, we will collect and report the classification accuracy, defined via the metrics argument 11
  • 12. 3. Compile Keras Model # compile the keras model model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy']) Or: sgd = SGD(lr=0.001, decay=1e-6, momentum=0.9, nesterov=True) model.compile(loss='mse', optimizer=sgd, metrics=['accuracy']) print("construction DNN done") 12
  • 13. 4. Fit Keras Model  It is ready for efficient computation.  Now it is time to execute the model on some data by train or fit our model on our loaded data by calling the fit() function on the model.  Training occurs over epochs and each epoch is split into batches.  Epoch: One pass through all of the rows in the training dataset.  Batch: One or more samples considered by the model within an epoch before weights are updated. 13
  • 14. 4. Fit Keras Model  It The training process will run for a fixed number of iterations through the dataset called epochs, that we must specify using the epochs argument.  We must also set the number of dataset rows that are considered before the model weights are updated within each epoch, called the batch size and set using the batch_size argument.  For this problem, number of epochs =150 batch size = 10. 14
  • 15. 4. Fit Keras Model  We want to train the model enough so that it learns a good (or good enough) mapping of rows of input data to the output classification.  The model will always have some error, but the amount of error will level out after some point for a given model configuration. This is called model convergence. 15
  • 16. 4. Fit Keras Model # fit the keras model on the dataset model.fit(X, y, epochs=150, batch_size=10) 16
  • 17. 5. Evaluate Keras Model  You can evaluate your model on your training dataset using the evaluate() function on your model and pass it the same input and output used to train the model. # evaluate the keras model _, accuracy = model.evaluate(X, y) print('Accuracy: %.2f' % (accuracy*100)) 17
  • 18. 6. Make Predictions 18  how can use the model to make predictions on new data?  Making predictions in a new dataset we have not seen before is as easy as calling the predict() function on the model.  we can call the predict_classes() function on the model to predict crisp classes directly
  • 19. 6. Make Predictions/ code 19 # make probability predictions with the model predictions = model.predict(X) for i in range(5): print('%s => %d (expected %d)' % (X[i].tolist(), predictions[i], y[i])) # make class predictions with the model predictions = model.predict_classes(X) for i in range(5): print('%s => %d (expected %d)' % (X[i].tolist(), predictions[i], y[i]))