multigeom.pipeline.alignment#
Stage 5: Aggregate cross-(encoder, area) similarity metrics from the per-image G(x) and J(x) eigendecompositions written by Stage 4.
For every unordered pair of (encoder, area) configurations, for both metrics
(G = multi-scale Fisher, J = Fisher), and on every image the two share, we
compute as a function of k = 1, ..., max_k:
- the subspace alignment 𝒜_k = (1/k)‖V_Aᵀ V_B‖_F² (Fig. 4D-E;
same definition as multigeom.analysis.subspace_alignment)
- the Bures-Wasserstein distance d_BW between the rank-k
reconstructions V Λ Vᵀ of the two metrics (appendix BW figure)
and report the mean and s.e.m. across images.
The paper compares models fitted to the same area ("cross_model") with the
same model fitted to different areas ("cross_area"). Those comparisons are
also listed under named keys in the output, e.g.
cross_model_V1_inception_resnet50, cross_area_inception
Output: <out_dir>/cross_encoder_metrics.json
Usage:
python -m multigeom.pipeline.alignment --runs-dir runs --out-dir runs/metrics
Functions
|
Alignment and Bures-Wasserstein curves for k = 1..K over shared images. |
|
Run the alignment (the former stage 5: alignment and Bures-Wasserstein distance between every pair of configurations, over the images they share). |
|
The (encoder, area) configurations that have per-image files under runs_dir. |
|
(encoder, area) pairs with at least one per-image file, in a fixed order. |
|
What Stage 5 would work on: per configuration the indices of its per-image files, and per pair of configurations the number of shared images (the alignment and distance are averaged over those). |
|
Read a metrics file written by compute_metrics. |
|
Load every img{N}.pt for one (encoder, area), keyed by image index. |
|
Compare every pair of configurations and write the metrics file (command-line entry point). |
|
The paper's comparisons: same model across areas, same area across models. |
|
The mean over k of d_BW for the two cross-model comparisons (V1, V4) and the two cross-area ones (Inception, ResNet-50), per metric, and whether the ordering is the paper's (G: cross-model below cross-area; J: reversed). |
|
Name of the comparison of two (encoder, area) configurations for one metric (G or J). |
|
Command-line arguments of python -m multigeom.pipeline.alignment. |
|
Print the images per configuration and warn when there are fewer than the paper's 200. |
|
Print, for G and for J, the mean Bures-Wasserstein distance of the cross-model and the cross-area comparisons and whether their order is the paper's (G: cross-model below cross-area; J: above). |