v3.2: Fix 7 bugs/redundancies (encoder mismatch, dead code, duplication, scheduler)

#1

v3.2 Bugfix & Cleanup Release

Critical Fix

  • #9 Encoder mismatch (train/inference): Training used LearnableTemporalEncoder but inference used DeterministicEncoder. Encoder weights were never saved. Now saves encoder alongside model checkpoint and loads it at inference. This was silently degrading accuracy at every evaluation.

Bug Fixes

  • #2 Neuron search dead code: Search results went nowhere — ENSEMBLE_CONFIGS was hardcoded. Now the pipeline rebuilds ENSEMBLE_CONFIGS from the top-K search results.
  • #6 Tautological SNR verification: generate_dataset_v2() reconstructed SNR from noisy - clean, which is guaranteed to match by construction. Removed the redundant computation.
  • #7 Scheduler miscalibration: MAX_EPOCHS=200 but models converge at ~40-60; cosine schedule was at 75% LR when early stopping fired. Changed to MAX_EPOCHS=100, EARLY_STOP_PATIENCE=35. Early stopping now tracks val_accuracy instead of val_loss (loss fluctuates at 99%+ accuracy). NEURON_SEARCH_EPOCHS increased from 20→40.

Code Deduplication

  • #3 Noise generation 4× duplication: Added generate_noise_sample() to noise_sources.py as single source of truth. All 5 functions in generator.py now call it.
  • #4 Denoising dispatch 4× duplication: Added denoise_signal() and denoise_batch() to nqr_snn/denoising/__init__.py. Used by dataset, inference, selector, and pipeline.
  • #5 Legacy API: Annotated with deprecation notes, slimmed by noise refactor.

Files Changed (10)

  • nqr_snn/config.py — hyperparameter fixes
  • nqr_snn/data/noise_sources.py — new generate_noise_sample()
  • nqr_snn/data/generator.py — uses noise helper, removes SNR tautology
  • nqr_snn/data/dataset.py — uses denoise helper
  • nqr_snn/denoising/__init__.py — new denoise_signal() + denoise_batch()
  • nqr_snn/denoising/selector.py — uses denoise helper
  • nqr_snn/snn/train.py — saves encoder, early stops on accuracy
  • nqr_snn/snn/ensemble.py — loads encoder, uses LearnableTemporalEncoder
  • nqr_snn/inference.py — uses LearnableTemporalEncoder
  • run_full_pipeline.py — wires search→ensemble, uses denoise helper, uses ensemble encoder

Net Effect

  • ~217 lines added (new helpers, encoder save/load, search→ensemble wiring)
  • ~141 lines removed (duplicated noise/denoising code, tautological verification)
  • All existing tests pass. Backward compatible with legacy checkpoints.
KD099 changed pull request status to open
Cannot merge
This branch has merge conflicts in the following files:
  • nqr_snn/config.py
  • nqr_snn/data/dataset.py
  • nqr_snn/data/generator.py
  • nqr_snn/inference.py
  • nqr_snn/snn/ensemble.py
  • nqr_snn/snn/train.py
  • run_full_pipeline.py

Sign up or log in to comment