This project demonstrates the implementation of a neural network for classifying handwritten digits from the MNIST dataset using TensorFlow and Keras
- Python 3.12.5
- NumPy
- Matplotlib
- Seaborn
- OpenCV
- PIL
- TensorFlow
- Keras
- Clone the repository:
git clone <repository-url> cd <repository-directory>
- Install the required packages
- Run the cells sequentially to execute the code
- Enter the path of the image to be predicted when prompted
- Importing Dependencies:
- Import necessary libraries such as NumPy, Matplotlib, Seaborn, OpenCV, PIL, TensorFlow, and Keras
- Loading the MNIST Dataset:
- Load the MNIST dataset using Keras' built-in dataset loader
- Data Preprocessing:
- Normalize the pixel values of the images to the range [0, 1]
- Reshape the data as required by the neural network
- Building the Neural Network:
- Define a sequential model with layers including Flatten, Dense, and Activation layers
- Compiling the Model:
- Compile the model using the Adam optimizer and sparse categorical cross-entropy loss function
- Training the Model:
- Train the model on the training data for a specified number of epochs
- Evaluating the Model:
- Evaluate the model's performance on the test data
- Display the accuracy and loss
- Making Predictions:
- Use the trained model to make predictions on the test data
- Convert prediction probabilities to class labels
- Visualizing Results:
- Display sample images from the test set along with their predicted and true labels.
- Plot the confusion matrix to visualize the model's performance
The model achieves a high accuracy on both the training and test datasets