shine.inference¶
Bayesian inference engine supporting NUTS/MCMC, MAP, and Variational Inference.
Dispatches on InferenceConfig.method to run one of three inference paths.
All methods return ArviZ InferenceData so the downstream pipeline works
uniformly.
inference
¶
Inference(model, config)
¶
Inference engine supporting NUTS/MCMC, MAP, and Variational Inference.
All three methods return az.InferenceData so the downstream pipeline (extraction, diagnostics, plots) works uniformly.
Initialize the inference engine.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
Callable
|
NumPyro model function (the forward generative model). |
required |
config
|
InferenceConfig
|
Inference configuration. |
required |
Source code in shine/inference.py
run_map(rng_key, observed_data, extra_args=None, map_config=None)
¶
Run MAP estimation to find maximum a posteriori parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rng_key
|
PRNGKey
|
JAX random key. |
required |
observed_data
|
ndarray
|
Observed image data. |
required |
extra_args
|
Optional[Dict[str, Any]]
|
Extra keyword arguments passed to the model (e.g., psf). |
None
|
map_config
|
Optional[MAPConfig]
|
MAP configuration (defaults to MAPConfig() if None). |
None
|
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
Dictionary of MAP parameter estimates. |
Source code in shine/inference.py
run_vi(rng_key, observed_data, extra_args=None)
¶
Run Variational Inference with AutoNormal guide.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rng_key
|
PRNGKey
|
JAX random key. |
required |
observed_data
|
ndarray
|
Observed image data. |
required |
extra_args
|
Optional[Dict[str, Any]]
|
Extra keyword arguments passed to the model (e.g., psf). |
None
|
Returns:
| Type | Description |
|---|---|
InferenceData
|
ArviZ InferenceData with posterior samples from the fitted guide. |
Source code in shine/inference.py
run_mcmc(rng_key, observed_data, extra_args=None, init_params=None)
¶
Run MCMC inference using the NUTS sampler.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rng_key
|
PRNGKey
|
JAX random key. |
required |
observed_data
|
ndarray
|
Observed image data. |
required |
extra_args
|
Optional[Dict[str, Any]]
|
Extra keyword arguments passed to the model (e.g., psf). |
None
|
init_params
|
Optional[Dict[str, Any]]
|
Optional initial parameters (e.g., from MAP estimation). |
None
|
Returns:
| Type | Description |
|---|---|
InferenceData
|
ArviZ InferenceData object with posterior samples. |
Source code in shine/inference.py
run(rng_key, observed_data, extra_args=None)
¶
Run inference pipeline, dispatching on the configured method.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rng_key
|
PRNGKey
|
JAX random key. |
required |
observed_data
|
ndarray
|
Observed image data. |
required |
extra_args
|
Optional[Dict[str, Any]]
|
Extra keyword arguments passed to the model (e.g., psf). |
None
|
Returns:
| Type | Description |
|---|---|
InferenceData
|
ArviZ InferenceData object with posterior samples/estimates. |