beetroots.modelling package
Subpackages
- beetroots.modelling.forward_maps package
- Submodules
- beetroots.modelling.forward_maps.abstract_base module
ForwardMapForwardMap.DForwardMap.D_samplingForwardMap.LForwardMap.NForwardMap.arr_fixed_valuesForwardMap.compute_all()ForwardMap.dict_fixed_values_scaledForwardMap.evaluate()ForwardMap.gradient()ForwardMap.hess_diag()ForwardMap.list_indices_fixedForwardMap.list_indices_to_sampleForwardMap.restrict_to_output_subset()ForwardMap.set_sampled_and_fixed_entries()
- beetroots.modelling.forward_maps.abstract_exp module
ExpForwardMapExpForwardMap.DExpForwardMap.D_samplingExpForwardMap.LExpForwardMap.NExpForwardMap.arr_fixed_valuesExpForwardMap.dict_fixed_values_scaledExpForwardMap.evaluate_log()ExpForwardMap.gradient_log()ExpForwardMap.hess_diag_log()ExpForwardMap.list_indices_fixedExpForwardMap.list_indices_to_sample
- beetroots.modelling.forward_maps.basic_exp module
BasicExpForwardMapBasicExpForwardMap.DBasicExpForwardMap.D_samplingBasicExpForwardMap.LBasicExpForwardMap.NBasicExpForwardMap.arr_fixed_valuesBasicExpForwardMap.compute_all()BasicExpForwardMap.dict_fixed_values_scaledBasicExpForwardMap.evaluate()BasicExpForwardMap.evaluate_log()BasicExpForwardMap.gradient()BasicExpForwardMap.gradient_log()BasicExpForwardMap.hess_diag()BasicExpForwardMap.hess_diag_log()BasicExpForwardMap.list_indices_fixedBasicExpForwardMap.list_indices_to_sampleBasicExpForwardMap.output_subsetBasicExpForwardMap.restrict_to_output_subset()
- beetroots.modelling.forward_maps.identity module
BasicForwardMapBasicForwardMap.DBasicForwardMap.D_samplingBasicForwardMap.LBasicForwardMap.NBasicForwardMap.arr_fixed_valuesBasicForwardMap.compute_all()BasicForwardMap.dict_fixed_values_scaledBasicForwardMap.evaluate()BasicForwardMap.gradient()BasicForwardMap.hess_diag()BasicForwardMap.list_indices_fixedBasicForwardMap.list_indices_to_sampleBasicForwardMap.output_subsetBasicForwardMap.restrict_to_output_subset()
- beetroots.modelling.forward_maps.neural_network_approx module
NeuralNetworkApproxNeuralNetworkApprox.DNeuralNetworkApprox.D_no_kappaNeuralNetworkApprox.D_samplingNeuralNetworkApprox.LNeuralNetworkApprox.LOGE_10NeuralNetworkApprox.NNeuralNetworkApprox.arr_fixed_valuesNeuralNetworkApprox.compute_all()NeuralNetworkApprox.deviceNeuralNetworkApprox.dict_fixed_values_scaledNeuralNetworkApprox.evaluate()NeuralNetworkApprox.evaluate_log()NeuralNetworkApprox.gradient()NeuralNetworkApprox.gradient_log()NeuralNetworkApprox.hess_diag()NeuralNetworkApprox.hess_diag_log()NeuralNetworkApprox.list_indices_fixedNeuralNetworkApprox.list_indices_fixed_for_nnNeuralNetworkApprox.list_indices_to_sampleNeuralNetworkApprox.list_indices_to_sample_for_nnNeuralNetworkApprox.networkNeuralNetworkApprox.restrict_to_output_subset()
- beetroots.modelling.forward_maps.regression_poly module
PolynomialApproxPolynomialApprox.DPolynomialApprox.D_no_kappaPolynomialApprox.D_samplingPolynomialApprox.LPolynomialApprox.LOGE_10PolynomialApprox.NPolynomialApprox.anglePolynomialApprox.arr_fixed_valuesPolynomialApprox.coeff_arrPolynomialApprox.coeff_arr_subsetPolynomialApprox.coeff_gradPolynomialApprox.coeff_grad_subsetPolynomialApprox.coeff_hess_diagPolynomialApprox.coeff_hess_diag_subsetPolynomialApprox.compute_all()PolynomialApprox.degPolynomialApprox.dict_fixed_values_scaledPolynomialApprox.evaluate()PolynomialApprox.evaluate_log()PolynomialApprox.gradient()PolynomialApprox.gradient_log()PolynomialApprox.hess_diag()PolynomialApprox.hess_diag_log()PolynomialApprox.indices_output_subset()PolynomialApprox.list_indices_fixedPolynomialApprox.list_indices_to_samplePolynomialApprox.output_subsetPolynomialApprox.output_subset_indicesPolynomialApprox.outputs_namesPolynomialApprox.pow_arrPolynomialApprox.pow_gradPolynomialApprox.pow_hess_diagPolynomialApprox.restrict_to_output_subset()
compute_grad_poly_params()compute_hess_diag_poly_params()evaluate_poly()grad_poly()hess_diag_poly()
- Module contents
- beetroots.modelling.likelihoods package
- Submodules
- beetroots.modelling.likelihoods.abstract_likelihood module
- beetroots.modelling.likelihoods.approx_censored_add_mult module
MixingModelsLikelihoodMixingModelsLikelihood.DMixingModelsLikelihood.LMixingModelsLikelihood.NMixingModelsLikelihood.P_lambdaMixingModelsLikelihood.evaluate_all_nll_utils()MixingModelsLikelihood.forward_mapMixingModelsLikelihood.grad_P_lambdaMixingModelsLikelihood.grad_model_mixing_param()MixingModelsLikelihood.gradient_neglog_pdf()MixingModelsLikelihood.gradient_neglog_pdf_ac()MixingModelsLikelihood.gradient_neglog_pdf_au()MixingModelsLikelihood.gradient_neglog_pdf_mc()MixingModelsLikelihood.gradient_neglog_pdf_mu()MixingModelsLikelihood.hess_diag_P_lambdaMixingModelsLikelihood.hess_diag_model_mixing_param()MixingModelsLikelihood.hess_diag_neglog_pdf()MixingModelsLikelihood.hess_diag_neglog_pdf_ac()MixingModelsLikelihood.hess_diag_neglog_pdf_au()MixingModelsLikelihood.hess_diag_neglog_pdf_mc()MixingModelsLikelihood.hess_diag_neglog_pdf_mu()MixingModelsLikelihood.log_fm1MixingModelsLikelihood.log_fp1MixingModelsLikelihood.log_yMixingModelsLikelihood.model_mixing_param()MixingModelsLikelihood.neglog_pdf()MixingModelsLikelihood.neglog_pdf_ac()MixingModelsLikelihood.neglog_pdf_au()MixingModelsLikelihood.neglog_pdf_mc()MixingModelsLikelihood.neglog_pdf_mu()MixingModelsLikelihood.omegaMixingModelsLikelihood.sample_observation_model()MixingModelsLikelihood.set_likelihood_approx_parameters()MixingModelsLikelihood.sigma_aMixingModelsLikelihood.sigma_mMixingModelsLikelihood.y
cost_au()cost_mu()gradient_cost_au()gradient_cost_mu()
- beetroots.modelling.likelihoods.gaussian module
GaussianLikelihoodGaussianLikelihood.DGaussianLikelihood.LGaussianLikelihood.NGaussianLikelihood.evaluate_all_forward_map()GaussianLikelihood.evaluate_all_nll_utils()GaussianLikelihood.forward_mapGaussianLikelihood.gradient_neglog_pdf()GaussianLikelihood.hess_diag_neglog_pdf()GaussianLikelihood.neglog_pdf()GaussianLikelihood.sample_observation_model()GaussianLikelihood.sigmaGaussianLikelihood.y
- beetroots.modelling.likelihoods.gaussian_censored module
CensoredGaussianLikelihoodCensoredGaussianLikelihood.DCensoredGaussianLikelihood.LCensoredGaussianLikelihood.NCensoredGaussianLikelihood.biasCensoredGaussianLikelihood.evaluate_all_forward_map()CensoredGaussianLikelihood.evaluate_all_nll_utils()CensoredGaussianLikelihood.forward_mapCensoredGaussianLikelihood.gradient_neglog_pdf()CensoredGaussianLikelihood.gradient_neglog_pdf_ac()CensoredGaussianLikelihood.gradient_neglog_pdf_au()CensoredGaussianLikelihood.hess_diag_neglog_pdf()CensoredGaussianLikelihood.hess_diag_neglog_pdf_ac()CensoredGaussianLikelihood.hess_diag_neglog_pdf_au()CensoredGaussianLikelihood.neglog_pdf()CensoredGaussianLikelihood.neglog_pdf_ac()CensoredGaussianLikelihood.neglog_pdf_au()CensoredGaussianLikelihood.omegaCensoredGaussianLikelihood.sample_observation_model()CensoredGaussianLikelihood.sigmaCensoredGaussianLikelihood.y
- beetroots.modelling.likelihoods.log_normal module
LogNormalLikelihoodLogNormalLikelihood.DLogNormalLikelihood.LLogNormalLikelihood.NLogNormalLikelihood.evaluate_all_forward_map()LogNormalLikelihood.evaluate_all_nll_utils()LogNormalLikelihood.forward_mapLogNormalLikelihood.gradient_neglog_pdf()LogNormalLikelihood.hess_diag_neglog_pdf()LogNormalLikelihood.logyLogNormalLikelihood.neglog_pdf()LogNormalLikelihood.sigmaLogNormalLikelihood.y
- beetroots.modelling.likelihoods.log_normal_censored module
CensoredLogNormalLikelihoodCensoredLogNormalLikelihood.DCensoredLogNormalLikelihood.LCensoredLogNormalLikelihood.NCensoredLogNormalLikelihood.evaluate_all_forward_map()CensoredLogNormalLikelihood.evaluate_all_nll_utils()CensoredLogNormalLikelihood.forward_mapCensoredLogNormalLikelihood.gradient_neglog_pdf()CensoredLogNormalLikelihood.gradient_neglog_pdf_ac()CensoredLogNormalLikelihood.gradient_neglog_pdf_au()CensoredLogNormalLikelihood.hess_diag_neglog_pdf()CensoredLogNormalLikelihood.hess_diag_neglog_pdf_ac()CensoredLogNormalLikelihood.hess_diag_neglog_pdf_au()CensoredLogNormalLikelihood.log_omegaCensoredLogNormalLikelihood.logyCensoredLogNormalLikelihood.neglog_pdf()CensoredLogNormalLikelihood.neglog_pdf_ac()CensoredLogNormalLikelihood.neglog_pdf_au()CensoredLogNormalLikelihood.omegaCensoredLogNormalLikelihood.sigmaCensoredLogNormalLikelihood.y
- beetroots.modelling.likelihoods.utils module
- Module contents
- beetroots.modelling.priors package
- Submodules
- beetroots.modelling.priors.abstract_prior module
- beetroots.modelling.priors.abstract_spatial_prior module
SpatialPriorSpatialPrior.DSpatialPrior.NSpatialPrior.build_sites()SpatialPrior.dict_neighborsSpatialPrior.dict_sitesSpatialPrior.gradient_neglog_pdf()SpatialPrior.hess_diag_neglog_pdf()SpatialPrior.initial_weightsSpatialPrior.list_edgesSpatialPrior.neglog_pdf()SpatialPrior.use_next_nearest_neighborsSpatialPrior.weights
build_list_edges()
- beetroots.modelling.priors.l22_laplacian_prior module
L22LaplacianSpatialPriorL22LaplacianSpatialPrior.DL22LaplacianSpatialPrior.NL22LaplacianSpatialPrior.dict_neighborsL22LaplacianSpatialPrior.dict_sitesL22LaplacianSpatialPrior.gradient_neglog_pdf()L22LaplacianSpatialPrior.hess_diag_neglog_pdf()L22LaplacianSpatialPrior.initial_weightsL22LaplacianSpatialPrior.list_edgesL22LaplacianSpatialPrior.neglog_pdf()L22LaplacianSpatialPrior.use_next_nearest_neighborsL22LaplacianSpatialPrior.weights
compute_gradient_from_laplacian()compute_laplacian()compute_neglog_chromatic_from_laplacian2()
- beetroots.modelling.priors.l22_prior module
L22SpatialPriorL22SpatialPrior.DL22SpatialPrior.NL22SpatialPrior.dict_neighborsL22SpatialPrior.dict_sitesL22SpatialPrior.gradient_neglog_pdf()L22SpatialPrior.hess_diag_neglog_pdf()L22SpatialPrior.initial_weightsL22SpatialPrior.list_edgesL22SpatialPrior.neglog_pdf()L22SpatialPrior.neglog_pdf_one_pix()L22SpatialPrior.use_next_nearest_neighborsL22SpatialPrior.weights
- beetroots.modelling.priors.smooth_indicator_prior module
SmoothIndicatorPriorSmoothIndicatorPrior.DSmoothIndicatorPrior.NSmoothIndicatorPrior.gradient_neglog_pdf()SmoothIndicatorPrior.hess_diag_neglog_pdf()SmoothIndicatorPrior.indicator_margin_scaleSmoothIndicatorPrior.lower_boundsSmoothIndicatorPrior.lower_bounds_fullSmoothIndicatorPrior.neglog_pdf()SmoothIndicatorPrior.neglog_pdf_one_pix()SmoothIndicatorPrior.upper_boundsSmoothIndicatorPrior.upper_bounds_full
gradient_penalty()hess_diag_penalty()penalty()penalty_one_pix()
- beetroots.modelling.priors.spatial_prior_params module
- beetroots.modelling.priors.tv_1D_prior module
TVeps1DSpatialPriorTVeps1DSpatialPrior.DTVeps1DSpatialPrior.NTVeps1DSpatialPrior.dict_neighborsTVeps1DSpatialPrior.dict_sitesTVeps1DSpatialPrior.gradient_neglog_pdf()TVeps1DSpatialPrior.hess_diag_neglog_pdf()TVeps1DSpatialPrior.initial_weightsTVeps1DSpatialPrior.list_edgesTVeps1DSpatialPrior.neglog_pdf()TVeps1DSpatialPrior.use_next_nearest_neighborsTVeps1DSpatialPrior.weights
- beetroots.modelling.priors.tv_2D_prior module
TVeps2DSpatialPriorTVeps2DSpatialPrior.DTVeps2DSpatialPrior.NTVeps2DSpatialPrior.dict_neighborsTVeps2DSpatialPrior.dict_sitesTVeps2DSpatialPrior.gradient_neglog_pdf()TVeps2DSpatialPrior.hess_diag_neglog_pdf()TVeps2DSpatialPrior.initial_weightsTVeps2DSpatialPrior.list_edgesTVeps2DSpatialPrior.neglog_pdf()TVeps2DSpatialPrior.use_next_nearest_neighborsTVeps2DSpatialPrior.weights
compute_gradient_from_tv_matrix()compute_tv_matrix()
- Module contents
Submodules
beetroots.modelling.posterior module
- class beetroots.modelling.posterior.Posterior(D: int, L: int, N: int, likelihood, prior_spatial=None, prior_indicator=None, separable: bool = True, dict_sites: Dict[int, ndarray] | None = None)[source]
Bases:
object- D
number of distinct physical parameters
- Type:
int
- L
number of observables per pixel
- Type:
int
- N
number of pixels
- Type:
int
- compute_all(Theta: ndarray, idx_pix: ndarray | None = None, forward_map_evals: dict = {}, nll_utils: dict = {}, compute_derivatives: bool = True, compute_derivatives_2nd_order: bool = True) dict[source]
compute negative log pdf and derivatives of the posterior distribution
- Parameters:
Theta (np.ndarray of shape (N, D)) – current iterate
forward_map_evals (dict[str, np.ndarray], optional) – output of the
likelihood.evaluate_all_forward_map()method, by default {}nll_utils (dict[str, np.ndarray], optional) – output of the
likelihood.evaluate_all_nll_utils()method, by default {}compute_derivatives (bool, optional) – wether to compte derivatives, by default True
- Returns:
negative log pdf and derivatives of the posterior distribution
- Return type:
dict[str, Union[float, np.ndarray]]
- compute_all_for_saver(Theta: ndarray, forward_map_evals: dict[str, float | ndarray], nll_utils: dict) Tuple[dict[str, float | ndarray], ndarray][source]
computes negative log pdf of likelihood, priors and posterior (detailed values to be saved, not to be used in sampling)
- Parameters:
Theta (np.ndarray of shape (N, D)) – current iterate
forward_map_evals (dict[str, Union[float, np.ndarray]]) – output of the
likelihood.evaluate_all_forward_map()methodnll_utils ([str, Union[float, np.ndarray]]) – output of the
likelihood.evaluate_all_nll_utils()method
- Returns:
values to be saved
- Return type:
dict[str, Union[float, np.ndarray]]
- dict_sites
sites for pixels to be sampled in parallel in the MTM-chromoatic Gibbs kernel
- Type:
dict[int, np.ndarray]
- grad_neglog_pdf(Theta: ndarray, idx_pix: ndarray, forward_map_evals: dict[str, float | ndarray], nll_utils: dict[str, float | ndarray]) ndarray[source]
- hess_diag_neglog_pdf(Theta: ndarray, idx_pix: ndarray, forward_map_evals: dict, nll_utils: dict) ndarray[source]
- likelihood
data-fidelity term
- Type:
- mtm_neglog_pdf_priors(Theta: ndarray, idx_pix: ndarray, with_weights: bool | None = True, use_indicator_prior: bool | None = True, use_spatial_prior: bool | None = True, chromatic_gibbs: bool | None = True) ndarray[source]
computes the neg log-prior when only one pixel is modified
- Parameters:
Theta (np.ndarray of shape (N, D)) – current iterate
idx_pix (int) – the index of the pixel to consider (0 <= idx_pix <= N - 1)
list_pixel_candidates (np.ndarray of shape (N_candidates, D)) – the list of all candidates for pixel idx_pi
spatial_weights (Optional[np.ndarray], optional) – vector of shape (D,) containing the weights of the spatial prior, by default None
use_indicator_prior (bool, optional) – wether to use the indicator prior term, by default True
use_spatial_prior (bool, optional) – wether to use the spatial prior term, by default True
- Returns:
the negative log-prior of the candidates
- Return type:
np.ndarray of shape (N_candidates,)
- neglog_pdf(Theta: ndarray, idx_pix: ndarray, forward_map_evals: dict, nll_utils: dict, pixelwise: bool = False, chromatic_gibbs: bool = False) float | ndarray[source]
evaluates the negative log pdf of the posterior at Theta
- Parameters:
Theta (np.ndarray) – point at which the posterior negative log pdf is to be evaluated
forward_map_evals (dict[str, Union[float, np.ndarray]]) – output of the
likelihood.evaluate_all_forward_map()methodnll_utils ([str, Union[float, np.ndarray]]) – output of the
likelihood.evaluate_all_nll_utils()methodpixelwise (bool, optional) – whether to return the prior neg log pdf per pixel, by default False
chromatic_gibbs (bool, optional) – by default False
- Returns:
returns a float if pixelwise is False, otherwise an array of shape (N,)
- Return type:
Union[float, np.ndarray]
- neglog_pdf_priors(Theta: ndarray, idx_pix: ndarray, pixelwise: bool = False, chromatic_gibbs: bool = False) float | ndarray[source]
evaluates the negative log-pdf of the priors
- Parameters:
Theta (np.ndarray) – vector to evaluate
pixelwise (bool, optional) – whether to return the prior neg log pdf per pixel, by default False
- Returns:
returns a float if pixelwise is False, otherwise an array of shape (N,)
- Return type:
Union[float, np.ndarray]
- prior_indicator
prior term encoding validity intervals
- Type:
- prior_spatial
spatial prior term
- Type:
Module contents
Essentially contains the definition of
The forward model (an polynomial regression of a grid of simulations of the Meudon PDR code)
the negative logpdf of the likelihood, prior and posterior, their gradient and the diagonal of their hessian matrix