This project explores the impact of different hyperparameters on Convolutional Neural Networks (CNNs) using the CIFAR-10 dataset. Our goal is to optimize the model architecture and preprocessing techniques to enhance the accuracy and efficiency of CNNs in image classification tasks.
- Hyperparameter Optimization: Explore various hyperparameter configurations to find the best settings for improving model accuracy and efficiency.
- Data Preprocessing and Enhancement: Use advanced preprocessing and data augmentation techniques to prepare and enhance the dataset for building a robust CNN model.
The CIFAR-10 dataset consists of 60,000 32x32 color images in 10 classes, with 6,000 images per class. There are 50,000 training images and 10,000 testing images.
data/
train/
validation/
test/
models/
model_1.h5
model_2.h5
model_3.h5
model_4.h5
model_5.h5
model_6.h5
model_7.h5
model_8.h5
notebooks/
model_1.ipynb
model_2.ipynb
model_3.ipynb
model_4.ipynb
model_5.ipynb
model_6.ipynb
model_7.ipynb
model_8.ipynb
README.md
- Normalization: Pixel values are scaled to the range [0, 1].
- One-Hot Encoding: Class labels are converted into binary vectors using
tf.keras.utils.to_categorical()
. - Data Augmentation: Techniques like rotation, zooming, and shifting are applied to increase training data variety and model robustness.
- Input Layer: 32x32 RGB images.
- Convolutional Layers: Apply filters to extract features.
- Activation Functions: Introduce non-linearity (ReLU).
- Pooling Layers: Reduce spatial dimensions (Max Pooling).
- Flatten Layer: Converts 2D feature maps into a 1D vector.
- Dense (Fully Connected) Layers: Aggregate features to make predictions.
- Output Layer: Softmax activation for classification.
The project includes eight different models, each with unique configurations of convolutional layers, pooling layers, dense layers, activation functions, and regularization techniques.
- 2 Convolutional Layers
- Max Pooling
- Flatten
- 1 Dense Layer
- Softmax Output
- 3 Convolutional Layers
- Max Pooling
- Flatten
- 2 Dense Layers
- Softmax Output
- 4 Convolutional Layers
- Max Pooling
- Flatten
- 2 Dense Layers
- Softmax Output
- 5 Convolutional Layers
- Max Pooling
- Flatten
- 3 Dense Layers
- Softmax Output
- Batch Normalization after each Convolutional Layer
- 3 Convolutional Layers
- Max Pooling
- Flatten
- 2 Dense Layers
- Softmax Output
- Dropout after each Dense Layer
- 4 Convolutional Layers
- Max Pooling
- Flatten
- 2 Dense Layers
- Softmax Output
- Increased Filter Size in Convolutional Layers
- 3 Convolutional Layers
- Max Pooling
- Flatten
- 2 Dense Layers
- Softmax Output
- Combination of Batch Normalization and Dropout
- 4 Convolutional Layers
- Max Pooling
- Flatten
- 3 Dense Layers
- Softmax Output
- Optimizer: Adam with a learning rate of 0.001
- Loss Function: Categorical cross-entropy
- Metrics: Accuracy
Models are trained using the fit()
function with:
- Batch Size: Number of samples processed before updating weights.
- Number of Epochs: Total iterations over the dataset.
- EarlyStopping: To halt training if performance on the validation set doesn’t improve.
- Accuracy and Loss: Measure learning and generalization.
- Confusion Matrix: To understand the classification performance.
- Training and Validation Curves: Analyze accuracy and loss curves for insights.
- Keras: High-level neural network API for fast prototyping.
- TensorFlow: Open-source library for machine learning and deep learning.
- Matplotlib: For plotting training and validation metrics.
This project aims to optimize CNN models for better image classification using the CIFAR-10 dataset. By fine-tuning hyperparameters and applying advanced preprocessing techniques, we developed CNN algorithms that excel in accuracy and generalization.
-
Clone the repository:
git clone https://github.com/karim7tr/Machine-Learning-II-Project.git cd Machine-Learning-II-Project
-
Install required libraries:
pip install -r requirements.txt
-
Run the Jupyter notebooks:
jupyter notebook notebooks/model_1.ipynb
-
Train the models: Follow the instructions in each notebook to train and evaluate the models.
- Karim Triki
- Ines Haouala