Batch processors

A batch processor adapts a dataset batch to a model interface. XANESNET selects one automatically from the pair (dataset_type, model_type) using BatchProcessorRegistry. Users normally do not configure one directly.

Available implementations

Forward processors:

Inverse processors:

The corresponding _mp dataset variants use the same processors as their non-multiprocessing dataset types. See Datasets for the complete dataset-model compatibility matrix and Models for model choices.

Required interface

Every concrete BatchProcessor must implement these abstract methods:

  • input_preparation(batch) converts a collated dataset batch into the inputs expected by model.forward.

  • target_preparation(batch) extracts the raw target tensor used for loss calculation and prediction records.

  • encode_input(inputs, elements) maps raw inputs into model input space.

  • encode_target(targets, elements) maps raw targets into model prediction space before the loss is computed.

  • decode_target(predictions, elements) maps model predictions back to raw target space after inference.

  • sample_id_preparation(batch) returns the sample identifiers used in prediction output.

The base class also provides optional hooks for prediction reshaping, target-site elements, and target-site indices. Direction-specific base classes implement the encoding behavior: forward processors encode targets and decode spectral predictions, while inverse processors encode spectral inputs and keep descriptor targets unchanged.

API reference

See BatchProcessor, ForwardBatchProcessor, InverseBatchProcessor, and xanesnet.batchprocessors for the base interfaces, registry, and concrete implementations.