A simple CNN for MNIST digit classification, trained from scratch.
Run the full pipeline in Docker: docker run -it harpertoken/cnn-mnist:latest
- Create virtual environment:
python3 -m venv venv - Activate:
source venv/bin/activate - Install dependencies:
pip install -r requirements.txt - Train model:
python src/train.py - Test model:
python src/test.py - Predict:
python src/predict.py
Git branches are parallel versions of your codebase. They allow you to work on features or fixes without affecting the main code.
- Main Branch: The primary branch (often
mainormaster) where stable code lives. - How to Use:
- Create a new branch:
git checkout -b feature-branch - Switch branches:
git checkout main - Merge changes:
git merge feature-branch
- Create a new branch:
- In this project, push to
maintriggers CI and Docker push.
Containers are lightweight, portable environments that package your app with all dependencies. Docker creates containers from images.
- Benefits: Run consistently across machines, isolate environments, easy deployment.
- How to Choose:
- Local: For development, quick testing, or when you have Python installed. Use
./run_all.shfor full workflow. - Docker: For production, sharing, or when you want isolation/portability. Use
docker run yourusername/cnn-mnistafter pulling the image.
- Local: For development, quick testing, or when you have Python installed. Use
- How to Use:
- Build locally:
docker build -t cnn-mnist . - Run:
docker run --rm cnn-mnist - Pull from Docker Hub:
docker pull yourusername/cnn-mnist
- Build locally:
Choose local for experimentation, Docker for deployment.
- Create a new repository on GitHub.
- Push the code:
git remote add origin <repo-url> && git push -u origin main - Set up secrets in GitHub repo settings:
DOCKER_USERNAME: Your Docker Hub usernameDOCKER_PASSWORD: Your Docker Hub password or access token
- The CI workflow will run on push, testing and pushing Docker image to Docker Hub.
The CI automatically builds and pushes the image to yourusername/cnn-mnist:latest on successful tests.
To run locally: docker run yourusername/cnn-mnist
This project uses conventional commit standards.
To enable commit message validation:
cp scripts/commit-msg .git/hooks/commit-msgfeat:new featurefix:bug fixdocs:documentationstyle:formattingrefactor:code refactortest:testingchore:maintenanceperf:performanceci:CI/CDbuild:build systemrevert:revert
- First line: lowercase, ≤60 chars, starts with type:
- Example:
feat: add new cnn model
To clean up existing commits:
git filter-branch --msg-filter 'bash scripts/rewrite_msg.sh' -- --all
git push --forceUse with caution.