Simulation-pretrained autoencoders versus PCA for compressing multimode fibre transmission matrices
Authors: Callum J. Wilson, Terry Wright, Qing Yang, Zhong Wen, Michael P. Pound, George S. D. Gordon
Organizations: OPTIMlab, Department of Chemical Engineering and Biotechnology, University of Cambridge, United Kingdom · State Key Laboratory of Modern Optical Instrumentation, Department of Optical Engineering, Zhejiang University, Hangzhou, China · School of Computer Science, University of Nottingham, United Kingdom
Multimode optical fibres can image through a thin, flexible probe once their transmission matrix (TM) has been measured, but a TM is large and must be re-measured whenever the fibre moves. A compact model of feasible TMs would make storing and re-estimating them cheaper, so we ask how compactly TMs can be represented, and from how few measured TMs. Here we benchmark a permutation-equivariant autoencoder, pretrained on simulated fibres and adapted to measured TMs, against principal component analysis (PCA). At 62x compression, adapting the pretrained autoencoder with just two measured TMs reconstructs the TM of a 50um fibre well enough to focus light at 98% of the ideal enhancement, and it stays accurate when the TMs are shifted by 25 pixels or zoomed by 10%, which quickly degrades a linear basis. It is not, however, a better compressor: PCA is about ten times more accurate when fitted on all 163 real TMs (1.1% against 11.9% error on held-out TMs) and is already more accurate from ten. The autoencoder's value is as a prior when few or no real TMs exist: with none it reaches 29% error, against 91% for PCA fitted on the same simulation. Transfer to a different fibre is only partial. The most important extension, not yet tested, is to recover pixel-basis TMs from fewer measurements than a full TM, which would turn the pretrained prior from a compressor into a measurement-saving tool.
Figures & tables
Figure 1: Autoencoder architecture. A TM of shape [B,2,145,205,205] (batch, real and imaginary channels, input pattern, output image) is padded to 208×208 , and each of its 145 speckle images is processed independently with shared weights. Encoder (left and bottom): three 2D convolutional layers reduce each image to C feature maps of 13×13 . Channel self-attention (top, one head shown) then treats the C channels as the sequence and the flattened 13×13=169 positions as the embedding. As in the Linformer [ 22 ] , the keys and values are linearly projected from C to k channels, which shortens the sequence and reduces the attention matrix from C×C to C×k , and the attention output is added to its input (residual connection). A linear layer across channels then reduces C to the latent channel count, giving a latent of shape [145,8,13,13] at 62 × compression (4 channels at 124 × ). Decoder (right): a linear layer across channels and three 2D convolutional layers restore the 208×208 image, which is cropped to 205×205 . The decoder is not a mirror of the encoder and contains no attention, so decoding is fast. There are no skip connections between the encoder and decoder. Channel widths, k and the number of heads are given in Methods.
Figure 2: Validation error against compression ratio on the original experimental TMs. Lines: PCA fitted on 163 or 10 experimental TMs, or on 163 simulated TMs; the dotted vertical line marks 772 reals (the 386 simulated modes). Diamonds: autoencoder trained from scratch on the 163 experimental training TMs, mean ± SD of the converged seeds, labelled with the number of converged seeds out of 5 (the 83 × point is a single run, so has no SD; at 124 × no seed converged and the cross is the mean of all seeds). Only 2,538 PCA components rise above the float32 noise floor, so the PCA curves end at around 33 × . Per-seed autoencoder results are in Supplementary Table S3 .
Experimental TMs used
1
2
3
5
10
25
163
62 × validation error (%)
89.5
65.6
52.4
25.3
1.7
1.3
0.8
Table 1: PCA performance on experimental TMs when using varying number of TMs to fit the model.
Validation error (%) [Complex correlation]
Dataset used to fit PCA
Experimental
Simulated
163 exp TMs
0.77 [1.00]
38.48 [0.90]
163 simulated composite-5m TMs
90.78 [0.42]
10.28 [0.99]
Table 2: PCA fitted on one domain does not transfer to the other as well, especially in the case of fitting PCA on simulated data and evaluating on experimental.
Validation error (%)
N. training TMs
Seeds converged
Converged avg. ± SD
All-seed avg. ± SD
100
0/5
n/a
100.89±1.50
125
0/5
n/a
100.57±0.55
150
2/5
13.59±0.76
65.65±47.53
163
4/5
15.70±2.00
32.64±37.93
Table 3: Autoencoder experimental-only data scaling study, with fixed compression rate of 62 × (the 163-TM row is the same runs as the 62 × point of Figure 2 ). A 25-TM run also failed in all five seeds; full results can be found in Supplementary Table S4 .
1 m
5 m
Attempts
51
200
Kept TMs (cond. < 250)
10 (20%)
1 (0.5%)
Time per attempt
∼ 26 s
∼ 124 s
Total time
0.37 h
6.89 h
Median condition number of attempts
1.2×1014
5.6×1034
SVD failures (NaN/Inf)
0
3
Table 4: Comparing simulator performance when generating TMs for 1m and 5m fibres.
Figure 3: Effect of the simulated pretraining data on validation error at 124 × compression. Left: error of the pretrained model before fine-tuning. Right: error after fine-tuning on all 163 experimental training TMs. Lines show the mean and dots the individual seeds (3 seeds), against the number of simulated training TMs. Series: 1 m simulated TMs with early stopping on simulated validation TMs; 5 m composite TMs with early stopping on simulated validation TMs; 5 m composite TMs with early stopping on the 20 experimental validation TMs. Failed runs stay near 100% error. Per-seed values and standard deviations are in Supplementary Tables S5 – S7 .
Figure 4: Validation error of the simulation-pretrained autoencoder (5 m composite pretraining) after fine-tuning on N experimental TMs, at 124 × and 62 × compression. N=0 is the pretrained model before fine-tuning. Early stopping on the 20 experimental validation TMs; baseline configuration, 3 seeds. Values are in Supplementary Tables S8 and S9 .
Average validation error ± SD (%)
Model type
N=0
N=5
N=10
N=163
AE finetuned
28.41±0.79
14.79±0.58
13.43±0.18
11.59±0.23
AE, exp. only, all runs
-
106.73±3.95
106.88±7.18
49.73±46.49
AE, exp. only, converged runs
-
none (0/5)
none (0/5)
15.79±1.71 (3/5)
PCA, sim. fit
90.78
-
-
-
PCA, exp. fit
-
25.32 †
1.68
0.77
Table 5: Autoencoder (AE) versus PCA at 62 × compression on the original experimental TMs (validation set). N is the number of experimental TMs used to fine-tune the simulation-pretrained AE ( N=0 : pretrained only, no fine-tuning), to train the AE from scratch (exp. only; “converged” runs have validation error below 90%), or to fit PCA (exp. fit); PCA sim. fit uses 163 simulated TMs. AE entries are mean ± SD over five seeds and PCA entries are single deterministic fits. The AE checkpoint was chosen using the 20 validation TMs, so AE values are optimistic. Full results can be found in Supplementary Table S10 . † Rank-limited to 724 components.
Average validation error ± SD (%)
Model
N=0
N=5
N=10
N=163
Raw second-fibre TMs
AE fine-tuned
59.04±0.30
62.13±0.68
62.86±0.57
62.62±0.35
AE exp-only
-
-
-
77.63±20.63
PCA fitted on simulation
92.43
-
-
-
PCA fitted on original TMs
-
-
-
54.62
Table 6: Zero-shot transfer to the second fibre (second-fibre validation TMs, 62 × compression): nothing is refitted on the second-fibre data. AE = autoencoder; N is the number of original-fibre experimental TMs used to fine-tune the simulation-pretrained AE ( N=0 : pretrained only) or to fit PCA. AE entries are mean ± SD over five seeds (the exp-only mean includes two failed seeds) and PCA entries are single fits. For reference, PCA fitted on the second fibre’s own 131 training TMs reaches 39.12% (raw) and 7.02% (band-limited), the best a 62 × linear model can do on these data. Per-seed values in Supplementary Table S11 .
Figure 5: Few-shot calibration on the second fibre at 62 × compression (second-fibre validation TMs). Left: raw TMs; right: band-limited TMs (15 cycles/frame). Autoencoder: the simulation-pretrained model fine-tuned on N second-fibre TMs ( N=0 : no fine-tuning), mean ± SD over five seeds, checkpoint chosen on the second-fibre validation TMs. PCA: fitted on the same N TMs (single fits), with the simulation-fitted PCA at N=0 . “All” is the 131 second-fibre training TMs. Full results in Supplementary Table S12 .
Figure 6: One shared model for both fibres versus a specialist per fibre at 62 × compression (validation TMs). Shared models are fine-tuned on N TMs from each fibre ( 2N in total) and specialists on N TMs of the fibre being scored; N=0 is the simulation-pretrained model, and “all” is 131 TMs per fibre (163 for the original-fibre specialist). Autoencoder: mean ± SD over five seeds, checkpoint chosen on the validation TMs; PCA: single fits. Full results in Supplementary Table S13 .
Autoencoder
PCA
Training TMs
Original (21 TMs)
Second fibre (17 TMs)
Original (21 TMs)
Second fibre (17 TMs)
None (simulation only)
29.20
63.05
90.79
92.94
2 original
14.55
67.15
66.67
89.57
2 second-fibre
29.21
56.71
92.03
93.02
Shared, 1+1
18.38
61.07
81.45
89.33
163 original
11.94
67.10
1.08
59.06
Table 7: Final test results: error (%) on the held-out test TMs of each fibre at 62 × compression, evaluated once after all models were frozen. Autoencoder entries are single models (seed 42) and PCA entries are single deterministic fits; no model was chosen using these numbers. “Specialist” models use TMs of one fibre only, “shared” models use the stated number from each fibre, and the autoencoder checkpoints were selected on validation TMs.
Figure 7: Test error under perturbation of the TMs before reconstruction, at 62 × compression (21 original-fibre test TMs, seed 42). Shift is in pixels of the 205×205 output grid, zoom is a scale factor, rotation is in degrees, blur is the Gaussian σ in pixels and noise is a fraction of the RMS. Each autoencoder is a single model and PCA is a single fit. Error is measured against the perturbed TM.
Figure 8: Focusing and imaging through reconstructed TMs for the target “F” (frozen test split, 62 × compression). Rows: the first test TM of the original fibre and of the second fibre, the same for every model. Columns: target; ideal (the true TM, the best possible with 145 inputs); PCA fitted on 163 simulated TMs; autoencoder pretrained on simulation only; PCA fitted on two TMs of the fibre shown; PCA fitted on one TM from each fibre; autoencoder specialist (two TMs of the fibre shown); shared autoencoder (one TM from each fibre). The input is found from the reconstructed TM and applied to the true TM. Under each panel: mean focus enhancement as a percentage of the ideal and mean SSIM over all test TMs of that fibre (21 original, 17 second fibre).
Figure 9: As Figure 8 , for the target of a ring.
Model
Frozen during fine-tuning
PT sim
PT exp
FT sim
FT exp
Full attention
enc, to_latent, channel_attn
37.31
68.31
382.49
52.98
enc, to_latent
312.78
52.53
none
519.30
44.56
Coarse (Linformer) attention
enc, to_latent, channel_attn
35.76
70.81
792.54
52.85
enc, to_latent
1223.04
52.26
none
412.66
45.26
Table S1: Preliminary comparison of attention variants on smaller 256×256 TMs, run before the experimental data were collected; each model was tuned with 50 Optuna trials. PT = pretrained on simulated TMs; FT = after fine-tuning on experimental TMs; “sim” and “exp” give the phase-aligned error (%) on simulated and experimental validation TMs. FT exp is the metric of interest; FT sim is not, since the model moves away from the simulated data when fine-tuned. Freezing layers affects only the FT columns. Single runs.
Validation error (%)
Model (latent shape per speckle)
Latent reals
Pretrained
Fine-tuned
Two-channel, 16×13×13 (real)
2,704
258.13
7.47
Complex-valued, 16×13×13 (complex)
5,408
34.70
13.13
Complex-valued, 8×13×13 (complex)
2,704
111.78
101.20
Table S2: Preliminary comparison of a complex-valued and a two-channel autoencoder with the same structure (channel attention, 2D convolutional encoder, residual attention) on the pixel-basis TMs, scored on the experimental validation TMs after pretraining on simulated TMs and after fine-tuning on experimental TMs. A complex latent value counts as two real numbers, so the two-channel model with 16 real channels (about 31 × compression) is matched in latent size by the complex model with 8 complex channels, and the complex model with 16 channels has twice the latent size (about 15.5 × ). The complex model uses complex weights with a modReLU activation. The relative error is not bounded by 100%, so values above 100% are possible. Single runs under an earlier protocol.
Figure S1 : Full channel-attention autoencoder from the preliminary tests on 256×256 TMs: each speckle is passed through a 2D convolutional encoder, channel self-attention with a residual connection, a linear layer to the latent code, an upscaling linear layer, plus a 2D convolutional decoder. The inset shows the pretraining and fine-tuning procedure.
Figure S2 : Coarse (Linformer-style) channel attention: as in the previous figure, but the keys and values are linearly projected from 112 channels to 14 before the attention product, which reduces the attention matrix from 112×112 to 112×14 . The model was tuned separately, so its channel count differs from the full-attention model.
Figure S3 : One-dimensional convolutional variant with coarse attention: each speckle is flattened to a 256-element vector and encoded with 1D convolutions. This model failed to train in all configurations (Supplementary Table S1).
Figure S4 : Singular values of composite 5 m TMs compared with experimental TMs.
Validation error (%)
Compression rate
Seeds converged
Converged avg. ± SD
All-seed avg. ± SD
seed 42
seed 43
seed 44
seed 45
seed 46
16 ×
2/5
12.03 ± 2.64
64.97 ± 48.35
100.18
13.89
100.15
100.48
10.16
31 ×
2/5
11.62 ± 1.32
64.99 ± 48.73
12.55
10.68
100.50
100.52
100.72
62 ×
4/5
15.70 ± 2.00
32.64 ± 37.93
100.43
14.37
18.67
14.77
14.97
83 ×
1/5
27.22
85.58 ± 32.62
100.08
100.02
27.22
100.15
100.42
124 ×
0/5
n/a
100.27 ± 0.07
100.26
100.24
100.37
100.19
100.31
Table S3: Autoencoder experimental only compression study: per seed results.
Validation error (%)
N. training TMs
Seeds converged
Converged avg. ± SD
All-seed avg. ± SD
seed 42
seed 43
seed 44
seed 45
seed 46
25
0/5
n/a
100.78 ± 0.38
100.74
101.24
100.98
100.76
100.20
100
0/5
n/a
100.89 ± 1.50
103.57
100.36
100.15
100.15
100.22
125
0/5
n/a
100.57 ± 0.55
100.51
100.20
101.53
100.26
100.35
150
2/5
13.59 ± 0.76
65.65 ± 47.53
100.77
14.13
100.13
13.05
100.18
163
4/5
15.70 ± 2.00
32.64 ± 37.93
100.43
14.37
18.67
14.77
14.97
Table S4: Autoencoder experimental-only data scaling study, with fixed compression rate of 62 × : per seed results.
Validation error (%)
N. sim. training TMs
Seed
Zero-shot ± SD
Fine-tuned ± SD
500
Avg.
99.82±0.83
60.03±34.82
42
100.30
100.24
43
98.86
39.73
44
100.29
40.12
1000
Avg.
85.24±20.67
40.34±1.26
Table S5 : Data scaling law for 1 m simulated fibre TMs using autoencoder with 124 × compression: per seed results.
Validation error (%)
N. sim. training TMs
Seed
Zero-shot ± SD
Fine-tuned ± SD
500
Avg.
100.60±0.33
39.58±0.93
42
100.85
40.48
43
100.72
38.63
44
100.22
39.62
1000
Avg.
73.56±23.82
40.15±1.57
Table S6 : Data scaling law for 5 m simulated fibre TMs using autoencoder with 124 × compression: per seed results.
Validation error (%)
N. sim. training TMs
Seed
Zero-shot ± SD
Fine-tuned ± SD
500
Avg.
71.99±24.99
39.66±0.78
42
56.08
40.31
43
59.10
38.80
44
100.79
39.86
1000
Avg.
73.05±24.53
39.65±1.30
Table S7 : Data scaling law for 5 m simulated fibre TMs using autoencoder with 124 × compression. Experimental data used for early stopping: per seed results.
Validation error (%)
N experimental finetuning TMs
Seed
Avg. finetuned error ± SD
Avg. gain vs pretraining ± SD
0
Avg.
59.78±0.50
-
42
59.46
-
43
59.52
-
44
60.36
-
5
Avg.
45.43±1.47
14.35
Table S8 : Finetuning data scaling law for 5 m simulated fibre TMs using autoencoder with 124 × compression. Experimental data used for early stopping and finetuning: per seed results.
Validation error (%)
N experimental finetuning TMs
Seed
Avg. finetuned error ± SD
Avg. gain vs pretraining ± SD
0
Avg.
30.21±0.96
-
42
30.94
-
43
29.12
-
44
30.58
-
5
Avg.
18.36±4.10
11.85
Table S9 : Finetuning data scaling law for 5 m simulated fibre TMs using autoencoder with 62 × compression. Experimental data used for early stopping and finetuning: per seed results.
Average validation error ± SD (%)
Model type
seed
N=0
N=5
N=10
N=163
AE finetuned
Avg.
28.41±0.79
14.79±0.58
13.43±0.18
11.59±0.23
42
28.77
14.44
13.27
11.24
43
27.59
14.49
13.30
11.59
44
27.56
15.30
13.45
11.63
45
29.31
14.21
13.40
11.60
Table S10 : Autoencoder (AE) versus PCA at 62 × compression on the original experimental TMs (validation set). N is the number of experimental TMs used to fine-tune the simulation-pretrained AE ( N=0 : pretrained only, no fine-tuning), to train the AE from scratch (exp. only; “converged” runs have validation error below 90%), or to fit PCA (exp. fit); PCA sim. fit uses 163 simulated TMs. AE entries are mean ± SD over five seeds and PCA entries are single deterministic fits. The AE checkpoint was chosen using the 20 validation TMs, so AE values are optimistic. Per seed results. † Rank-limited to 724 components.
Validation error (%)
Model
seed 42
seed 43
seed 44
seed 45
seed 46
Avg. ± SD
Raw second-fibre TMs
AE sim-pretrained
59.31
58.80
59.28
59.16
58.64
59.04 ± 0.30
AE fine-tuned on 5 original TMs
62.51
62.53
61.50
62.82
61.32
62.13 ± 0.68
AE fine-tuned on 10 original TMs
63.15
63.46
62.82
62.89
61.95
62.86 ± 0.57
AE fine-tuned on 163 original TMs
62.62
62.73
62.07
62.67
63.03
62.62 ± 0.35
Table S11: Zero-shot transfer to the second fibre: per seed results on the second-fibre validation TMs (62 × compression). Nothing is refitted on the second-fibre data, except the in-domain PCA reference in the last row of each block. PCA rows are single deterministic fits, so one value is shown. AE = autoencoder; fine-tuning uses original-fibre TMs only.
AE validation error (%) by seed
N
42
43
44
45
46
AE mean ± SD
PCA
Original TMs (50 μ m)
0
28.77
27.59
27.56
29.31
28.84
28.41±0.79
-
1
19.06
18.87
20.09
18.65
18.95
19.12±0.56
89.50
2
14.33
15.25
15.19
15.27
15.98
15.31±0.42
65.60
3
15.17
16.64
15.34
15.53
16.94
15.92±0.81
52.40
Table S12: Few-shot calibration: validation error (%) of the autoencoder (AE) by seed, with its mean ± SD, and of PCA (a single fit). The simulation-pretrained checkpoint is fine-tuned on the first N TMs of the target dataset and scored on that dataset’s validation TMs; N=0 is the unadapted model, and “all” is every training TM of the dataset (163 original, 131 second fibre). PCA is fitted on the same N TMs at 62 × compression; for N≤5 it is rank-limited. Fine-tuning uses a fresh AdamW optimiser, so values differ slightly from the fine-tuning table in the main text.
AE validation error (%) by seed
N+N
42
43
44
45
46
AE mean ± SD
PCA
Scored on original TMs (50 μ m)
1+1
18.49
18.97
19.14
18.63
18.96
18.84±0.27
82.49
2+2
16.80
17.52
17.32
16.97
18.74
17.47±0.76
58.58
3+3
17.54
17.60
17.81
17.78
18.49
17.84±0.38
42.14
5+5
16.89
17.16
17.11
17.43
17.54
17.22±0.26
21.10
Table S13: One shared model for both fibres: validation error (%) by seed, with mean ± SD, for the autoencoder (AE) and for PCA (a single fit). The simulation-pretrained checkpoint is fine-tuned on the first N original TMs and the first N second-fibre TMs together ( 2N TMs; N=1 uses two TMs), with the checkpoint chosen on the mean of the two validation errors, and is scored on each validation set. The shared PCA is one basis (62 × compression) fitted on the same 2N TMs; it is rank-limited for small N . All uses 131 TMs from each fibre.
Figure S5 : Focusing and imaging through reconstructed TMs for the target of spots (frozen test split, 62 × compression), laid out as the main-text figure for the target “F”. Rows: the first test TM of the original fibre and of the second fibre, the same for every model. Columns: target; ideal (the true TM, the best possible with 145 inputs); PCA fitted on 163 simulated TMs; autoencoder pretrained on simulation only; PCA fitted on two TMs of the fibre shown; PCA fitted on one TM from each fibre; autoencoder specialist (two TMs of the fibre shown); shared autoencoder (one TM from each fibre). Under each panel: mean focus enhancement as a percentage of the ideal and mean SSIM over all test TMs of that fibre (21 original, 17 second fibre).
Autoencoders learn compressed representations by encoding data into latent codes and decoding them for reconstruction, generation, denoising, or anomaly detection.
The multimode fiber is among the thinnest imaging conduits available, carrying hundreds to thousands of spatial modes through a cross-section comparable to a human hair, but its endoscopic capabilities are currently limited by the sensitivity of the transmission matrix to the fiber's deformed state. Proximal-only recovery of the fiber's transmission matrix is an appealing approach for enabling general use multimode fiber endoscopy, and within the last decade, machine learning techniques have been applied to both single-ended and double-ended transmission matrix recovery tasks. We present a new approach to this interdisciplinary problem and show that neural networks can generalize to recover transmission matrices of an arbitrarily deformed graded-index multimode fiber from proximal measurements alone.
Sparse autoencoders (SAEs) compress model activations into sparse codes, but equal reconstruction error and sparsity can preserve different linearly decodable signals. We formalize this ambiguity as a matrix-valued distortion between optimal ridge-prediction operators and train decoder-preserving SAEs by combining this distortion with reconstruction loss. In a rank relaxation, an isotropic task prior saturates per-mode omission costs without changing PCA's ordering, whereas a structured prior can change which modes are retained. A controlled sparse experiment shows that a declared prior protects held-out combinations from its task subspace. On GPT-2 small block 8, DPSAE reduces held-out decoder distortion by 10.6--11.4% across three paired runs while matching reconstruction NMSE. The same checkpoints pass an average natural-text output-KL noninferiority test, but one matched Pythia pair shows no improvement in probes restricted to a few sparse features. These results show that reconstruction quality does not determine which refitted linear readouts survive sparse compression, and that readout preservation is distinct from learning cleaner benchmark concepts or preserving every frozen-model behavior.
Aniket Deshpande
Department of Physics, University of Illinois Urbana-Champaign
Scientific simulations generate collections of physical fields with heterogeneous statistics and dependencies, yet learned compressors often encode those fields independently or rely on a shared encoder without explicitly modeling the structure that remains in latent space. We present CAESAR-LDAR, an error-controlled multivariate learned compressor that augments a shared CAESAR-V backbone with two complementary mechanisms: a trainable orthogonal transform that reorganizes dependence across aligned latent channels, and a causal autoregressive hierarchical prior that captures local spatial structure left after transformation. Orthogonality is maintained through a matrix-exponential parameterization, making the transform exactly invertible without an additional penalty. A common residual-correction stage is applied uniformly to all variants to enforce the requested reconstruction tolerance. Experiments across combustion, climate, and turbulence data show that the two mechanisms are useful in different regimes. Latent decorrelation helps most when substantial linear cross-channel dependence survives the nonlinear encoder, whereas autoregressive modeling remains effective when the remaining structure is primarily local or spatial. Their combination provides the strongest or near-strongest rate-distortion performance across the evaluated datasets. The global transform adds little computational overhead, while autoregressive coding introduces a larger throughput tradeoff. More broadly, the results suggest a practical design principle for multivariate scientific compression: exploit global cross-channel dependence when it is measurably present in latent space, and use local probabilistic context as a complementary mechanism across a wider range of data regimes.
Liangji Zhu, Anand Rangarajan, Sanjay Ranka
Department of Computer & Information Science & Engineering University of Florida Gainesville, FL, USA