This repository contains implementations of various neural network architectures for image classification and other machine learning tasks. The project includes CNN models for CIFAR-10 image classification, RNN models for stock price prediction, and NLP models for sentiment analysis.
CNN/
├── cnn_image_classification.ipynb # Main CNN implementation for CIFAR-10
├── train_RNN.py # RNN training script for stock prediction
├── test_RNN.py # RNN testing script
├── train_NLP.py # NLP training script for sentiment analysis
├── test_NLP.py # NLP testing script
├── data/ # Dataset directory
│ ├── aclImdb/ # IMDB dataset for sentiment analysis
│ ├── q2_dataset.csv # Stock price dataset
│ ├── train_data_RNN.csv # Processed RNN training data
│ └── test_data_RNN.csv # Processed RNN testing data
└── README.md # This file
Implementation of convolutional neural networks for classifying images from the CIFAR-10 dataset. The project uses TensorFlow/Keras and implements multiple MLP and CNN architectures.
- CIFAR-10: 60,000 32x32 color images in 10 classes
- Training set: 50,000 images (20% randomly sampled = 10,000 images for training)
- Test set: 10,000 images (used for validation)
- MLP 1: 2 hidden layers (512, 512) with sigmoid activation
- MLP 2: 5 hidden layers (512, 256, 128, 64, 32) with sigmoid activation
- MLP 3: 3 hidden layers (256, 256, 256) with sigmoid activation
- MLP 4: 3 hidden layers (1024, 512, 256) with sigmoid activation
- MLP 5: 4 hidden layers (1024, 512, 256, 256) with sigmoid activation
- CNN 1: 2 Conv2D layers (64 filters, 3x3) + 2 Dense layers (512, 512)
- CNN 2: 2 Conv2D layers (64 filters, 3x3) + MaxPooling2D + 2 Dense layers (512, 512) + Dropout
- CNN 3: 4 Conv2D layers (64, 64, 128, 128) + MaxPooling2D + 2 Dense layers (128, 128) + Dropout
- Batch size: 32
- Epochs: 5 (initial), 10 (extended training)
- Optimizer: Adam
- Loss function: Categorical crossentropy
- Metrics: Accuracy
- Best MLP: MLP 4 achieved highest validation accuracy
- Best CNN: CNN 3 achieved 57.99% validation accuracy
- Overfitting Analysis: Extended training showed overfitting in CNN models
LSTM-based recurrent neural network for predicting stock opening prices using historical market data.
- Features: Open, High, Low, Volume prices
- Target: Next day's opening price
- Time window: 3 days of historical data
- Data split: 70% training, 30% testing
- LSTM layers: 3 layers with 256 units each
- Dropout: 0.2 dropout rate between LSTM layers
- Dense layer: 1 output unit for price prediction
- Activation: Linear (default)
- Min-Max scaling (0-1 range)
- Reshaped to (samples, timesteps, features) format
- Random shuffling with seed 42
Convolutional neural network for sentiment analysis on IMDB movie reviews dataset.
- IMDB Dataset: Movie reviews with positive/negative labels
- Text preprocessing: HTML removal, special character cleaning, lowercase conversion
- Sequence length: Maximum 1000 tokens
- Embedding layer: 16-dimensional word vectors
- Conv1D: 16 filters with kernel size 2
- GlobalAveragePooling1D: Sequence pooling
- Dense layers: 2 hidden layers (16, 16) with ReLU activation
- Dropout: 0.2 dropout rate throughout
- Output: 1 unit with sigmoid activation for binary classification
- Optimizer: Adam
- Loss function: Binary crossentropy
- Metrics: Accuracy
- Validation split: 30%
# Open the Jupyter notebook
jupyter notebook cnn_image_classification.ipynb
# Training
python train_RNN.py
# Testing
python test_RNN.py
# Training
python train_NLP.py
# Testing
python test_NLP.py
- TensorFlow/Keras
- NumPy
- Pandas
- Matplotlib
- Scikit-learn
- Jupyter Notebook
- MLP Performance: Deeper networks with more layers showed decreased performance due to overfitting
- CNN Advantage: CNN models consistently outperformed MLP models for image classification
- Overfitting: Extended training epochs led to overfitting in CNN models
- Architecture Impact: Adding dropout and pooling layers improved CNN generalization
- Data Sampling: Using 20% of training data showed the importance of sufficient training samples
Model Type | Best Validation Accuracy |
---|---|
MLP 4 | 38.25% |
CNN 1 | 54.65% |
CNN 2 | 55.41% |
CNN 3 | 57.99% |
- All models use the same training parameters for fair comparison
- Results are based on 5 epochs of training unless specified otherwise
- The project demonstrates the effectiveness of CNNs over MLPs for image classification tasks
- RNN and NLP implementations show practical applications of neural networks in different domains