setu.tune_nle#
- setu.tune_nle(dataset, *, x_dim=None, theta_dim=None, condition_dim=0, search_space=None, n_trials=50, val_fraction=0.1, batch_size=256, max_epochs=1000, max_patience=30, pruning=True, seed=None, study_name=None, storage=None, show_progress=True, baseline_params=None, key)[source]#
Tune NLE hyperparameters with Optuna.
Searches over flow architecture, network size, activation, and learning rate, returning the best NLE by validation loss. Replaces
create_nle+fit_nlewhen you want automatic architecture selection.Requires optuna:
pip install setu-sbi[tuning].- Parameters:
dataset (
SimulationDataset) – Training data (parameters and observations) to tune on.x_dim (
int|None) – Observation dimension. Inferred fromdatasetifNone.theta_dim (
int|None) – Parameter dimension. Inferred fromdatasetifNone.condition_dim (
int) – Per-trial condition dimension;0for no conditions.search_space (
NLESearchSpace|None) – Hyperparameter ranges to search. A defaultNLESearchSpaceis used ifNone.n_trials (
int) – Number of Optuna trials (architectures) to evaluate.val_fraction (
float) – Fraction ofdatasetheld out to compute validation loss.batch_size (
int) – Minibatch size used when training each trial.max_epochs (
int) – Maximum training epochs per trial.max_patience (
int) – Early-stopping patience, in epochs without validation improvement.pruning (
bool) – IfTrue, prune unpromising trials early with Optuna’s median pruner.seed (
int|None) – Seed for the Optuna sampler, for reproducible searches.storage (
str|None) – Optuna storage URL (e.g. an SQLite path) for persisting the study; in-memory ifNone.show_progress (
bool) – IfTrue, display Optuna’s progress bar.baseline_params (
dict[str,Any] |None) – Hyperparameters for a baseline trial enqueued before the search, for comparison against the tuned result.key (
Array) – JAX PRNG key for model initialization and training.
- Return type:
- Returns:
A
TuningResultholding the best NLE, its hyperparameters, and the completed Optuna study.