Electron microscopy
 
PythonML
Handwritten Digit Recognition
- Python Automation and Machine Learning for ICs -
- An Online Book -
Python Automation and Machine Learning for ICs                                                           http://www.globalsino.com/ICs/        


Chapter/Index: Introduction | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z | Appendix

=================================================================================

TensorFlow provides various datasets through its tf.keras.datasets module. The MNIST dataset is a commonly used dataset for handwritten digit recognition (code):

 

   Input: 

 

   Output when epochs=1: 

The predicted number is: 5 

This is a wrong prediction with just 1 epoch. 

   Output when epochs=2:  

The predicted number is: 3

This is still a wrong prediction with just 2epoch.

   Output when epochs=5:  

The predicted number is: 7 

Now, the prediction is correct with an increased numbers of epochs (5 epoch). 

The code (x_train, y_train), (x_test, y_test) = mnist.load_data() above is used to load the MNIST dataset in TensorFlow: 

  • mnist refers to the MNIST dataset, which is a collection of 28x28 pixel grayscale images of handwritten digits (0 through 9). 

  • The load_data() function is used to load the dataset. When we call mnist.load_data(), it returns two tuples: 

    • (x_train, y_train): This tuple contains the training images (x_train) and their corresponding labels (y_train). These images and labels are used to train a machine learning model. 

    • (x_test, y_test): This tuple contains the test images (x_test) and their corresponding labels (y_test). The model is not trained on these test images; instead, they are used to evaluate the model's performance after training. 

    • After executing the code, you have four variables (x_train, y_train, x_test, and y_test) that hold the training and test data for the MNIST dataset. This data can be used to train a neural network or any other machine learning model for tasks such as digit classification. 

 

============================================

         
         
         
         
         
         
         
         
         
         
         
         
         
         
         
         
         
         

 

 

 

 

 



















































 

 

 

 

 

=================================================================================