We introduce reflectorch, a Python package which facilitates the full machine learning pipeline for the data domain of X-ray and neutron reflectometry. Firstly, the package allows the choice of different parameterizations of the scattering length density profile of a thin film, or generally, a layered structure, and the sampling of the ground truth physical parameters from user-defined ranges. Secondly, the package provides functionality for the fast simulation of reflectometry curves on the GPU using a vectorized implementation of the Abelès matrix formalism (Abelès, 1950) and the augmentation of the theoretical curves with noise informed by experimental considerations. The architecture of the neural network as well as the training callbacks and hyperparameters can be easily customized from YAML configuration files. Notably, our implementation makes use of a special training procedure introduced in our publication (Munteanu et al., 2024), in which prior boundaries for the target parameters are provided alongside the reflectivity curve as an additional input to the neural network.
Munteanu et al. (2025) studied this question.