Counting Layers by Learned Inverse Rendering: Parity-Exact Flake Identification Without Per-Flake Fitting

Many of the most interesting effects in layered crystals switch on or off with a single atomic layer. A flake of tungsten ditelluride (WTe2) with an odd number of layers responds to an electric field in a completely different way from one with an even number. The nonlinear Hall signal flips sign in one case and stays unchanged in the other. In practice, the hard part of exploiting this is not the physics but finding the right flake. Optical microscopes see only small color differences between, say, four and five layers. Today's automated flake finders either stop at "monolayer / few-layer / thick" or openly struggle with adjacent multilayers. Physicists fall back on slow atomic force microscopy (AFM, a probe that physically scans surface height), which takes a long time per sample and can damage it.

We propose to treat layer counting as an inverse rendering problem: infer the hidden scene (an integer layer-count map plus unknown imaging conditions) that best explains the observed microscope image. We then amortize this problem with the trick that made feed-forward 3D reconstruction work. In 3D vision, fitting a scene by thousands of gradient steps was replaced by a trained network. That network repeatedly renders its current guess, looks at the rendering error, and predicts a correction. Here the "renderer" is the well-understood thin-film optics of a flake on a silicon oxide substrate. The target is not image quality but exact layer parity: a calibrated probability that each terrace has an odd or even layer count, delivered in under a second per field of view.

Core Claim

The claim is that a recurrent, physics-in-the-loop network can identify the exact layer count of few-layer flakes, and especially odd versus even, more accurately than single-pass classifiers. It would also match or beat per-flake physical model fitting at a fraction of the cost. The network is trained on simulated optics and corrected by repeated comparison of rendered and observed contrast.

The mechanism is borrowed from ReSplat: Learning Recurrent Gaussian Splats, which renders its current 3D Gaussian estimate, maps the rendering error back into 3D, and predicts residual updates without test-time gradients. That approach beat DepthSplat by 3.5 dB PSNR on DL3DV 8-view synthesis and gained about 5 dB on out-of-distribution resolutions over single-pass models. That second number is the property we need, because microscope illumination, camera white balance, and oxide thickness all drift between labs and sessions.

What is new is the combination of three things:

  • A physical forward model inside the loop. The renderer is a differentiable transfer-matrix thin-film model rather than a Gaussian rasterizer.
  • Discrete scene variables. The scene is an integer layer map, not continuous primitives.
  • A parity-specific objective. Success is judged on parity, which is the variable that determines the physics.

Research Program

The forward model, written $R(\mathbf{n}, \boldsymbol{\phi})$, takes a per-pixel layer count $\mathbf{n}$ and nuisance parameters $\boldsymbol{\phi}$. The nuisance parameters cover oxide thickness, illumination spectrum, numerical aperture, camera color response, and a slowly varying intensity field. It returns a predicted RGB image, or a multi-wavelength stack when narrowband LEDs are available.

This is the same transfer-matrix physics that MaskTerial: a foundation model for automated 2D material flake detection used to generate 300,000 synthetic training images. MaskTerial used that physics only offline, as a data source. We keep it at test time, as part of every refinement step.

The network has three parts:

  • Initial estimate. An image encoder produces a per-pixel distribution over layer counts $q^{(0)}(\mathbf{n})$ and an estimate $\boldsymbol{\phi}^{(0)}$.
  • Refinement steps. At each of $T$ steps, we render the expected image under the current estimate and compute the residual between rendered and observed images. A small update module receives the residual, the image features, and the current estimate, and outputs corrections.
  • Training signal. Training unrolls all steps and supervises every step on simulated data, then fine-tunes on a modest real set.

The update at step $t$ is

$$ \left(q^{(t+1)}, \boldsymbol{\phi}^{(t+1)}\right) = \left(q^{(t)}, \boldsymbol{\phi}^{(t)}\right) + U_\theta\!\left(I - R\!\left(\mathbb{E}_{q^{(t)}}[\mathbf{n}], \boldsymbol{\phi}^{(t)}\right),\; F(I),\; q^{(t)}, \boldsymbol{\phi}^{(t)}\right) $$

Here $I$ is the observed image, $F(I)$ are encoder features, and $U_\theta$ is the learned update module.

Two structural priors make the problem easier than per-pixel contrast lookup:

  • Terraces. A flake is a set of flat regions whose layer counts differ by integers. We regularize $q$ to be piecewise constant within segmented regions.
  • Built-in calibration. The bare substrate around every flake has known layer count zero. That fixes much of $\boldsymbol{\phi}$ in every image.

The final output is a per-terrace parity posterior. We calibrate it so that a downstream user can set a threshold such as "only send flakes with at least 95% confidence of being trilayer to fabrication."

Ground truth comes from two instruments. AFM step heights give layer counts on a subset. Second harmonic generation (SHG, an optical signal at double the laser frequency that appears only when inversion symmetry is broken) gives a direct parity label for WTe2. Spatially Tunable Interfacial Ferroelectricity in Low-Symmetric WTe2 reports that odd-layer WTe2 is centrosymmetric (space group P2₁/m) while even-layer WTe2 is polar (Pm), so SHG is parity-sensitive. SHG labels are fast and non-contact, so we can collect many more parity labels than AFM-verified counts. Parity is also exactly what Ferroelectric nonlinear anomalous Hall effect in few-layer WTe2 and Berry curvature memory through electrically driven stacking transitions need: odd-layer WTe2 flips its Berry curvature dipole under polarization reversal, while bilayer-type stacks do not.

The primary material is WTe2 at 2–7 layers, since its parity physics is best documented. Graphene and WSe2 serve as secondary checks. The method should transfer to any material with known optical constants, including TaIrTe4, where Quantum spin Hall effect in monolayer and bilayer TaIrTe4 shows that even the bilayer is topologically nontrivial. Exact counts matter there too.

Baselines

Naive reference. The do-nothing point is chance-level parity (50%). The realistic naive point is per-pixel color clustering of the kind used by Zero-shot Autonomous Microscopy for Scalable and Intelligent Characterization of 2D Materials. ATOMIC runs K-means on contrast and uses GPT-4o to choose the cluster number. It reports 99.7% pixel accuracy for monolayer MoS2 and correct cluster-count selection in 82.9% of cases, but it explicitly states difficulty with 4-layer versus 5-layer. We run it on our images with its published procedure. To score parity, we map clusters to layer counts in contrast order using the substrate as anchor.

Strongest learned competitor. This is MaskTerial: a Mask2Former segmenter followed by a mixture-model thickness classifier with uncertainty estimates, pretrained on transfer-matrix synthetic images. It reports more than 10% higher AP50 than Gaussian-mixture baselines (up to 40% on low-contrast hBN), saturation after 2–5 labeled images per class, and 120–280 ms inference.

No reported result was found on Lacuna for exact few-layer counts or parity accuracy on WTe2 by MaskTerial or any other optical method. The closest WTe2 figure is CLIFF's 56.96% macro accuracy on coarse three-bucket classes (CLIFF: Continual Learning for Incremental Flake Features in 2D Material Identification). Its tasks are not comparable to ours.

To keep the comparison fair, MaskTerial gets the following:

  • the same synthetic pretraining generator, with layer counts 1–7 as separate classes;
  • the same real labeled images per class;
  • the same multi-wavelength inputs when we use them;
  • an equal hyperparameter search budget.

Per-flake physical fitting. This is the "per-scene optimization" that our method amortizes, and it is the most principled competitor. It runs gradient-based or exhaustive search over integer layer counts per terrace and continuous $\boldsymbol{\phi}$ per image, minimizing the same rendering residual with the same forward model. It is initialized from substrate calibration and given a generous iteration budget. We report its accuracy and its wall-clock time.

Ablations that isolate the key ingredient. First, $T=0$: the same network with no refinement. This tests whether the in-loop renderer matters beyond synthetic pretraining. Second, refinement with a learned black-box residual instead of the physical renderer. Third, a hybrid in which our single-pass output initializes per-flake fitting.

What counts as winning. Beating the baselines means the following. Parity accuracy and exact-count accuracy at 3–6 layers must exceed MaskTerial by a margin larger than the run-to-run spread across seeds. Accuracy must match per-flake fitting to within its error bars, at least an order of magnitude faster. The calibration curve must allow a high-confidence subset with parity precision above 95%.

Why not just…?

Why not just fit the transfer-matrix model per flake, since the physics is known? This is the real threat. Single-terrace contrast fitting is cheap, so amortization might buy little speed. Our bet is that fitting is fragile exactly where parity matters. Adjacent multilayers differ by small contrast steps that are comparable to illumination and white-balance errors. Joint fitting of nuisance parameters per image is therefore poorly determined and prone to off-by-one minima.

The recurrent network learns which residual patterns indicate a miscounted terrace versus a miscalibrated lamp. That is the same advantage ReSplat showed over 3DGS optimized for 4,000 iterations, which it surpassed in 4 steps. If per-flake fitting matches our accuracy on held-out sessions, we will report that honestly. The contribution then shrinks to throughput: fitting would take seconds per flake against sub-second per field of view. The hybrid ablation will show whether the right answer is "learned initialization plus fitting."

Why not just retrain MaskTerial's classifier with finer classes? It already uses transfer-matrix pretraining and needs few labels. But it maps contrast to class in a single pass, with no mechanism for correcting a session-level calibration error after seeing its own prediction. MaskTerial also fails on flakes under 200 pixels. Our $T=0$ ablation is essentially this design with matched data, so if refinement adds nothing, the experiment will show it directly.

Why not just measure every flake with AFM or SHG? These remain the ground truth, and we use both. But they are serial and slow over a full substrate. AFM also risks damaging sensitive samples, a limitation the 2D-materials literature in the file notes as the reason optical screening exists. The proposal does not replace these instruments. It reduces their use to confirming a short list of high-confidence candidates.

Proposed Experiments

Data collection. We exfoliate WTe2 onto two oxide thicknesses and image each substrate under white light and under three to four narrowband LEDs. Imaging is repeated across several sessions and at least two microscopes to create real distribution shift. We label several hundred terraces at 1–7 layers by AFM and a larger set by SHG parity. For prior-work comparability, we also evaluate the graphene and WSe2 subsets of the MaskTerial benchmark, and the WTe2 images of the Masubuchi dataset used by CLIFF, both at coarse granularity.

Metrics. We measure per-terrace exact-count accuracy, parity accuracy stratified by layer count, and expected calibration error of the parity posterior. We also report precision at the confidence threshold that keeps 50% of terraces, and wall-clock time per 1 cm² substrate.

Decisive check 1: does refinement help? The first decisive check is the accuracy-versus-$T$ curve on images from held-out microscopes. If refinement with the physical renderer gives no gain over $T=0$ under session shift, the core claim fails.

Decisive check 2: is amortization worth it? The second is the head-to-head with per-flake fitting at matched forward models. This settles whether amortization buys accuracy or only speed.

Decisive check 3: does it matter downstream? The third is a downstream test. We select odd-layer WTe2 flakes by our posterior alone and fabricate a small batch of dual-gated devices. We check whether the fraction showing the sign-reversing nonlinear Hall response expected for odd layers is consistent with the predicted parity precision. This ties the vision metric to the physics the flakes are being found for.