FDSML: Formula-Driven Supervised Metric Learning
with Parameter-Aware Triplet Loss

WACV'27
1Waseda University2National Institute of Advanced Industrial Science and Technology3University of Oxford* Equal contribution

Abstract

Formula-Driven Supervised Learning (FDSL) enables vision pre-training without real images, but existing methods cast pre-training as classification on discretized labels, discarding continuity in the generative process. We propose Formula-Driven Supervised Metric Learning (FDSML), which derives relational supervision from image-generation parameters beyond discrete class labels. FDSML combines FineFractalDB, our refined fractal dataset with higher intra-class variation and more stable structures, with a Parameter-Aware Triplet (PA-Triplet) Loss that assigns positives and negatives according to distances in the underlying Iterated Function System parameter space. This objective trains embeddings to respect parameter-derived relative similarity orderings. Experiments show that FDSML improves transferability to image retrieval while remaining competitive on downstream classification and improving robustness under several corruption settings. On ResNet-50, Recall@1 improves from 65.6%65.6\% to 74.0%74.0\% on Stanford Online Products and from 56.2%56.2\% to 78.4%78.4\% on Stanford Cars over FDSL pre-training. These results suggest that parameter-derived relational supervision provides a stronger synthetic pre-training signal than label-based classification for transfer beyond recognition.

Why FDSML?

Formula-Driven Supervised Learning (FDSL) pre-trains vision models on images rendered from mathematical formulas, so no real images, annotations, or privacy concerns are involved. Existing FDSL methods, however, treat pre-training as classification: the continuous generation parameters are discretized into class labels, and everything that happens inside a class is thrown away.

Conventional FDSL

  • Supervision: "which class does this fractal belong to?"
  • Fine-grained geometric relations inside a class are discarded
  • Encourages memorization of instance-specific textures
  • Strong on classification, weak on retrieval and robustness

FDSML (Ours)

  • Supervision: "which of these two fractals is closer to the anchor?"
  • Relative orderings are derived from the continuous IFS parameter space
  • Learns how to compare visual structures instead of what to memorize
  • Large gains on retrieval, competitive classification, better robustness (ResNet-50)

Fractals are generated by an Iterated Function System (IFS), and their shapes change gradually as the affine parameters change. We argue that this continuity is the supervision signal itself. Instead of asking a model to recognize categories, we ask it to respect the relative similarity orderings induced by the generative parameters.

Parameter-Aware Triplet Loss

FDSML keeps the standard triplet objective and changes only how positives and negatives are chosen.

1

Sample

Draw an anchor xa and two candidates x1, x2 together with their IFS parameter descriptors Ψa, Ψ1, Ψ2.

2

Assign

The candidate closer to the anchor in parameter space becomes the positive, the other the negative. No class label is needed for this decision.

3

Train

Optimize the encoder so that embedding-space distances reproduce the ordering given by the parameter space.

Each image xi\boldsymbol{x}_i is generated by an IFS {(ψk,πk)}k=1N\{(\boldsymbol{\psi}_k, \pi_k)\}_{k=1}^{N}, where ψk∈R6\boldsymbol{\psi}_k \in \mathbb{R}^6 are the affine parameters of map kk and πk\pi_k its selection probability. We summarize the generative process with a compact descriptor and a distance on it:

Ψi=∑k=1Nπk ψk∈R6,dΨ(i,j)=∥Ψi−Ψj∥2.\boldsymbol{\Psi}_i = \sum_{k=1}^{N} \pi_k \, \boldsymbol{\psi}_k \in \mathbb{R}^6, \qquad d_{\boldsymbol{\Psi}}(i, j) = \lVert \boldsymbol{\Psi}_i - \boldsymbol{\Psi}_j \rVert_2 .

Given an anchor and two candidates, x1\boldsymbol{x}_1 is the positive and x2\boldsymbol{x}_2 the negative whenever dΨ(a,1)≤dΨ(a,2)d_{\boldsymbol{\Psi}}(a, 1) \le d_{\boldsymbol{\Psi}}(a, 2), and the triplet is fed to the usual margin loss:

Ltriplet=max⁡(0,  ∥gθ(xa)−gθ(xp)∥2−∥gθ(xa)−gθ(xn)∥2+α).\mathcal{L}_{\mathrm{triplet}} = \max\Bigl(0,\; \lVert g_\theta(\boldsymbol{x}_a) - g_\theta(\boldsymbol{x}_p) \rVert_2 - \lVert g_\theta(\boldsymbol{x}_a) - g_\theta(\boldsymbol{x}_n) \rVert_2 + \alpha \Bigr).

Note that dΨd_{\boldsymbol{\Psi}} is used only ordinally, to decide which candidate is closer. It is not treated as a perceptual distance, so the embedding is trained to respect relative orderings rather than categorical separability.

Filtering Triplet Candidates

Two fractals drawn at random from the whole dataset are usually so different that the comparison is trivial. We therefore use the discrete class labels as a coarse prior that restricts the candidate pool; the final positive/negative assignment is still made by dΨd_{\boldsymbol{\Psi}}.

Four candidate filtering strategies: all, each, same, diff
(A) all
No restriction; both candidates come from anywhere.
(B) each
One candidate from the anchor's class, one from another class.
(C) same
Both candidates from the anchor's class: fine structural differences.
(D) diff
Both candidates from other classes: large variations.

Does the parameter ordering actually match what is rendered? We measured how often the candidate closer in dΨd_{\boldsymbol{\Psi}} is also closer under the symmetric Chamfer distance between the rendered shapes.

FilteringAgreement with dΨd_{\boldsymbol{\Psi}}Label-only rule
all47.2 %–
each89.2 %89.4 %
same80.6 %50.0 % (chance)
diff46.8 %50.0 % (chance)

Under each, the descriptor essentially reproduces the class label. Under same, no label rule exists at all, yet the descriptor still reaches 80.6 %: this is supervision that class labels cannot provide even in principle, and it is the regime where FDSML works best.

FineFractalDB

FractalDB-1k creates its 1,000 instances per class from only 25 parameter perturbations combined with flips and rendering variations, and its affine maps are not forced to be contractive. The result is low intra-class diversity (left, blue box) and collapsed, uninformative samples (right, red box), neither of which is good for fine-grained relational supervision.

FractalDB vs. FineFractalDB samples from one class

FineFractalDB keeps the 1,000 classes × 1,000 images of FractalDB-1k but refines the generation process:

  • 1,000 independent parameter perturbations per class (instead of 25), so every instance is a distinct point in parameter space.
  • Strict contraction constraints on every affine map, which keep the attractor stable.
  • Rejection sampling on pixel occupancy (< 0.05 % discarded), which removes nearly empty renderings.

Drag the slider to compare random samples from the two datasets. Each row is one class, each column a different instance.

Random samples from FractalDB-1k Random samples from FineFractalDB
← FractalDB-1kFineFractalDB →

Code & Pre-trained Models

Image Retrieval

Retrieval depends on the geometry of the embedding space rather than on decision boundaries, which makes it the most direct test of our claim. With a ResNet-50 backbone fine-tuned with the Proxy-Anchor loss, FDSML pre-training on FineFractalDB consistently beats both training from scratch and classification-based FDSL on FractalDB-1k.

Stanford Online Products · Recall@1
65.6 → 74.0
+8.4 pt over FDSL
Stanford Cars · Recall@1
56.2 → 78.4
+22.2 pt over FDSL
In-Shop Clothes · Recall@1
87.3 → 89.2
+1.9 pt over FDSL
Pre-training (ResNet-50)SOP R@1SOP R@10Cars R@1Cars R@4In-Shop R@1In-Shop R@10
Scratch70.483.140.961.587.295.7
ImageNet-1k (supervised, real images)79.191.087.795.691.197.8
FractalDB-1k, FDSL65.681.356.276.387.395.5
FineFractalDB, FDSML (same)74.086.678.490.289.297.0

Two observations stand out. First, on SOP the FDSL model is actually worse than training from scratch (65.6 vs. 70.4 Recall@1): classification-based synthetic supervision does not automatically provide a useful inductive bias for embedding-based tasks. Second, FDSML closes a large part of the gap to real-image pre-training while never seeing a natural image. The full table with all filtering strategies and Recall@K values is in the paper.

Classification & Robustness

FDSML is designed for relational tasks, but it does not sacrifice category recognition. Top-1 accuracy after fine-tuning (%):

Pre-training (ResNet-50)CIFAR-10CIFAR-100ImageNet-100ImageNet-1kPlaces-30
Scratch87.6062.7072.4275.4773.50
ImageNet-1k (supervised)96.9684.48––80.33
FractalDB-1k, FDSL90.5070.2179.4270.4376.33
FineFractalDB, FDSML (same)91.4768.7480.6272.6577.20
Pre-training (ViT-Tiny)CIFAR-10CIFAR-100ImageNet-100ImageNet-1kPlaces-30CarsFlowers
Scratch76.4758.0270.0871.4681.1721.3048.74
ImageNet-1k (supervised)97.9285.65––81.4891.2693.70
FractalDB-1k, FDSL96.6581.1884.4072.4080.4677.0173.99
FineFractalDB, FDSML (each)98.0082.0888.9073.7180.3583.1774.21

On ViT-Tiny, FDSML lifts ImageNet-100 from 84.40 % to 88.90 % and even edges out supervised ImageNet-1k pre-training on CIFAR-10. The same trend holds for ViT-Base (see the paper).

The objective and the dataset are complementary

Ablation with ViT-Tiny (Top-1 %). Swapping the objective alone already helps; swapping the dataset helps only under FDSML.

ObjectiveDatasetCIFAR-10CIFAR-100ImageNet-100
FDSL (cross-entropy)FractalDB-1k96.6581.1884.40
FDSL (cross-entropy)FineFractalDB96.1177.5284.32
FDSML (each)FractalDB-1k97.7781.7287.93
FDSML (each)FineFractalDB98.0082.0888.90

Cross-entropy assigns the same label to every instance in a class, so it cannot exploit the extra intra-class variation of FineFractalDB and even suffers from it. PA-Triplet turns exactly that variation into supervision.

Robustness to corruptions

Classification error on ImageNet-C (lower is better), averaged within each corruption group:

BackbonePre-trainingNoiseBlurWeatherDigitalGeometric
ResNet-50FractalDB-1k, FDSL86.1674.8271.9460.3661.15
ResNet-50FineFractalDB, FDSML (same)83.6272.8768.8157.4659.13
ViT-TinyFractalDB-1k, FDSL55.3160.7850.8441.9448.49
ViT-TinyFineFractalDB, FDSML (same)59.2660.0647.6443.5547.97

For ResNet-50, FDSML improves every corruption group. For ViT-Tiny the picture is mixed: structural and environmental corruptions (blur, weather, geometric) improve, while high-frequency noise and digital corruptions get worse. We report this trade-off as is; understanding its frequency-domain cause is future work.

Qualitative Analysis

Where does the model look?

Grad-CAM for ResNet-50 models fine-tuned on ImageNet-1k. FDSML produces activation maps that are concentrated on the object, qualitatively closer to the ImageNet pre-trained model, whereas FDSL responses are often diffuse or drift to the background.

Grad-CAM comparison: ImageNet pre-trained, FDSL, FDSML

Attention inside the Transformer

Layer-wise CLS-to-patch attention of ViT-Tiny on a fractal input, from shallow (left) to deep (right). FDSL attends almost exclusively to the silhouette boundary; FDSML also attends to textured interior regions, which suggests it captures fine-grained appearance in addition to coarse structure.

Layer-wise attention maps of ViT-Tiny

Structure of the embedding space

UMAP projection of ResNet-50 features for ten FineFractalDB test classes. FDSML (each) organizes each class into structured trajectories that follow the generative parameters, with the images (A)–(D) sampled along one trajectory shown below each panel.

UMAP of embeddings learned with FDSL, FDSML (each), FDSML (same)

Limitations

  • Only IFS fractals so far. PA-Triplet could be instantiated for other formula-driven generators (e.g. VisualAtom, TileDB), but each needs its own similarity definition over its parameters and its own validation.
  • One-million-image scale. Whether the gains from parameter-aware supervision persist at larger scales is an open question.
  • Extra overhead. Descriptor computation and triplet construction add cost over cross-entropy FDSL; we have not analyzed this cost in detail.
  • Architecture-dependent robustness. The ViT noise/digital trade-off above remains unexplained.

License

The FDSML source code is released under CC BY-NC-SA 4.0 (see LICENSE). Parts of the code are derived from the third-party projects below, which keep their original licenses (see NOTICE.md for details).

This project page is built on the academic-project-template by denkiwakame, provided under CC BY-SA 4.0.

Acknowledgements

This work was supported by JSPS KAKENHI Grant Numbers JP24H00742 and JP24H00748, JST SPRING Grant Number JPMJSP2128, and computational resources of ABCI 3.0 provided by AIST and AIST Solutions.

Citation

@inproceedings{Otake2027fdsml,
  author    = {Hina Otake and Shinei Arakawa and Keitaro Tanaka and Yoshihiro Fukuhara and Hirokatsu Kataoka and Shigeo Morishima},
  title     = {FDSML: Formula-Driven Supervised Metric Learning with Parameter-Aware Triplet Loss},
  booktitle = {Proceedings of the IEEE/CVF Winter Conference on Applications of Computer Vision (WACV)},
  year      = {2027}
}