Practical 1: Augmentation and Regularization. Additionally, The Model's Performance Will
Practical 1: Augmentation and Regularization. Additionally, The Model's Performance Will
Practical 1
To study and implement CNN on CIFAR-10 with real-world testing.
Problem Description:
This practical task involves building and fine-tuning a Convolutional Neural
Network (CNN) to classify images within the CIFAR-10 dataset, which includes
ten diverse categories such as animals and vehicles. The objective is to
improve the model's accuracy through optimization techniques like data
augmentation and regularization. Additionally, the model’s performance will
be evaluated on ten or more real-world images to assess its generalization
capabilities outside the training dataset. The completed project will be
compiled into a single PDF, including the code, results, and summary.
Solution Architecture:
Code:
import tensorflow as tf
from tensorflow.keras import datasets, layers, models
plt.figure(figsize=(10,10))
for i in range(25):
plt.subplot(5,5,i+1)
plt.xticks([])
plt.yticks([])
plt.grid(False)
plt.imshow(train_images[i])
plt.xlabel(class_names[train_labels[i][0]])
plt.show()
model = models.Sequential()
model.add(layers.Conv2D(32, (3, 3), activation='relu', input_shape=(32, 32, 3)))
model.add(layers.MaxPooling2D((2, 2)))
model.add(layers.Conv2D(64, (3, 3), activation='relu'))
model.add(layers.MaxPooling2D((2, 2)))
model.summary()
model.add(layers.Flatten())
model.add(layers.Dense(64, activation='relu'))
model.add(layers.Dense(10))
model.summary()
model.compile(optimizer='adam',
loss=tf.keras.losses.SparseCategoricalCrossentropy(from_logits=True),
metrics=['accuracy'])
plt.plot(history.history['accuracy'], label='accuracy')
plt.plot(history.history['val_accuracy'], label = 'val_accuracy')
plt.xlabel('Epoch')
plt.ylabel('Accuracy')
plt.ylim([0.5, 1])
plt.legend(loc='lower right')
print(test_acc)
Results:
Summary :
The CNN model was developed and optimized to classify images accurately
within the CIFAR-10 dataset. Fine-tuning techniques, including data
augmentation, dropout, and learning rate adjustments, were applied to
enhance accuracy and reduce overfitting. The model was further tested on
real-world images, demonstrating strong generalization beyond the dataset.
The submission includes well-organized code, a summary of key findings, and
a report on real-world performance, all compiled in a single PDF as per the
submission requirements.