Fitting controls#
Use mrax.core.loss_builder.run_fit() for one experiment, or
Studies and Observables for a sequence of dependent fits. The same fitting interface
supports Optax, FISTA and split Bregman.
Choose an optimizer#
Optimizer |
Typical use |
|---|---|
Optax, such as Adam |
Differentiable objectives and smoothed regularization. |
FISTA |
Accelerated proximal-gradient fitting with physical bounds and native TV. |
Split Bregman |
Augmented-primal, shrinkage and multiplier updates for native TV. |
Automatic selection uses FISTA for enabled TV terms and Adam otherwise. Explicit Adam uses smoothed TV and emits a warning. FISTA and split Bregman use native TV with physical field bounds. Temporal smoothness remains a squared-difference penalty. Model parameter specifications define bounds, constant dimensions and regularizer weights.
from mrax.core import run_fit
fields, history, info = run_fit(
experiment, model, dataset,
optimizer_name="fista",
step_size=0.02,
num_steps=200,
return_fit_info=True,
)
print(info.optimizer_name, info.termination_reason, info.final_loss)
Prepare the objective#
Check the model’s units, observables, parameter bounds and initialization. Use Boolean masks for equal-weight regions or numeric masks for confidence weights. ROI normalization uses the retained finite observations. Full-image normalization uses all finite image data. Adjust regularizer weights consistently when changing normalization. See Variance Estimation and Weighted Fitting for noise weighting.
Weighted least squares is the default data term. The optional data_loss
callable supports alternatives such as grouped pseudo-Huber loss.
Fitting documents normalization, masks, reference-image fitting and
custom losses.
Run and inspect#
Fits default to CPU. Select a local device with device. Use
mrax.get_available_devices() to list available devices. GPU setup is covered
in Docker development setup and Windows setup.
Inspect the loss history, fitted fields and FitInfo termination reason.
For nonlinear models, assess stationarity and sensitivity to initialization.
Early-stopping tolerances, schedules and host-check intervals are described in
Fitting.
Continue a fit with initial_state=info.state and the same model, data,
regularizers and optimizer. Use initial_params for a fresh optimizer.
Further details#
Optimizers and regularizers: algorithm options, proximal accuracy, direct Optax loops and checkpoint compatibility.
Fitting: complete fitting arguments and return values.
Model parameters: parameter coordinates and model specifications.
References: publications underlying the models and optimizers.