ML-CaPsule icon indicating copy to clipboard operation
ML-CaPsule copied to clipboard

#539 Added CNN Implementation

Open Saswatsusmoy opened this issue 9 months ago • 0 comments

Contributes to #539

This PR adds functionality to load and preprocess the MNIST dataset for handwritten digit classification using PyTorch. It includes the following key changes:

Imports required libraries and modules for working with PyTorch, data manipulation, visualization, and evaluation.
Loads the MNIST dataset from Keras and splits it into training and test sets.
Preprocesses the data by reshaping the images to a 4D tensor and normalizing pixel values.
Converts the datasets to PyTorch tensors for efficient computations.
Visualizes sample images from the training set to understand the data.
Calculates and visualizes mean images and pixel intensity distributions per digit class.
Applies dimensionality reduction techniques (PCA and t-SNE) and visualizes the results.
Defines a Convolutional Neural Network (CNN) model architecture for digit classification.
Creates PyTorch DataLoader objects for efficient data loading during training and evaluation.
Instantiates the CNN model and defines the loss function (cross-entropy) and optimizer (Adam).
Implements the training loop to iteratively update the model's parameters based on computed gradients.
Evaluates the trained model on the test set, computing accuracy, classification report, and confusion matrix.
Visualizes the confusion matrix as a heatmap for analyzing the model's performance.

This PR sets up the data loading, preprocessing, and model architecture for the MNIST digit classification task using PyTorch. It lays the foundation for further training and evaluation of the CNN model.

Saswatsusmoy avatar May 10 '24 23:05 Saswatsusmoy