0% found this document useful (0 votes)
3 views5 pages

Aiml Lab Week 8 Set-2

The document outlines a lab assignment for B.Tech students in the School of Computer Science Engineering and Technology, focusing on implementing a Convolutional Neural Network (CNN) to classify fashion items from the Fashion MNIST dataset. It includes detailed instructions for data exploration, preparation, model implementation using Keras/TensorFlow, performance evaluation, and visualization. Students are required to submit Python code and a report summarizing their findings and model performance metrics.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views5 pages

Aiml Lab Week 8 Set-2

The document outlines a lab assignment for B.Tech students in the School of Computer Science Engineering and Technology, focusing on implementing a Convolutional Neural Network (CNN) to classify fashion items from the Fashion MNIST dataset. It includes detailed instructions for data exploration, preparation, model implementation using Keras/TensorFlow, performance evaluation, and visualization. Students are required to submit Python code and a report summarizing their findings and model performance metrics.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

School of Computer Science Engineering and Technology

Course - B.Tech. Semester – 4th


Course Code - CSET301 Course Name - AIML
Year – 2025 Semester - Even

LAB ASSIGNMENT #8 SET -2


Objective:
To provide hands-on experience to students in implementing and applying a
Convolutional Neural Network (CNN) to classify fashion items from the
Fashion MNIST dataset, evaluate its performance, and compare the results of
different configurations.

Task Instructions:
Dataset Download:
• Fashion MNIST Dataset: The task is to classify fashion items (10
categories) using grayscale images from the Fashion MNIST dataset.
• Dataset URL: Fashion MNIST Dataset
(https://www.kaggle.com/datasets/zalando-research/fashionmnist)
Data Exploration:
1. Load the dataset into a DataFrame df_train for training data and df_test
for testing data.
o The Fashion MNIST dataset is available via libraries such as
keras.datasets.fashion_mnist.
2. Print statistical values such as mean, median, standard deviation for
each feature.
o Use functions like df.describe() for numerical statistics.
o Investigate the distribution of pixel values.
3. Check for missing values:
o Verify if there are missing values in the training or testing set.
Handle them accordingly (e.g., if required, scale or impute).
School of Computer Science Engineering and Technology

4. Visualize the distribution of pixel values or images to understand the data


distribution.

Data Preparation:
1. Preprocess Data:
o Normalize the data: Scale the pixel values to a range between 0
and 1 by dividing the image pixel values by 255.
o Reshape the images: The images are 28x28 pixels. Instead of
flattening, reshape them into (28,28,1) to maintain spatial features.
o Encode the labels: The target variable (fashion item) should be
one-hot encoded for classification.
2. Split the data into training (df_train) and testing (df_test) sets, ideally
80-20 split (train-test split can be done using train_test_split from
sklearn).

Model Implementation using Keras/TensorFlow:


1. Define the CNN Model:
o Implement a Convolutional Neural Network (CNN) with two or
more convolutional layers.
o Use ReLU activation for the convolutional layers.
o Apply MaxPooling layers to reduce dimensions.
o Add Flatten layer before the fully connected layers.
o Use a fully connected layer (Dense Layer) before the output
layer.
o Use Softmax activation for the output layer (since this is a multi-
class classification task).
2. Compile the model:
o Use categorical cross-entropy loss function (appropriate for
multi-class classification).
School of Computer Science Engineering and Technology

o Use Adam optimizer for optimization.


3. Train the model:
o Fit the model on the training data (df_train).
o Use an appropriate number of epochs (e.g., 10 to 30) and a batch
size (e.g., 32).
4. Evaluate the model:
o Evaluate the trained model using the test set (df_test) and calculate
the accuracy.
o Evaluate performance with other metrics such as precision, recall,
and F1-score if necessary.

Performance Evaluation:
1. Evaluate the performance of the model using:
o Accuracy (most common metric for classification).
o Confusion matrix to evaluate how well the model predicted the
fashion items.
2. Compare the performance of models by varying the number of filters in
convolutional layers and kernel size. For example, try different
configurations (e.g., 32, 64, 128 filters) and compare the results.
3. Analyze the model’s overfitting:
o If overfitting occurs, consider adding Dropout layers or
EarlyStopping to prevent this.

Visualization:
1. Plot the training vs. validation accuracy and loss over epochs to
visually assess how well the model is learning.
2. Visualize the predictions:
o Show a sample of test images and their predicted vs. actual
labels.
School of Computer Science Engineering and Technology

o Plot a confusion matrix to assess classification errors.


3. Feature importance:
o CNNs do not provide direct feature importance, but you can
visualize which areas of an image contribute most to a
classification using techniques like Grad-CAM.

Additional Tasks:
1. Experiment with different number of convolutional layers and filter
sizes. Compare performance by changing the number of filters in each
layer.
2. Hyperparameter tuning: Experiment with different configurations of
the model (e.g., number of filters, kernel sizes, activation functions)
and tune the model using techniques like GridSearchCV or
RandomSearch.
3. Evaluate using Cross-validation:
o Implement K-fold cross-validation to assess the model’s
consistency and generalizability.

Deliverables:
1. Submit the complete Python code used for implementing the assignment.
o Code for data preprocessing, model definition, training,
evaluation, and visualization.
2. Provide a detailed report summarizing the following:
o Findings from data exploration and preprocessing.
o Performance metrics (accuracy, loss, confusion matrix) for the
model.
o Visualizations of training history, predictions, and confusion
matrix.
School of Computer Science Engineering and Technology

o Comparisons between different CNN configurations (e.g., number


of filters, kernel sizes).

Additional Practice Questions (Not evaluated):


1. Experiment with different activation functions (ReLU, Sigmoid, Tanh,
etc.) and observe the performance variations.
2. Analyze how the number of epochs affects performance, particularly
looking for signs of overfitting or underfitting.
3. Implement and experiment with different optimizers (SGD, RMSprop,
Adamax) and compare their performance.

You might also like