Cross-modal knowledge distillation (Cross-KD) has shown immense promise in transferring rich representations from high-capacity Artificial Neural Networks (ANNs) to Spiking Neural Networks (SNNs). While typically used for vision or neuromorphic data, this project applies Cross-KD to highly imbalanced tabular datasets, enabling low-power, robust classification for applications like fraud detection, healthcare diagnostics, and IoT analytics.
In tabular domains with rare classes, SNNs provide power-efficient inference but suffer from limited capacity. This framework distills a well-trained ANN into an SNN using three progressive phases:
- Logit Mimicry (KL Divergence)
- Semantic Feature Alignment (MSE/Cosine similarity)
- Fine-tuning for Imbalance Sensitivity (Cross-Entropy + F1 optimization)
The ANN teacher is trained with SMOTE, focal loss, or class-weighted CE. Inputs are encoded as spike trains via rate or time-to-first-spike coding.
crosskd-snn-tabular/
├── teacher_ann.py # ANN teacher model
├── student_snn.py # SNN student model (SpikingJelly)
├── distillation_loss.py # KL + MSE + CE loss
├── spike_encoding.py # Tabular → spike encoding
├── train_crosskd.py # Pipeline: train, align, evaluate
├── evaluate_metrics.py # Balanced evaluation metrics
├── requirements.txt
├── LICENSE
├── .gitignore
└── README.mdpip install -r requirements.txtEnsure you have Python ≥3.8 and install
spikingjellyfrom GitHub if not in PyPI:pip install git+https://github.com/fangwei123456/spikingjelly
python train_crosskd.pypython evaluate_metrics.py- Rate Coding for continuous features
- Time-to-First-Spike or One-Hot Spike for categorical/binary
- Sliding Semantic Replacement during distillation
- Focal Loss + SMOTE on ANN to combat imbalance
- KL Divergence + MSE + CE hybrid loss on SNN
- Macro F1-Score
- Balanced Accuracy
- PR-AUC
- Recall@Minority Class
- Li et al. (2025), Cross-Modal Distillation with Boundary-Aware Alignment, Neural Networks
- Fang et al. (2023), SpikingJelly: An Open-Source Framework for SNNs, Frontiers in Neuroscience
- Liu et al. (2024), Distillation from Vision Transformers to SNNs, arXiv preprint
- Cai et al. (2022), Temporal Knowledge Transfer for Spiking Networks, NeurIPS
- He et al. (2023), Focal Loss for Highly Imbalanced Data, IEEE TPAMI
- Zhang et al. (2025), Sliding Semantic Replacement in Multi-Modal Learning, ACL
You can turn this into a live interactive demo via Hugging Face Spaces:
huggingface-cli login
huggingface-cli repo create crosskd-tabular --type=space --sdk=streamlit
git remote add hf https://huggingface.co/spaces/<username>/crosskd-tabular
git push hf mainThis project is licensed under the MIT License.
Saurav Singla
🔗 github.com/sauravsingla
Special thanks to the authors of SpikingJelly, and the Cross-KD researchers pioneering the adaptation of semantic distillation across modalities.