This changelog outlines the changes made from v3 to v4 in:
espi_dncnn_lite_eca_FULL_PATCH_v4.py
and explains why these changes are expected to improve the model's behavior.
- Added CLI flags:
--use-eca--no-eca
- Added
use_ecato the config (DnCNNLiteECAConfig) and runtime args. - During model construction, when
use_eca=False, all attention blocks are replaced with identity mappings.
- Provides a true A/B comparison without having to switch scripts or architecture families.
- Fair comparison between ECA and no-ECA.
- Fewer "artifact" discrepancies caused by running entirely different scripts.
- Added
--gn-groupsflag. - New helper function
make_norm_with_groups(...):gn_groups=0-> auto mode (tests 8/4/2/1 divisors)gn_groups>0-> explicitly selects the largest valid divisor.
- The
ConvBlocknow acceptsgn_groups.
- Group Normalization (GN) strongly affects attention and activation dynamics.
- We require a controlled parameter sweep rather than hard-coded behavior.
- More stable training.
- Potential improvements in SSIM/EdgeF1 on challenging samples.
run_epoch_train(...)was rewritten to:- Check for finite inputs/loss/gradients.
- Skip bad batches (
nan_action=skip) or halt completely (nan_action=stop). - Track non-finite occurrences.
- Return structured statistics.
- Added arguments:
--nan-action {skip,stop}--max-nonfinite-batches--grad-clip--log-grad-norm
- Previous runs experienced NaN collapses starting as early as epoch 2.
- Without these guards, misleading logs and corrupted checkpoints are saved.
- Run stability and reliability.
- Immediate fail-fast behavior when something goes wrong.
run_validation_fullres(...)now:- Checks for finite inputs/loss/metrics.
- Tracks
samples_seen/samples_used/nonfinite_batches. - Returns a dictionary containing metrics and counters.
run_real_evaluation(...)now:- Skips non-finite samples.
- Returns
usedandskippedcounts.
- Validation is the source of truth for model selection.
- It is critical to know if a metric was derived from a complete or a "broken" validation pass.
- Cleaner and more accurate selection of the best checkpoint.
- Better diagnostics when outliers or instabilities occur.
- Added flags:
--resume-strict(default)--resume-nonstrict
- Resuming a model now loads strictly by default.
- In strict mode, a mismatch causes a hard error (instead of silently proceeding).
- Non-strict loading frequently obscures architecture mismatches.
- It causes subtle, "sneaky" errors during evaluation.
- Consistent resume behavior.
- Fewer pseudo-results caused by partially matched checkpoints.
- New columns in
train_log.csv:train_nonfinite,val_nonfinitetrain_batches,val_samplesgrad_norm
- New TensorBoard scalars:
debug/train_nonfinitedebug/val_nonfiniteopt/grad_norm_mean
- The v3 logs were insufficient for explaining why a run degraded.
- Rapid root-cause analysis.
- More reliable experiment tracking.
--freeze-norm-epochdefault value changed from3to0.
- For fair ablation studies, we prefer initial tests without early freezing.
- Premature freezing can hinder layer adaptation.
- Clearer conclusions regarding the impact of ECA and GN.
bestandbest_ssimmetric updates are only executed when the validation metrics are finite.
- Prevents saving a "best model" derived from a corrupted validation state.
- More valid and robust final checkpoints.
| Change | Primary Benefit | Expected Result |
|---|---|---|
--no-eca / --use-eca |
Fair ablation | Clean comparison of ECA vs baseline |
--gn-groups |
Norm control | Better tuning for SSIM/EdgeF1 |
| Non-finite guards | Stability | Fewer NaN collapse runs |
| Strict resume | Correctness | Fewer checkpoint mismatch errors |
| Expanded logs | Observability | Faster debugging and reproducibility |
| Default no freeze | Fairness | More honest initial A/B results |
Version 4 is primarily a reliability and fairness upgrade, not a "magical" architectural leap.
Realistically, the difference (ECA vs noECA) after proper tuning is expected to be:
dPSNR: approximately-0.10to+0.30dBdSSIM: approximately-0.01to+0.03dEdgeF1: approximately+0.005to+0.03
The greatest advantage of v4:
- The results obtained will be significantly more reliable and reproducible.