NQR-SNN Framework v3.2
Nuclear Quadrupole Resonance Signal Detection using Spiking Neural Networks
Detects ΒΉβ΄N-containing explosives/narcotics (RDX, TNT, HMX, PETN, cocaine, heroin) from NQR receiver RF signals buried in noise at -25 to -50 dB SNR.
v3.2 Results
99.17% mean accuracy across all SNR levels.
| SNR (dB) | Accuracy | AUC | F1 |
|---|---|---|---|
| -25 | 99.0% | 1.000 | 0.990 |
| -30 | 100.0% | 1.000 | 1.000 |
| -35 | 100.0% | 1.000 | 1.000 |
| -40 | 98.0% | 1.000 | 0.980 |
| -45 | 98.0% | 1.000 | 0.980 |
| -50 | 100.0% | 1.000 | 1.000 |
All gate checks passed: β -35 dB β₯ 95% β -40 dB β₯ 90% β -50 dB β₯ 80%
Full Pipeline (6 Stages)
python run_full_pipeline.py --quick # ~90s on CPU
python run_full_pipeline.py # full run
| Stage | What it does | Key output |
|---|---|---|
| 1. Denoiser Selection | Evaluates LM, SSA, Wavelet on low-SNR white noise; selects best | denoiser_selection.txt |
| 2. Parallel Neuron Search | 5 neuron Γ 3 surrogate = 15 configs via ProcessPoolExecutor |
neuron_search.csv, heatmap |
| 3. Dataset Generation | SNR-controlled signals β denoised β 7-channel feature extraction | train/val DataLoaders |
| 4. Ensemble Training | N-member heterogeneous CNN+SNN ensemble with TET loss | model checkpoints |
| 5. SNR Evaluation | Accuracy/AUC/F1 at each dB level with denoising | snn_accuracy_vs_snr.csv, ROC plots |
| 6. Stress Test | Gaussian, S&P, RFI, weight noise, OOD frequency shift | degradation + OOD plots |
Pipeline Data Flow
Raw NQR signal βββ [Wavelet/SSA/LM Denoiser] βββ Denoised signal
β β
ββββββββββββββββββββββββββββββββββββ [7-channel Feature Extraction]
β
real, imag, magnitude,
log-FFT, FFT phase,
unbiased autocorrelation,
instantaneous frequency
β
[CNN + SE Attention + Residual]
Conv1d(7β16β32β64) + SE blocks
GlobalAvgPool β 64-dim
β
[Learnable Temporal Encoder]
Differentiable time-weighting β T=8
β
[SNN Classification Head]
PLIF (learnable Ο) + detach_reset
TET loss (per-timestep supervision)
β
Detection: ΒΉβ΄N signal / noise
v3.2 Changes (from v3.1)
Bug Fixes
| # | Fix | Impact |
|---|---|---|
| 1 | Neuron search β ensemble wiring | Search results now populate ENSEMBLE_CONFIGS dynamically (was dead code β search ran but result was ignored) |
| 2 | Encoder train/inference mismatch | LearnableTemporalEncoder used at inference (was DeterministicEncoder), encoder weights saved in checkpoints |
| 3 | Early stopping on val_accuracy | Was val_loss β at 99%+ accuracy, loss fluctuates while accuracy plateaus, causing premature stopping |
Code Quality
| # | Change | Impact |
|---|---|---|
| 4 | Consolidated noise generation | generate_noise_sample() is single source of truth (was copy-pasted 4Γ) |
| 5 | Consolidated denoiser dispatch | denoise_signal()/denoise_batch() in nqr_snn.denoising (was copy-pasted 4Γ) |
| 6 | Removed dead code | RateCodingEncoder, legacy NQRDataset/build_dataloaders/get_balanced_loader removed |
| 7 | Removed archive files | Source lives on main branch directly β no more zip/tar.gz clutter |
| 8 | Removed dead config | USE_CURRICULUM/CURRICULUM_UNLOCK_FRAC removed (never implemented) |
| 9 | Tautological SNR verification | Removed noisy - clean check that always returned target exactly by construction |
Hyperparameter Tuning
| # | Parameter | Old β New | Why |
|---|---|---|---|
| 10 | NEURON_SEARCH_EPOCHS |
20 β 40 | Too few to differentiate neuron types |
| 11 | MAX_EPOCHS |
200 β 100 | Models converge at ~40-60; cosine schedule calibrated |
| 12 | EARLY_STOP_PATIENCE |
25 β 35 | More room for fine-grained improvement |
Signal Physics
The NQR receiver detects Free Induction Decay (FID) from ΒΉβ΄N nuclei:
y(t) = A Β· exp(-tΒ²/2ΟΒ² - t/Tβ) Β· exp(i[2ΟΞ½t + Ο]) + Ξ΅(t)
- A β amplitude (β nitrogen density)
- Ο β Gaussian decay (inhomogeneous broadening)
- Tβ β spin-spin relaxation (~1-10 ms for nitrogen compounds)
- Ξ½ β resonance frequency offset (compound + temperature specific)
- Ο β phase (pulse timing dependent)
- Ξ΅(t) β environmental RF noise (10β΄-10β΅Γ stronger than signal)
CLI Options
--quick Fast demo mode (~90s CPU)
--train_size N Samples per class for training (default: 3000)
--val_size N Samples per class for validation (default: 1000)
--ensemble_size N Ensemble members (default: 10)
--max_epochs N Max training epochs (default: 100)
--n_test N Test samples per SNR level (default: 300)
--search_workers N Parallel workers for neuron search (default: auto)
--search_epochs N Epochs per neuron search config (default: 40)
--skip_denoise Skip denoiser selection
--skip_neuron_search Skip neuron search (use PLIF+ATan)
--skip_stress_test Skip noise injection stress test
Requirements
pip install -r requirements.txt
- PyTorch β₯ 2.1
- SpikingJelly β₯ 0.0.0.0.14 (falls back to MLP without it)
- NumPy, SciPy, scikit-learn, PyWavelets, matplotlib, pandas
Literature References
- PLIF / learnable Ο: ParametricLIF node from SpikingJelly; AR-LIF (2507.20746) showed +3-4% on temporal tasks
- TET loss: Temporal Efficient Training from AR-LIF Β§3, Ξ»=0.5 balances per-timestep + mean loss
- SE attention: Squeeze-and-Excitation Networks (Hu et al. 2018) adapted for 1D signal processing
- Heterogeneous ensemble: STEP (2505.11151) found Ο and neuron type matter more than architecture depth
- T=8 timesteps: STEP + AR-LIF show T=4-8 sufficient; lower T reduces BPTT memory 2-4Γ
- detach_reset: DCLS-Delays (2306.17670) flags this as essential for stable training with T>4
- Instantaneous frequency: Standard NQR detection feature β NQR FID has constant IF vs random for noise
Generated by ML Intern
This model repository was generated by ML Intern, an agent for machine learning research and development on the Hugging Face Hub.
- Try ML Intern: https://smolagents-ml-intern.hf.space
- Source code: https://github.com/huggingface/ml-intern
Usage
from transformers import AutoModelForCausalLM, AutoTokenizer
model_id = 'KD099/nqr-snn-framework'
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(model_id)
For non-causal architectures, replace AutoModelForCausalLM with the appropriate AutoModel class.
Inference Providers NEW
This model isn't deployed by any Inference Provider. π Ask for provider support