SlideShare a Scribd company logo
1 of 10
z
How to Build a
Neural Network and
Make Predictions?
-Developerhelps
z
Introduction
 Lately, people have been really into neural networks. They’re like a
computer system that works like a brain, with nodes connected together.
These networks are great at sorting through big piles of data and figuring
out patterns to solve hard problems or guess stuff. And you know what’s
super cool? They can keep on learning forever.
 Creating and deploying neural networks can be a challenging process,
which largely depends on the specific task and dataset you’re dealing with.
To succeed in this endeavor, it’s crucial to possess a solid grasp of machine
learning concepts, along with strong programming skills. Additionally, a
deep understanding of the chosen deep learning framework is essential.
Moreover, it’s imperative to prioritize responsible and ethical usage of AI
models, especially when integrating them into real-world applications.
z
What is a Neural Network?
 Neural networks are a type of artificial intelligence modeled after
the human brain. They consist of interconnected nodes, or
“neurons,” organized in layers.

 Input Layer: The input layer receives data, like images or text.
 Hidden Layers: Between the input and output layers, there can be
one or more hidden layers. These layers process and transform the
data.
 Output Layer: The output layer produces the final results, like
predicting numbers or classifying objects.
z
How to Build Our First Neural
Network?
 Certainly! Building your first neural network in Python is an exciting step
in the world of artificial intelligence and deep learning. Let’s walk through
a simple example of creating a neural network to solve a basic problem:
classifying handwritten digits using the popular library Tensor Flow and its
high-level API, Keras.

 Step 1: Import Libraries
 First, you need to import the necessary libraries:

 import tensor flow as tf
 from tensor flow import keras
z
 Step 2: Load and Prepare the Data
 Before you can train a neural network, you need to prepare your data. This typically involves:

 Data Collection: Gather a dataset that is relevant to your task. For example, if you want to
classify images of cats and dogs, you need a dataset of labeled cat and dog images.
 Data Preprocessing: Clean and preprocess your data. This can include tasks like resizing
images, normalizing values, and splitting the data into training and testing sets.
 For this, we’ll use the MNIST dataset, which contains handwritten digits. You can load it
using TensorFlow’s built-in function:

 mnist = keras.datasets.mnist
 (train_images, train_labels), (test_images, test_labels) = mnist.load_data()
 Next, preprocess the data by normalizing the pixel values to a range between 0 and 1:

 train_images = train_images / 255.0
 test_images = test_images / 255.0
z
 Step 3: Build the Neural Network
 Choose a neural network architecture that is suitable for your problem. The
architecture defines the structure of the neural network, including the
number of layers, the type of layers, and the number of neurons in each
layer. For example, you can choose between feedforward neural networks,
convolutional neural networks (CNNs), and recurrent neural networks
(RNNs) based on your data and task.

 Now, let’s proceed to create a straightforward neural network. In this
example, we’ll opt for a feedforward neural network featuring one hidden
layer:
z
 Step 4: Compile the Model
 Compile the neural network model by specifying:

 Loss Function: This defines the measure of error between the predicted output and the actual
target. The choice of loss function depends on the type of problem you’re solving, such as
mean squared error for regression or categorical cross-entropy for classification.
 Optimizer: Select an optimization algorithm (e.g., Adam, SGD) that adjusts the network’s
parameters to minimize the loss function.
 Metrics: Specify evaluation metrics (e.g., accuracy, precision, recall) to assess the model’s
performance during training.
 Compile the model by specifying the loss function, optimizer, and evaluation metric:
 model.compile(optimizer=‘adam’,
 loss=‘sparse_categorical_crossentropy’,
 metrics=[‘accuracy’])
z
 Step 5: Train the Model
 The training process involves feeding your training data into the neural network
and iteratively updating the model’s weights and biases to minimize the loss.
This process includes:

 Forward Propagation: The neural network makes predictions on the training
data.
 Loss Computation: The difference between the predicted values and the actual
target values is computed using the chosen loss function.
 Backward Propagation (Backpropagation): Errors are propagated backward
through the network, and the optimizer updates the weights and biases using
gradients to reduce the loss.
 Epochs: Training typically occurs over multiple epochs, where one epoch is a
complete pass through the entire training dataset.
 Now, it’s time to train the neural network on the training data:

 model.fit(train_images, train_labels, epochs=5)
z
 Step 6: Evaluate the Model
 After training, evaluate the model’s performance on the test data. During training, it’s essential to monitor
the model’s performance on a separate validation dataset. This helps detect overfitting, where the model
learns the training data too well but fails to generalize to new data. You can fine-tune hyperparameters,
adjust the architecture, or employ techniques like dropout and regularization to improve performance.

 After training, evaluate the model’s performance on a separate testing dataset to assess its ability to
generalize to new, unseen data.

 Test_loss, test_acc = model.evaluate(test_images, test_labels)
 print(“Test accuracy:”, test_acc)
 Step 7: Make Predictions
 Once you are satisfied with your model’s performance, you can use it to make predictions on new, real-
world data.

 You can make predictions using the trained model on new data:

 predictions = model.predict(test_images)
z
CONCLUSION
 Following the network’s architecture setup, we initiated the
training process, which spanned over five epochs.
Subsequently, we assessed its performance on the test dataset.
The noteworthy outcome was that the model achieved an
impressive test accuracy of approximately 97.61%. This
outcome underscores the model’s capability to accurately
classify handwritten digits, demonstrating a high level of
accuracy.
 -THANKYOU

More Related Content

Similar to How to Build a Neural Network and Make Predictions

MachinaFiesta: A Vision into Machine Learning 🚀
MachinaFiesta: A Vision into Machine Learning 🚀MachinaFiesta: A Vision into Machine Learning 🚀
MachinaFiesta: A Vision into Machine Learning 🚀GDSCNiT
 
Facial Emotion Detection on Children's Emotional Face
Facial Emotion Detection on Children's Emotional FaceFacial Emotion Detection on Children's Emotional Face
Facial Emotion Detection on Children's Emotional FaceTakrim Ul Islam Laskar
 
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
 
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
 
Designing a neural network architecture for image recognition
Designing a neural network architecture for image recognitionDesigning a neural network architecture for image recognition
Designing a neural network architecture for image recognitionShandukaniVhulondo
 
Introduction to Machine Learning with SciKit-Learn
Introduction to Machine Learning with SciKit-LearnIntroduction to Machine Learning with SciKit-Learn
Introduction to Machine Learning with SciKit-LearnBenjamin Bengfort
 
Neural basics
Neural basicsNeural basics
Neural basicscoursesub
 
Metaphorical Analysis of diseases in Tomato leaves using Deep Learning Algori...
Metaphorical Analysis of diseases in Tomato leaves using Deep Learning Algori...Metaphorical Analysis of diseases in Tomato leaves using Deep Learning Algori...
Metaphorical Analysis of diseases in Tomato leaves using Deep Learning Algori...IRJET Journal
 
Machine teaching tbo_20190518
Machine teaching tbo_20190518Machine teaching tbo_20190518
Machine teaching tbo_20190518Yi-Fan Liou
 
CSA 3702 machine learning module 1
CSA 3702 machine learning module 1CSA 3702 machine learning module 1
CSA 3702 machine learning module 1Nandhini S
 
Getting_Started_with_DL_in_Keras.pptx
Getting_Started_with_DL_in_Keras.pptxGetting_Started_with_DL_in_Keras.pptx
Getting_Started_with_DL_in_Keras.pptxMohamed Essam
 
Deep Learning with Apache MXNet (September 2017)
Deep Learning with Apache MXNet (September 2017)Deep Learning with Apache MXNet (September 2017)
Deep Learning with Apache MXNet (September 2017)Julien SIMON
 
EssentialsOfMachineLearning.pdf
EssentialsOfMachineLearning.pdfEssentialsOfMachineLearning.pdf
EssentialsOfMachineLearning.pdfAnkita Tiwari
 
The ABC of Implementing Supervised Machine Learning with Python.pptx
The ABC of Implementing Supervised Machine Learning with Python.pptxThe ABC of Implementing Supervised Machine Learning with Python.pptx
The ABC of Implementing Supervised Machine Learning with Python.pptxRuby Shrestha
 

Similar to How to Build a Neural Network and Make Predictions (20)

MachinaFiesta: A Vision into Machine Learning 🚀
MachinaFiesta: A Vision into Machine Learning 🚀MachinaFiesta: A Vision into Machine Learning 🚀
MachinaFiesta: A Vision into Machine Learning 🚀
 
Neural Networks
Neural NetworksNeural Networks
Neural Networks
 
Facial Emotion Detection on Children's Emotional Face
Facial Emotion Detection on Children's Emotional FaceFacial Emotion Detection on Children's Emotional Face
Facial Emotion Detection on Children's Emotional Face
 
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
 
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
 
ANN - UNIT 3.pptx
ANN - UNIT 3.pptxANN - UNIT 3.pptx
ANN - UNIT 3.pptx
 
ANN - UNIT 3.pptx
ANN - UNIT 3.pptxANN - UNIT 3.pptx
ANN - UNIT 3.pptx
 
Designing a neural network architecture for image recognition
Designing a neural network architecture for image recognitionDesigning a neural network architecture for image recognition
Designing a neural network architecture for image recognition
 
Introduction to Machine Learning with SciKit-Learn
Introduction to Machine Learning with SciKit-LearnIntroduction to Machine Learning with SciKit-Learn
Introduction to Machine Learning with SciKit-Learn
 
Neural basics
Neural basicsNeural basics
Neural basics
 
Metaphorical Analysis of diseases in Tomato leaves using Deep Learning Algori...
Metaphorical Analysis of diseases in Tomato leaves using Deep Learning Algori...Metaphorical Analysis of diseases in Tomato leaves using Deep Learning Algori...
Metaphorical Analysis of diseases in Tomato leaves using Deep Learning Algori...
 
Machine teaching tbo_20190518
Machine teaching tbo_20190518Machine teaching tbo_20190518
Machine teaching tbo_20190518
 
Artificial Neural Networks , Recurrent networks , Perceptron's
Artificial Neural Networks , Recurrent networks , Perceptron'sArtificial Neural Networks , Recurrent networks , Perceptron's
Artificial Neural Networks , Recurrent networks , Perceptron's
 
CSA 3702 machine learning module 1
CSA 3702 machine learning module 1CSA 3702 machine learning module 1
CSA 3702 machine learning module 1
 
Getting_Started_with_DL_in_Keras.pptx
Getting_Started_with_DL_in_Keras.pptxGetting_Started_with_DL_in_Keras.pptx
Getting_Started_with_DL_in_Keras.pptx
 
Som paper1.doc
Som paper1.docSom paper1.doc
Som paper1.doc
 
N ns 1
N ns 1N ns 1
N ns 1
 
Deep Learning with Apache MXNet (September 2017)
Deep Learning with Apache MXNet (September 2017)Deep Learning with Apache MXNet (September 2017)
Deep Learning with Apache MXNet (September 2017)
 
EssentialsOfMachineLearning.pdf
EssentialsOfMachineLearning.pdfEssentialsOfMachineLearning.pdf
EssentialsOfMachineLearning.pdf
 
The ABC of Implementing Supervised Machine Learning with Python.pptx
The ABC of Implementing Supervised Machine Learning with Python.pptxThe ABC of Implementing Supervised Machine Learning with Python.pptx
The ABC of Implementing Supervised Machine Learning with Python.pptx
 

Recently uploaded

Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024Janet Corral
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfAyushMahapatra5
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...fonyou31
 
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...PsychoTech Services
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 

Recently uploaded (20)

Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 

How to Build a Neural Network and Make Predictions

  • 1. z How to Build a Neural Network and Make Predictions? -Developerhelps
  • 2. z Introduction  Lately, people have been really into neural networks. They’re like a computer system that works like a brain, with nodes connected together. These networks are great at sorting through big piles of data and figuring out patterns to solve hard problems or guess stuff. And you know what’s super cool? They can keep on learning forever.  Creating and deploying neural networks can be a challenging process, which largely depends on the specific task and dataset you’re dealing with. To succeed in this endeavor, it’s crucial to possess a solid grasp of machine learning concepts, along with strong programming skills. Additionally, a deep understanding of the chosen deep learning framework is essential. Moreover, it’s imperative to prioritize responsible and ethical usage of AI models, especially when integrating them into real-world applications.
  • 3. z What is a Neural Network?  Neural networks are a type of artificial intelligence modeled after the human brain. They consist of interconnected nodes, or “neurons,” organized in layers.   Input Layer: The input layer receives data, like images or text.  Hidden Layers: Between the input and output layers, there can be one or more hidden layers. These layers process and transform the data.  Output Layer: The output layer produces the final results, like predicting numbers or classifying objects.
  • 4. z How to Build Our First Neural Network?  Certainly! Building your first neural network in Python is an exciting step in the world of artificial intelligence and deep learning. Let’s walk through a simple example of creating a neural network to solve a basic problem: classifying handwritten digits using the popular library Tensor Flow and its high-level API, Keras.   Step 1: Import Libraries  First, you need to import the necessary libraries:   import tensor flow as tf  from tensor flow import keras
  • 5. z  Step 2: Load and Prepare the Data  Before you can train a neural network, you need to prepare your data. This typically involves:   Data Collection: Gather a dataset that is relevant to your task. For example, if you want to classify images of cats and dogs, you need a dataset of labeled cat and dog images.  Data Preprocessing: Clean and preprocess your data. This can include tasks like resizing images, normalizing values, and splitting the data into training and testing sets.  For this, we’ll use the MNIST dataset, which contains handwritten digits. You can load it using TensorFlow’s built-in function:   mnist = keras.datasets.mnist  (train_images, train_labels), (test_images, test_labels) = mnist.load_data()  Next, preprocess the data by normalizing the pixel values to a range between 0 and 1:   train_images = train_images / 255.0  test_images = test_images / 255.0
  • 6. z  Step 3: Build the Neural Network  Choose a neural network architecture that is suitable for your problem. The architecture defines the structure of the neural network, including the number of layers, the type of layers, and the number of neurons in each layer. For example, you can choose between feedforward neural networks, convolutional neural networks (CNNs), and recurrent neural networks (RNNs) based on your data and task.   Now, let’s proceed to create a straightforward neural network. In this example, we’ll opt for a feedforward neural network featuring one hidden layer:
  • 7. z  Step 4: Compile the Model  Compile the neural network model by specifying:   Loss Function: This defines the measure of error between the predicted output and the actual target. The choice of loss function depends on the type of problem you’re solving, such as mean squared error for regression or categorical cross-entropy for classification.  Optimizer: Select an optimization algorithm (e.g., Adam, SGD) that adjusts the network’s parameters to minimize the loss function.  Metrics: Specify evaluation metrics (e.g., accuracy, precision, recall) to assess the model’s performance during training.  Compile the model by specifying the loss function, optimizer, and evaluation metric:  model.compile(optimizer=‘adam’,  loss=‘sparse_categorical_crossentropy’,  metrics=[‘accuracy’])
  • 8. z  Step 5: Train the Model  The training process involves feeding your training data into the neural network and iteratively updating the model’s weights and biases to minimize the loss. This process includes:   Forward Propagation: The neural network makes predictions on the training data.  Loss Computation: The difference between the predicted values and the actual target values is computed using the chosen loss function.  Backward Propagation (Backpropagation): Errors are propagated backward through the network, and the optimizer updates the weights and biases using gradients to reduce the loss.  Epochs: Training typically occurs over multiple epochs, where one epoch is a complete pass through the entire training dataset.  Now, it’s time to train the neural network on the training data:   model.fit(train_images, train_labels, epochs=5)
  • 9. z  Step 6: Evaluate the Model  After training, evaluate the model’s performance on the test data. During training, it’s essential to monitor the model’s performance on a separate validation dataset. This helps detect overfitting, where the model learns the training data too well but fails to generalize to new data. You can fine-tune hyperparameters, adjust the architecture, or employ techniques like dropout and regularization to improve performance.   After training, evaluate the model’s performance on a separate testing dataset to assess its ability to generalize to new, unseen data.   Test_loss, test_acc = model.evaluate(test_images, test_labels)  print(“Test accuracy:”, test_acc)  Step 7: Make Predictions  Once you are satisfied with your model’s performance, you can use it to make predictions on new, real- world data.   You can make predictions using the trained model on new data:   predictions = model.predict(test_images)
  • 10. z CONCLUSION  Following the network’s architecture setup, we initiated the training process, which spanned over five epochs. Subsequently, we assessed its performance on the test dataset. The noteworthy outcome was that the model achieved an impressive test accuracy of approximately 97.61%. This outcome underscores the model’s capability to accurately classify handwritten digits, demonstrating a high level of accuracy.  -THANKYOU