This project was built for my Neural Networks course, where the goal was to classify 120 different Bangla handwritten compound characters. To tackle this, I used a convolutional neural network (CNN) with a multi-stage self-attention mechanism to better focus on important spatial features during classification.
# Bangla Compound Character Classification
*Using CNN with Multi-Level Self-Attention on the MatriVasha Dataset*
This is my final project for the Neural Networks course. The goal was to classify 120 different **Bangla handwritten compound characters** using a custom-built deep learning pipeline that combines a CNN backbone with attention mechanisms. I also included heatmap visualizations to show where the model was focusing during classification.
---
## Overview
This project is split into two main stages:
1. **Pretraining**: A convolutional neural network (CNN) is trained on CIFAR-100 (grayscale) to learn general image features.
2. **Finetuning**: The pretrained model is extended with **multi-level self-attention modules** and fine-tuned on the MatriVasha dataset of Bangla handwritten compound characters.
Due to **resource limitations** (running on Google Colab), training was done for only a few epochs — but even then, the model produced solid results and insightful attention maps.
---
## Dataset
This project uses the **MatriVasha** dataset, a large-scale handwritten Bangla compound character dataset containing 120 classes collected from male and female contributors.
- 🔗 Download the dataset on Mendeley Data
**Citation**:
Ferdous, Jannatul; Karmaker, Suvrajit; Rabby, AKM Shahariar Azad; Hossain, Syed Akhter
(2021), *“MatriVasha: Bangla Handwritten Compound Character Dataset and Recognition”*,
Mendeley Data, V1,
doi.org
> Dataset was manually preprocessed by merging male/female folders, resizing to 128×128, inverting pixel intensities, and normalizing to [-1, 1].
---
## Model Architecture
### 📌 Stage 1: `CustomCNN` (Pretraining)
- 4-layer convolutional network
- Trained on grayscale CIFAR-100
- Used `AdamW` optimizer and Xavier initialization
### 📌 Stage 2: `CNNEncoderWithAttention` (Finetuning)
- Self-attention modules applied on three CNN layers:
- 32×128×128 features
- 64×64×64 features
- 128×32×32 features
- Each att …