A PyTorch implementation of TCS-LBCNN, a lightweight convolutional neural network that uses fixed sparse local binary pattern–inspired filters combined with learnable 1×1 convolutions.
This repository provides:
- A clean, installable Python package
- Ready-to-use Docker images
- Reproducible training and evaluation workflows
TCS-LBCNN replaces standard 3×3 convolution kernels with fixed, sparse, directional contrast filters (two non-zero weights per kernel) followed by learnable channel mixing.
Benefits
- Fewer trainable parameters
- Strong inductive bias for local texture and edge patterns
- Suitable for lightweight or constrained environments
- MNIST
- CIFAR-10 (optionally resized to 28×28 as configured)
The easiest way to use this project is via Docker. No Python installation required.
docker pull ghcr.io/ebrahimalwajih/tcslbcnn-pytorch-implementation:latestdocker run --rm ghcr.io/ebrahimalwajih/tcslbcnn-pytorch-implementation:latest \
python -c "import tcslbcnn; print('tcslbcnn ready')"docker run --rm \
ghcr.io/ebrahimalwajih/tcslbcnn-pytorch-implementation:latest \
python -c "from tcslbcnn.training import train; train(dataset='mnist', n_epochs=1, batch_size=64, use_compile=False)"- Python ≥ 3.10
- pip
pip install -r requirements.txt
pip install -e .python -c "from tcslbcnn.training import train; train(dataset='mnist', n_epochs=1, batch_size=64, use_compile=False)"During training, the following directories are created:
artifacts/models/— model checkpointsartifacts/runs/— TensorBoard logs
To view training metrics:
tensorboard --logdir artifacts/runssrc/tcslbcnn/ Core Python package
tests/ Unit tests
artifacts/ Training outputs (not committed)
- Fixed initialization for TCS-LBP filters
- Deterministic training options
- Docker images ensure environment consistency
MIT License.
If you use this implementation in academic or research work, please cite the following paper:
E. Al-wajih and R. Ghazali, Threshold center-symmetric local binary convolutional neural networks for bilingual handwritten digit recognition, Knowledge-Based Systems, vol. 259, Article 110079, 2023. https://doi.org/10.1016/j.knosys.2022.110079
@article{ALWAJIH2023110079,
title = {Threshold center-symmetric local binary convolutional neural networks for bilingual handwritten digit recognition},
author = {Al-wajih, Ebrahim and Ghazali, Rozaida},
journal = {Knowledge-Based Systems},
volume = {259},
pages = {110079},
year = {2023},
issn = {0950-7051},
doi = {10.1016/j.knosys.2022.110079},
url = {https://www.sciencedirect.com/science/article/pii/S0950705122011753}
}