Search for a command to run...
A README file is provided with the complete instructions. Brief description: This code implements a coordinate-based neural network that predicts image intensity from two inputs: 1. the spatial coordinate `(x, y)` of each pixel, and2. a vector of experimental control parameters (for example electrode biases). The intended application is the forward modelling of structured electron-beam illumination patterns, where one wants a fast surrogate model of the mapping `control parameters -> illumination pattern`. A second workflow is also included: once the network has been trained, the input parameter vector can be optimized to reproduce a desired target pattern. This corresponds to an inverse-design step in control-parameter space. ## What the code does The module is organized around five tasks. ### 1. Data loading and normalization `load_pattern_dataset()` reads a stack of `.npy` images from disk together with the corresponding control-parameter array. Images are rescaled to the interval `[0, 1]`. Labels are standardized by subtracting the mean and dividing by the standard deviation. ### 2. Conversion to coordinate-based training data `flatten_dataset()` converts an image stack of shape `(n_images, nx, ny)` into a flattened regression dataset where each training sample is a single pixel. For each pixel, the model receives: - its spatial coordinate `(x, y)`, and- the control-parameter vector associated with the parent image. The regression target is the pixel intensity. This is the standard way to train an implicit neural representation (INR). ### 3. Model construction `build_model()` creates a branched neural network with: - one branch for spatial coordinates,- one branch for experimental parameters,- additive fusion of the two branches,- additional hidden layers after fusion,- a scalar output corresponding to image intensity. Two variants are supported: - a standard dense network with `tanh` activations,- a SIREN-based model using `SinusodialRepresentationDense` from `tf_siren`. Please reference the provided README file for the rest of the details