geoprior.utils.target_utils#
Target-processing helpers for GeoPrior workflows.
Functions
|
Convert obj to an ordered tuple of outputs. |
|
Try to obtain stable output names (best-effort, Keras-3-safe). |
|
Keras-3-safe compiled metrics updater. |
- geoprior.utils.target_utils.get_output_names(model=None, y=None, y_pred=None, *, exclude_keys={'aux', 'data_final', 'data_mean_raw', 'maps', 'phys_final', 'phys_mean_raw', 'physics'})[source]#
Try to obtain stable output names (best-effort, Keras-3-safe).
Lookup priority is:
model._output_keysormodel._output_namesfirst, thenmodel.output_names, then keys fromy_pred, and finally keys fromy.
- geoprior.utils.target_utils.as_tuple(obj, *, names=None, model=None, ctx='value', strict=True, exclude_keys={'aux', 'data_final', 'data_mean_raw', 'maps', 'phys_final', 'phys_mean_raw', 'physics'}, to_numpy='never')[source]#
Convert obj to an ordered tuple of outputs.
- Supports:
dict: ordered by names (or inferred)
list/tuple: returns tuple(obj)
tensor/ndarray/scalar: returns (obj,)
- Parameters:
obj (
Any) – Targets/predictions container.names (
list[str]orNone) – Desired order of outputs.model (
AnyorNone) – Model used to infer output names (via _output_keys/output_names).strict (
bool) – If True, missing keys in dict raises KeyError.to_numpy (
{"never","auto","always"}) – Optional conversion of individual leaves to numpy (only safe in eager).
- Returns:
Ordered outputs.
- Return type:
- geoprior.utils.target_utils.update_compiled_metrics(model, y_true, y_pred, *, output_names=None, to_numpy='never')[source]#
Keras-3-safe compiled metrics updater.
Prefers dict structure (since you compiled with dict loss/metrics).
Ensures deterministic output order via output_names/_output_keys.
Falls back to list/tuple update_state if needed.
Final fallback: manual per-metric update (won’t crash training).
Note: converting to numpy inside train_step is generally NOT safe.