geoprior.models.forecast_tuner._base_tuner#
Base classes and utilities for hyperparameter tuning of PINN models.
Classes
|
Base class for hyperparameter tuning of physics-informed models. |
- class geoprior.models.forecast_tuner._base_tuner.PINNTunerBase(objective='val_loss', max_trials=10, project_name='PINN_Tuning', directory='pinn_tuner_results', executions_per_trial=1, tuner_type='randomsearch', seed=None, overwrite_tuner=True, _logger=None, **tuner_kwargs)[source]#
Bases:
HyperModel,BaseClassBase class for hyperparameter tuning of physics-informed models.
This class wraps keras-tuner orchestration for GeoPrior PINN-style models. Subclasses are expected to implement
build(hp).- Parameters:
objective (
strorkeras_tuner.Objective, default"val_loss") – Metric to optimize during the search.max_trials (
int, default10) – Maximum number of hyperparameter trials to evaluate.project_name (
str, default"PINN_Tuning") – Project name used for tuner artifacts.directory (
str, default"pinn_tuner_results") – Root directory for tuner outputs.executions_per_trial (
int, default1) – Number of repeated trainings per sampled hyperparameter set.tuner_type (
{"randomsearch", "bayesianoptimization", "hyperband"}, default"randomsearch") – Search backend used by keras-tuner.seed (
intorNone, defaultNone) – Random seed used for reproducibility.overwrite_tuner (
bool, defaultTrue) – Whether to overwrite an existing tuner project directory.tuner_kwargs (
dict) – Additional keyword arguments forwarded to the underlying tuner backend.
- Variables:
best_hps (
keras_tuner.HyperParametersorNone) – Best hyperparameters discovered during tuning.best_model (
tf.keras.ModelorNone) – Best compiled model recovered from the tuner.tuner (
keras_tuner.TunerorNone) – Underlying tuner instance.tuning_summary (
dict) – Compact summary of the completed tuning run.
- __init__(objective='val_loss', max_trials=10, project_name='PINN_Tuning', directory='pinn_tuner_results', executions_per_trial=1, tuner_type='randomsearch', seed=None, overwrite_tuner=True, _logger=None, **tuner_kwargs)[source]#
Initialize the base class.
- Parameters:
- build(hp)[source]#
Builds and compiles the Keras model with hyperparameters.
This method must be overridden by subclasses (e.g., PIHALTuner) to define the specific model architecture (like PIHALNet), sample hyperparameters using the hp object based on self.param_space, and compile the model.
- Args:
hp (kt.HyperParameters): Keras Tuner HyperParameters object.
- Returns:
tf.keras.Model: The compiled Keras model.
- Parameters:
hp (HyperParameters)
- Return type:
Model
- search(train_data, epochs, validation_data=None, callbacks=None, verbose=1, patience=10, **additional_search_kwargs)[source]#
Performs the hyperparameter search using Keras Tuner.
- Parameters:
train_data (
tf.data.Dataset) – Training dataset. Must yield tuples of(inputs_dict, targets_dict)compatible with the model’strain_step.epochs (
int) – Number of epochs to train each model during a trial.validation_data (
tf.data.DatasetorNone, defaultNone) – Validation dataset.callbacks (
listoftf.keras.callbacks.CallbackorNone, defaultNone) – Keras callbacks for the search phase.verbose (
int, default1) – Verbosity level for Keras Tuner search.patience (
int, default10) – Early-stopping patience.**additional_search_kwargs – Additional keyword arguments passed to the tuner
search()method.
- Returns:
- Return type:
tuple[Model | None, HyperParameters | None, Tuner | None]
- help(**kwargs)#
- my_params = PINNTunerBase( objective='val_loss', max_trials=10, project_name='PINN_Tuning', directory='pinn_tuner_results', executions_per_trial=1, tuner_type='randomsearch', seed=None, overwrite_tuner=True, _logger=None )#