A standard assumption in deep learning is that the inductive bias introduced by a neural network architecture must persist from training through inference. The architecture you train with is the architecture you deploy. This assumption constrains the community from selecting architectures that may have desirable efficiency or design properties due to difficulties with optimization. We challenge this assumption with the Network of Theseus (NoT), a method for progressively converting a trained, or even untrained, guide network architecture part-by-part into an entirely different target network architecture while preserving the performance of the guide network. At each stage, components in the guide network architecture are incrementally replaced with the target architecture modules and aligned via representational similarity metrics. This procedure preserves most of the functionality of the guide network even under substantial architectural changes-for example, converting a convolutional network into a multilayer perceptron, or GPT-2 into a recurrent neural network. By decoupling optimization from deployment, NoT expands the space of viable inference-time architectures, opening opportunities for better accuracy-efficiency tradeoffs and enabling more directed exploration of the architectural design space.
Figures & tables
Figure 1: Network of Theseus . A network can be converted to any desired target network by replacing each piece of the original network incrementally, part-by-part. Each original part is replaced by optimizing the representational alignment, ℓSIM , of the target part to the original part. After all original parts are replaced, only the target network remains and can be trained on any downstream task (i.e. standard training).
Figure 2: Alternative replacement schedules : Sequential freezes earlier replacements. Independent fits each layer using guide inputs. Joint trains all target layers at once.
Figure 3: NoT makes any-to-any architecture conversion possible. Without the requirement of functional intermediate models, the target network can be any architecture. For instance, we convert the deeper ResNet-50 to the shallower ResNet-18. Blue squares are a set of multiple ResNet-50 blocks. These are replaced with a single ResNet-18 block. ResNet-18 blocks are added until we have a full ResNet-18 network.
Figure 4: Progressive layer replacement preserves performance. Across patches, NoT aligns each replacement before finetuning the hybrid network, far exceeding naive replacement. Forward and reverse replacement perform similarly, and D-MNN is consistent with CKA in ResNet-18 → MLP.
Original (Guide) → Target
Similarity Metric
Guide
NoT
Baseline
ImageNet Top-1 Accuracy ( ↑ )
ResNet-18 → MLP
CKA
69.66
62.12 ± 0.42 ( ↑ 22.11)
40.01 ± 1.44
ResNet-18 → MLP
D-MNN
69.66
60.28 ± 0.39 ( ↑ 20.27)
40.01 ± 1.44
DINOv2 → Patch-MLP
CKA
81.03
72.56 ± 0.20 ( ↑ 3.84)
68.72 ± 0.55
DINOv2 → Patch-MLP
D-MNN
81.03
73.02 ± 0.84 ( ↑ 4.30)
68.72 ± 0.55
ResNet-50 → ResNet-18
CKA
76.13
73.81 ± 0.26 ( ↑ 4.91)
68.90 ± 0.33
Table 1: Network of Theseus vastly improves over naive replacement and preserves performance . We compare NoT with a FLOP-matched standard training and the original guide network performance. We find that NoT vastly outperforms naive replacement, close to 25% on ImageNet and 70 points on Wikitext-103.
Original → Target
Similarity Metric
Guide
Baseline
Trained
Untrained
ImageNet Top-1 Accuracy ( ↑ )
ResNet-18 → MLP
CKA
62.12 ± 0.42
60.85 ± 0.48
40.01 ± 1.44
ResNet-18 → MLP
D-MNN
60.28 ± 0.39
60.90 ± 0.69
40.01 ± 1.44
DINOv2 → Patch-MLP
CKA
72.56 ± 0.20
70.39 ± 0.25
68.72 ± 0.55
DINOv2 → Patch-MLP
D-MNN
73.02 ± 0.84
68.15 ± 0.96
68.72 ± 0.55
Table 3: NoT with untrained guide networks improves over naive replacement . Can we apply NoT with untrained guide networks to transfer inductive bias? We find that untrained guide networks contain useful inductive biases and can improve over naive replacement with no alignment, given by baseline. NoT with untrained guide networks is competitive with NoT with trained guide networks.
Figure 5: Representational similarity across stages reveals difficult layers : (left) We show CKA similarity losses (log-scaled) across all stages of progressive replacement. We see that CKA loss decreases across all stages for all layers. (right) We plot the final CKA loss for the last stage across all layers. We can identify bottleneck layers that are more difficult to align. Specifically, layers 6, 8, 13, and the final layers have higher loss. Layers 6, 8, and 13 are associated with downsampling in ResNet-18.
Figure 6: NoT performance improves with larger CKA and larger ranks : We compare final task performance of the ResNet-18 → MLP setting over different final CKA alignment scores (left) and linear layer ranks (right). We find that stronger average alignment for the final stage leads to better performance. Similarly, larger rank leads to better loss and stronger task performance.
Appendix figures & tables7 assets
Supplementary material from the paper’s appendix.
Appendix
Figure 7: Biased CKA inflated similarity scores between GPT-2 Small and GPT-2 Large. When plotting values in the Gram matrices of a random pair of layers from GPT-2 Small and GPT-2 Large, we find that the Gram matrix values are very skewed. This is lead by inflated diagonal scores and skewed Gram matrix comparisons. We fix this using an unbiased HSIC estimator.
Figure 8: D-MNN finds similar layer bottlenecks as CKA. We show the per-stage losses for D-MNN, as with CKA. We find that D-MNN is far from saturating unlike CKA, which had loss values closer to 0. We find that D-MNN is also more consistent across layers, indicating that further optimization can be pushed for better alignment in D-MNN. We believe this shows even better correlation between D-MNN and final task accuracy and optimizing D-MNN further may lead to a task accuracy closer to the guide network.
Original (Guide) → Target
Similarity Metric
Guide
NoT
Baseline
ImageNet Top-1 Accuracy ( ↑ )
MLP (Untrained) → ResNet-18
CKA
0.0911
68.06
68.90
MLP (Trained) → ResNet-18
CKA
32.18
67.54
68.90
RNN (Untrained) → ResNet-18
CKA
0.1134
67.22
68.90
ResNet-18 → ResNet-50
CKA
69.66
76.54
76.12
Appendix
Table 6: Network of Theseus is robust to reverse replacement . We can reverse replacement in NoT by converting from an MLP to ResNet-18, converting from an RNN designed for image classification to ResNet-18, or converting from ResNet-18 to ResNet-50. We find that this has little effect on results, indicating that NoT is robust. We emphasize the impact of this finding: we do not find impact on network performance when the original guide network is poorly designed.
Setting
Guide
NoT Target
Distillation Target
Original
ResNet-18 → MLP
69.16
62.55
59.13
40.01
Untrained ResNet-18 → MLP
0.10
60.28
31.11
40.01
GPT-2 → RNN ( ↓ )
37.50
50.58
75.49
119.44
Untrained GPT-2 → RNN ( ↓ )
51948.4
58.26
135.55
119.44
Appendix
Table 7: Progressive distillation : We include a comparison to knowledge distillation as a method for aligning our converted architectures to our original architectures. We progressively convert and distill ResNet-18 into our MLP and GPT-2 into our RNN. We only apply this method for conversion where the guide and target have the same layer shapes to allow propagation to the final logits. We find competitive results with NoT when the guide is trained and much worse results when the guide is untrained. This emphasizes that NoT can exploit untrained networks.
Original
NoT (Trained-EMA)
NoT (Trained-Original)
ResNet-18 → MLP
69.66
60.96
62.12
DINOv2 → Patch-MLP
81.03
71.45
72.56
GPT-2 → RNN
37.50
48.60
50.58
Appendix
Table 8: Automating NoT with EMA and new learning rate schedulers : We automate NoT by tuning the learning rate and stopping criterion with an EMA-based scheduler.
Figure 9: DINOv2 has simple attention maps : We visualize attention maps for DINOv2 over a set of ImageNet images to better understand how we are able to remove cross-token communication via NoT. We find attention is fairly sparse in DINOv2, when focusing on image classification.
Figure 10: Temperature Variations across D-MNN : We analyze how D-MNN similarity loss varies across different temperature values from 0.5 to 10.0. We see that close temperature values like 0.5 to 2.0 have similarity loss. As we increase similarity we see worse similarity.
School of Computer and Data Science, Fuzhou University · School of Computer and Data Science, Minjiang University · School of Artificial Intelligence, Nanchang University +2