A simple convolutional neural network built with PyTorch to classify Japanese Hiragana characters from the KMNIST dataset. This project demonstrates basic image classification on a non-Latin dataset using a custom CNN.
- 🔤 10-class classification task (Hiragana characters)
- 📈 Trained with PyTorch on CPU
- 🧪 Evaluates accuracy and visualizes correct vs. incorrect predictions
- 🖼️ Uses Matplotlib to plot prediction results
The CNN model is defined in model.py
and includes:
- 5 convolutional layers with ReLU activation
- Max pooling after each conv layer
- Fully connected layers with ReLU
nn.LazyLinear
used for dynamic input sizing
Example:
model = CNN(input_layer=1, hidden_layer=200, output_layer=10)
After training, a 5×5 grid shows predictions:
- ✅ Green titles: Correct predictions
- ❌ Red titles: Incorrect predictions
git clone https://github.com/your-username/kmnist-cnn-classifier.git
cd kmnist-cnn-classifier
pip install -r requirements.txt
On Windows, if you encounter SSL certificate issues with KMNIST, add this in your code:
import ssl
ssl._create_default_https_context = ssl._create_unverified_context
python main.py
Listed in requirements.txt
:
- torch>=2.0.0
- torchvision>=0.15.0
- matplotlib>=3.5.0
├── main.py # Training and evaluation loop
├── model.py # CNN model definition
├── images/ # (Optional) folder for output plots
├── data/ # Auto-downloaded KMNIST dataset
├── requirements.txt # Package dependencies
└── README.md
- KMNIST dataset from ROIS-DS Center for Open Data in the Humanities
- Built using PyTorch and Matplotlib
This project is licensed under the MIT License.