  Reconstructing the structure of thin films and multilayers from measurements
of scattered X-rays or neutrons is key to progress in physics, chemistry, and
biology. However, finding all structures compatible with reflectometry data is
computationally prohibitive for standard algorithms, which typically results in
unreliable analysis with only a single potential solution identified. We
address this lack of reliability with a probabilistic deep learning method that
identifies all realistic structures in seconds, setting new standards in
reflectometry. Our method, Prior-Amortized Neural Posterior Estimation (PANPE),
combines simulation-based inference with novel adaptive priors that inform the
inference network about known structural properties and controllable
experimental conditions. PANPE networks support key scenarios such as
high-throughput sample characterization, real-time monitoring of evolving
structures, or the co-refinement of several experimental data sets, and can be
adapted to provide fast, reliable, and flexible inference across many other
inverse problems.
