Skip to content

ApartsinProjects/CalexNet

Repository files navigation

CalexNet

CalexNet cascade: a CNN backbone with three early-exit branches; easy samples exit at branch 1, harder samples flow deeper, and only a thin residual reaches the backbone.

CalexNet: Soft Cascade-Aligned Training and Calibration for Lightweight Early-Exit Branches Y. Aperstein, A. Apartsin

This repository is the publishable companion to the CalexNet paper. It contains the full source code, the trained backbones (downloadable from a GitHub Release), every result JSON used to render every paper figure and table, the rendered paper itself, and the scripts that regenerate each figure and table from the result JSONs.

The paper introduces a training-recipe-only modification to the post-training early-exit pipeline that closes three sources of train-inference mismatch in CNN cascades:

  1. cascade-aligned importance weighting (Eq. 13) so each branch trains on the survivor distribution it will see at inference;
  2. cascade-aware CPM calibration (Eq. 8) so per-class precision thresholds are estimated on the survivor subset, not the full validation set;
  3. a distilled classification target (Eq. 10) against the backbone's full softmax with temperature T = 4.

CalexNet matches or improves the accuracy-FLOPs Pareto frontier over three published baselines (PTEEnet, ZTW, BoostNet) and a within-paper "no alignment, no KD" reference on ResNet18 / ResNet50 × CIFAR-100 coarse / CINIC-10.


Repository map

Directory Contents
paper/ The rendered paper (paper.html), its figure assets, and the MDPI Electronics Word template.
src/calexnet/ The Python package: backbone loaders, branch heads, CPM calibration, the cascade-aligned recipe, baselines (PTEEnet, ZTW, BoostNet), latency/energy metrics. MIT.
modal/ Cloud entrypoints for training and large-scale evaluation on Modal.
analysis/ Scripts that regenerate each paper figure and table from the result JSONs. One script → one paper artefact.
data/ Static visualisation data: per-sample exit exemplars used by Figure A2.1, design-iteration data for layout exploration.
checkpoints/ Backbone weights (ResNet18 + ResNet50 × CIFAR-100 coarse + CINIC-10). Distributed via GitHub Release; download with analysis/download_checkpoints.py.
results/ All measured result JSONs the paper figures read (~790 files). Tiny — under 4 MB total.
examples/ Runnable demos. inference.py loads the canonical branch bundle and runs Algorithm 1 on a CIFAR-100 image.
docs/ Reproduction recipe, architecture overview, result-filename grammar.
configs.py Global hyperparameters (margins, branch attach points, K).

Each subdirectory has its own README.md with detail on what's in it and how to use it.


Quickstart

# 1. Clone and install
git clone https://github.com/ApartsinProjects/CalexNet
cd CalexNet
pip install -e .              # core package
pip install -e ".[modal]"     # add cloud deps if you want to retrain

# 2. Download checkpoints (backbones ~266 MB + canonical branch bundle ~150 KB)
python analysis/download_checkpoints.py

# 3a. Run the cascade on a single CIFAR-100 image (uses the canonical branch bundle)
python examples/inference.py --idx 42

# 3b. Or regenerate any paper figure or table from the cached result JSONs
python analysis/plot_pareto.py        # body Figures 1, 2 (Pareto)
python analysis/summary_table.py      # body Tables 4, 5 (accuracy loss)
python analysis/render_figA2.py       # appendix Figure A2.1
python analysis/compute_shift.py      # Table A6.1 (KL / Gini)
python analysis/compute_ece.py        # Table A5.1 (ECE)
python analysis/ablation_table.py     # Table A4.1 (component ablation)
python analysis/latency_amortise.py   # Tables A3.1 + A3.2 (latency + crossover)

Re-running the entire experimental sweep (rather than regenerating figures from cached JSONs) requires Modal credentials and ~50–80 GPU-hours; see docs/REPRODUCE.md.


Citation

@article{aperstein2026calexnet,
  title   = {CalexNet: Soft Cascade-Aligned Training and Calibration
             for Lightweight Early-Exit Branches},
  author  = {Aperstein, Y. and Apartsin, A.},
  year    = {2026},
}

A CITATION.cff is provided for tools that consume it (GitHub's "Cite this repository" button, Zenodo, etc.).


Licensing

  • Code (src/, modal/, analysis/, configs.py, helper scripts) is licensed under the MIT License; see LICENSE.
  • Paper text and figures under paper/ are released under CC-BY-4.0 (Creative Commons Attribution 4.0).
  • The MDPI Word template under paper/templates/ is property of MDPI and is included only for reference under MDPI's terms of use.

Contributing

This repository is the publication artefact for a peer-reviewed paper and is maintained primarily as a reproducibility record rather than an actively-developed library. Issues that report reproducibility problems are very welcome; pull requests that change the recipe or the numerical results will not be merged unless the change is needed to fix a reproducibility regression.

About

CalexNet: Soft Cascade-Aligned Training and Calibration for Lightweight Early-Exit Branches. Companion repo for the paper (Aperstein & Apartsin, 2026).

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors