autofit.BFGS#
- class BFGS[source]#
Bases:
AbstractBFGSAbstract wrapper for the BFGS and L-BFGS scipy non-linear searches.
- Parameters:
disp (
bool) – Set to True to print convergence messages.maxiter (
int) – Maximum number of iterations.maxfun (
int) – Maximum number of function evaluations.clipper (
Optional[AbstractClipper]) –Enforcement of prior support (see
autofit.non_linear.clipper). Unlike the multi-start gradient searches, which project the parameters themselves after every update, this search declares the box to scipy and lets scipy enforce it —L-BFGS-Bsupports box bounds natively.Default
ClipperNone, under which nobounds=is passed at all and behaviour is unchanged. Only bound-supporting methods accept a real clipper; see_bounds_from.
Methods
apply_test_modeReduce the search's budget for test mode: the generic reduction sets each attribute of the declared
test_mode_budget(apply_test_modeof this module).check_modelcopy_with_pathsexact_fitexecution_settingsHow this search executes its objective on
analysis, resolved once: batching, eager or jitted execution, gradient use and the resolved gradient mode, plus theFitnesskeyword arguments the backend builds itsFitnesswith (autofit.non_linear.search.preflight.ExecutionSettings).finalize_resultThe one ending of a fit that ran (or was bypassed in test mode): build the
Result, run the analysis'save_resultshooks, unfreeze the model and complete the fit (archive, then.completed).finalize_search_internalArchive
search_internal(output_search_internal) when the search retains its internal state, otherwise remove thesearch_internalfolder.fitFit a model, M with some function f that takes instances of the class represented by model M and gives a score for their fitness: the search produces instances of the model by picking points in its N dimensional space.
fitness_overridesThe
Fitnessstores its evaluation history when the start point is plotted: the samples are then the whole optimisation path (raw_samples_from).info_fromThe
samples_infoentries of arun(ctx)search's internal state, theinfoitsraw_samples_fromputs on theRawSamples(autofit.non_linear.samples.adapter).load_search_internalThe search's internal state as stored in its output folder, or
Nonewhen its paths store nothing (NullPaths,DatabasePaths).make_fitnessThe Fitness this search evaluates its likelihood through, the one construction site every search shares.
optimiseOptimise one expectation-propagation factor with this search (
autofit.graphical.expectation_propagation.SearchFactorOptimiser).output_search_internalArchive
search_internalthrough the search'scheckpointerand, once a fit has completed, discard its resume state (there is nothing left to resume).perform_updatePerform an update of the non-linear search's model-fitting results.
perform_visualizationPerform visualization of the non-linear search's model-fitting results.
plot_latent_resultsThe search's plots of the model's latent parameters (the corner plot of a shear's magnitude and angle, say), by its
posterior_kind; nothing for a search without one.plot_resultsThe search's own plots of its samples, by its declared
posterior_kind(autofit.non_linear.search.posterior_kind): the chain, weighted or point plotter.plot_start_pointVisualize the starting point of the non-linear search, using an instance of the model at the starting point of the maximum likelihood estimator.
post_fit_outputArchives the output folder of a completed non-linear search into its .zip file (always), and then removes the folder so only the .zip is left (for supercomputers with a file-count limit) only when remove_files=True in the general.yaml output section; with remove_files=False both are kept.
pre_fit_outputOutputs attributes of fit before the non-linear search begins: the model composition (files/model.json), the search settings (files/search.json), the info dictionary (files/info.json), the analysis' save_attributes (e.g. files/data.json) and its visualize_before_fit / visualize_before_fit_combined visuals (quantities that do not change during the model-fit, e.g. the data).
progressThe run's progress for the status record (
autofit.non_linear.status): the iterations taken ofmaxiter(scipy stops earlier once converged).raw_samples_fromThe LBFGS internal results as raw samples: the full history when the start point is plotted, otherwise the single optimum
x.result_via_completed_fitReturns the result of the non-linear search of a completed model-fit.
runRun scipy's
minimize(therun(ctx)hook; seedocs/design/run_ctx.md) and return itsOptimizeResult.samples_fromLoads the samples of a non-linear search from its output files.
samples_via_internal_fromThe samples of the search, converted from its internal state.
start_pointsThe search's
ninitial points, drawn by its initializer, with the start-point plot made once, here, from the first of them.start_resume_fitAttributes
batchedcheckpointerwhere the backend's final state is stored when a fit completes, for
Result.search_internalandsamples_via_internal_from.citation_keysgradienthonours_gradient_modeinstall_extrainvalid_valuejax_useloggerLog 'msg % args' with severity 'DEBUG'.
nameobjective_targetoptionspathsposterior_kindproduces_evidencequick_update_messageThe one-line quick-update cadence logged at the start of every fit.
requires_fp64resumableresume_stateThe file an interrupted run resumes from, for searches that genuinely resume (
Noneotherwise).retains_search_internalalways when the archive declares
retain_after_completion(its results cannot be rebuilt without it), otherwise when theoutput.search_internalconfig is on.should_plot_start_pointstatustest_mode_budgettimerThe timer of the search (how long the search took, how much parallelization sped it up), or
Nonewhen the paths keep no timer (has_timer:NullPaths,DatabasePaths).upstream_urlwarm_start- method = 'BFGS'#