TSRDA / BASELINES /scripts /paper_gap.py
Dhruv1000's picture
Add BASELINES: code, results, logs, checkpoints, README
d573b62 verified
Raw History Blame Contribute Delete
5.64 kB
"""Our runs at the STCLN paper's OWN hyper-parameters vs the numbers printed in its Table 6.
The paper trains every from-scratch baseline "using the same parameters as our fine-tuning
process" = Adam, lr 1e-4, batch 2, 100 epochs. So lr 1e-4 is the paper-matched setting.
"""
import json, glob, collections
PAPER = {"unet3d": (0.7828, 0.4245, 0.5533), "bclstm": (0.5829, 0.2478, 0.3707), "utae": (0.7804, 0.4777, 0.6046),
"bunetconvlstm": (0.7309, 0.3902, 0.5107), "batrousconvlstm": (0.7571, 0.3987, 0.5306),
"stcln": (0.8942, 0.6448, 0.7574), "stcln_wp": (0.9086, 0.6953, 0.7974)}
LABEL = {"utae": "UTAE", "unet3d": "3D U-Net", "bclstm": "BCLSTM", "bunetconvlstm": "BUnetConvLSTM",
"batrousconvlstm": "BAtrousConvLSTM", "stcln": "STCLN", "stcln_wp": "STCLN_wp"}
REF = {"stcln": "yes (authors' script)", "stcln_wp": "yes (authors' script + released weights)"}
runs = collections.defaultdict(dict)
for f in glob.glob("/home/ubuntu/pro/baselines/results/mtlcc/*/*/result.json"):
r = json.load(open(f)); runs[r["model"]][round(r["lr"], 8)] = r
L = ["| Method | Reference code released? | Paper mIoU | Ours @ paper lr 1e-4 | Ξ” | Ours, best lr on val | Ξ” |", "|---|---|---|---|---|---|---|"]
for m in ("stcln_wp", "stcln", "utae", "unet3d", "batrousconvlstm", "bclstm", "bunetconvlstm"):
d = runs[m]; p = PAPER[m][1]
a = d.get(0.0001); best = max(d.values(), key=lambda r: r["best_val_mIoU"])
am = a["test"]["stcln"]["mIoU"] if a else None; bm = best["test"]["stcln"]["mIoU"]
L.append(f"| {LABEL[m]} | {REF.get(m, 'no β€” re-implemented by the authors, never released')} | {p:.4f} | "
+ (f"{am:.4f} | {am-p:+.4f} | " if am else "– | – | ")
+ f"{bm:.4f} (lr {best['lr']:g}) | {bm-p:+.4f} |")
md = """# Why our MTLCC baseline numbers differ from the STCLN paper's Table 6
**Short answer: for the only method whose reference code exists we match it exactly; for the
others no reference code was ever released, so an exact match is not achievable in principle.**
## 1. What the STCLN repository actually contains
`github.com/XiaoleiQinn/STCLN` (commit ce405c8) ships **only STCLN itself**:
```
MTLCC/ STCLN.py pretraining_STCLN.py finetuning_STCLN.py test_STCLN.py logger.py
PASTIS/ STCLN.py pretraining_STCLN.py finetuning_STCLN.py test_STCLN.py logger.py
```
There is **no code for 3D U-Net, BCLSTM, UTAE, BUnetConvLSTM, BAtrousConvLSTM, U-BARN,
SITS-Former or SITS-MoCo**. Those rows of Table 6 come from the authors' own
re-implementations, which were not published. We therefore took each method from **its own
authors' repository** and ported it where needed. Two different re-implementations of the same
paper do not give the same number β€” that is the whole of the discrepancy for those rows.
## 2. The paper's own training setting for the baselines
Section 4.2: *"For 3D U-Net, BCLSTM, UTAE, BUnetConvLSTM, BAtrousConvLSTM, we train them from
scratch using the same parameters as our fine-tuning process."* The fine-tuning setting is
Adam, **lr 1e-4, batch 2, 100 epochs** (`finetuning_STCLN.py` argparse defaults). So the
paper-matched column below is our lr 1e-4 run, not our validation-selected one.
## 3. The comparison
""" + "\n".join(L) + """
## 4. Reading of the table
* **STCLN_wp reproduces exactly (0.6953 vs 0.6953) and STCLN to within 0.006.** These are the
two methods whose code we could actually run. This validates the data loader, the tile
lists, the 30-of-36 date sampling, the fine-tuning protocol and the metric implementation β€”
everything shared by all the other rows.
* **UTAE at the paper's lr is within +0.011**, i.e. essentially reproduced, since we use
VSainteuf's original UTAE implementation.
* **3D U-Net +0.048, BCLSTM +0.123, BAtrousConvLSTM +0.122 β€” ours are better.** These are the
three models the paper's authors had to re-implement most heavily (a TensorFlow-1 graph and
two Keras graphs). Our versions come from the original authors' repositories with
parameter-count parity checks, and our training uses AMP and a modern PyTorch. A baseline
being *stronger* than published does not invalidate the comparison; it makes it harder for
T-SRDA, not easier.
* **BUnetConvLSTM βˆ’0.152 β€” ours is worse, and this one is worth a second look.** The name
exists in two forms in the original authors' code: an N-to-1 form (`osss-mcr`) and a
seq2seq form (`FCN_ConvLSTM...`). We used the N-to-1 form. If the paper used the seq2seq
form, that would explain the gap. This is an open item, not an explained one.
## 5. Residual causes that apply to every row
1. **Date sampling.** 30 of the ~36 dates are drawn at random. The reference implementation
re-draws at every validation/test call; we fix the draw per tile so scores are
reproducible. Different draws, different numbers.
2. **Single seed** (3407) on both sides; the paper reports no error bars.
3. **Hardware/batching.** The paper used 4x RTX 3090; batch composition and any data-parallel
effects differ from our single-GPU runs.
4. **Precision.** We fine-tune with mixed precision; the reference script is fp32.
## 6. Conclusion
Where the comparison can be made exactly, it matches exactly. Where it cannot, the cause is
the absence of released baseline code, not a protocol error on our side. The honest way to
report this β€” and the way the manuscript now does β€” is to give both columns: our numbers under
the paper's own hyper-parameters, and our numbers at each baseline's validation-selected
learning rate.
"""
open("/home/ubuntu/pro/baselines/results/mtlcc/paper_comparison.md", "w").write(md)
print(md)