This repo provides a hybrid training pipeline (Quantum + Classical) for event-based datasets using the Temporal Quantum Representation (TQR).
Supported datasets (processed into .npy TQR tensors):
- N-MNIST (10 classes, 34×34, ATIS)
- N-CARS (2 classes, 120×120, ATIS)
- DVS Gesture (11 classes, 128×128, DVS128)
- e-CK+ (7 classes, 346×260, DAVIS346)
Install dependencies:
pip install -r requirements.txtExpected directory format:
datasets/processed_data/recognition/
├── nmnist_rep_100ms/
│ ├── 0/ (class folder with .npy TQR tensors)
│ ├── 1/
│ └── ...
├── ncars_rep_100ms/
├── dvsgesture_rep_100ms/
└── eck+_rep_100ms/
Each .npy file should contain a tensor (H, W, BINS, 2) with binary values:
[..., 0]→ negative polarity[..., 1]→ positive polarity
Run training for all datasets:
python train.pyOr train a single dataset:
python train.py --dataset nmnist- Load TQR tensors (
.npy) - Preprocessing: optional spatial pooling, flatten
- PCA reduction → target dimension = number of qubits
- N-MNIST → 8
- N-CARS → 8
- DVS Gesture → 12
- e-CK+ → 16
- Quantum embedding: AngleEmbedding + StronglyEntanglingLayers
- Classical head: Linear + ReLU + Linear → Softmax
- Training/validation accuracy per epoch is printed.
- Best validation accuracy is reported per dataset.
python train.py --dataset ncars --epochs 10 --batch_size 32=== Dataset: ncars | qubits=8 | classes=2 ===
Epoch 01 | train loss 0.6932 acc 0.51 | val loss 0.6920 acc 0.55 | best 0.55
...