fit

Contents

fit#

scarlet2.fit(scene, observations, *args, schedule=None, max_iter=100, e_rel=0.0001, progress_bar=True, callback=None, **kwargs)[source]#

Fit model parameters of every source in scene to match observations.

Computes the best-fit parameters of all components in every source by first-order gradient descent with the Adam optimizer from optax.

Parameters:
  • scene (Scene) – The model of the scene.

  • observations (Observation or list) – The observations to fit the model to.

  • *args (list, optional) – Additional arguments passed. Only used for backwards (v0.3) compatibility.

  • schedule (callable, optional) – A function that maps optimizer step count to value. See optax.Schedule for details.

  • max_iter (int, optional) – Maximum number of optimizer iterations

  • e_rel (float, optional) – Upper limit for the relative change in the norm of any parameter to terminate the optimization early.

  • progress_bar (bool, optional) – Whether to show a progress bar

  • callback (callable, optional) – Function to be called on the current state of the optimized scene. Signature callback(scene, convergence, loss) -> None, where convergence is a tree of the same structure as scene, and loss is the current value of the log_posterior.

  • **kwargs (dict, optional) – Additional keyword arguments passed to the optax.scale_by_adam optimizer.

Notes

Requires optax

Returns:

The scene and observation(s) with updated parameters

Return type:

Scene, list(Observation)