Artificial Neural Network (ANN) -
Project Implementation
• Topic: ANN for Digit Recognition using SVHN Dataset
• Code Focus: Model Definition, Training, and Evaluation
• By: [Your Name]
• Course: Master of Computer Application
Data Preparation & Setup
• • Keras backend cleared to ensure reproducible results.
• • Random seeds fixed (NumPy, TensorFlow, random) for consistency.
• • Dataset reshaped into flattened form (32×32 = 1024 input features).
• • One-hot encoding applied to digit labels (0–9).
• • Final input shape: (samples, 1024) | Output shape: (samples, 10).
Model 1: Simple ANN
• • Architecture:
• - Input Layer: 1024 neurons
• - Hidden Layer 1: Dense(64), activation='relu'
• - Hidden Layer 2: Dense(32), activation='relu'
• - Output Layer: Dense(10), activation='softmax'
• • Optimizer: Adam (learning rate=0.001)
• • Loss: Categorical Crossentropy | Metric: Accuracy
• • Epochs: 20 | Batch Size: 128
Model 2: Optimized ANN
(Improved Architecture)
• • Architecture:
• - Input: 1024 neurons
• - Dense(256) → Dense(128) → Dropout(0.2)
• - Dense(64) → Dense(64) → Dense(32)
• - BatchNormalization() → Output(10, Softmax)
• • Optimizer: Adam (learning rate=0.0005)
• • Loss: Categorical Crossentropy | Metric: Accuracy
• • Epochs: 30 | Batch Size: 128
Training & Accuracy Tracking
• • Accuracy plotted for both training and validation sets.
• • Accuracy curve stabilizes around 77% for Model 2.
• • Validation accuracy consistent with training accuracy, indicating no overfitting.
• • Graph shows steady improvement across 30 epochs.
Model Evaluation & Results
• • Model 2 predictions compared with actual test labels.
• • Classification Report: 77% overall test accuracy.
• • Confusion Matrix visualized using seaborn heatmap.
• • Model performs better than Logistic Regression (13%) but weaker than CNN
(90%+).
Final Observations & Conclusion
• • ANN achieved 77% accuracy, proving effective but limited for image-based data.
• • Balanced training and validation accuracy shows good generalization.
• • Common misclassifications: digits 3, 5, 6, and 8.
• • ANN loses spatial context due to flattened input.
• • Future Work: Use CNN to retain spatial features for higher accuracy.