Linear Calibration Ranking
Use this skill when a recovery or evaluation needs to apply or fit the LPIPS paper's shallow human-judgment calibration over per-layer distances.
Do not use it to train or fine-tune a trunk network. This skill updates only calibration weights.
Inputs
- Items with
layers0,layers1, andjudge. layers0andlayers1are equal-length lists of per-layer distances forref-p0andref-p1.judge = 0meansp0should score closer;judge = 1meansp1should score closer.- Optional initial weights, step count, and learning rate.
Outputs
- Non-negative calibrated weights.
- Loss/accuracy before and after calibration.
params_beforeandparams_afterfor recovery validation.
Workflow
- Validate layer vectors and labels.
- Score each candidate by weighted layer-distance sum.
- Compute logistic ranking loss over
score0 - score1. - Run bounded gradient steps on calibration weights.
- Project weights to non-negative values after each step.
- Emit a trace with before/after loss, accuracy, and weights.
Validation
Run:
python scripts/calibrate_ranking.py --self-test
python tests/test_calibrate_ranking.py
Limitations
The script is intentionally small and deterministic. It is suitable for reduced recovery and unit tests, not full-scale LPIPS training.