sage.factory.validation
Sage validation loop.
- SageVanillaValidation
Mirrors SageVanillaTraining exactly except the model runs in eval + inference_mode, and per-epoch outputs (network predictions, targets, raw parameters) are saved to an HDF5 file for offline diagnostics (ROC curves, parameter recovery, etc.).
Classes
Standard Sage validation loop with full diagnostic output saving. |
Functions
|
Append one epoch's validation results to an HDF5 file. |
Module Contents
- save_validation(nepoch, output, target, params, signal_idx, savepath)[source]
Append one epoch’s validation results to an HDF5 file.
Creates a group
epoch_{nepoch:04d}insidesavepathcontaining four gzip-compressed datasets.- Parameters:
nepoch (int) – Epoch index (used as the HDF5 group name).
output (torch.Tensor, shape
(N, 1 + 2*num_pe)) – Network outputs: ranking statistic, predicted means, predicted sigmas (in physical units).target (torch.Tensor, shape
(N, num_pe + 1)) – Ground-truth targets (regression values + class label).params (torch.Tensor, shape
(N, num_params)) – Raw waveform parameters (theta) returned by the signal sampler.signal_idx (torch.Tensor, shape
(num_iter, S)) – Batch positions where signals were injected for each iteration.savepath (str) – Path to the HDF5 output file.
- class SageVanillaValidation(signal_sampler, noise_sampler, processor, model, loss_function, num_iterations, num_epochs)[source]
Bases:
torch.nn.ModuleStandard Sage validation loop with full diagnostic output saving.
Mirrors
SageVanillaTrainingbut:Runs the model in
eval+inference_mode.Calls
signal_sampler(return_theta=True)to obtain raw waveform parameters for parameter-recovery diagnostics.Unstandardises predicted means back to physical units.
Converts the raw sigma params to sigma via softplus (matching the loss’s
_sigma), then un-standardises to physical units.Writes per-epoch results to
{export_dir}/validation_data.h5.
Auto-multibanding and GWBatch tracking work identically to the training loop — no extra configuration needed.
- Parameters:
signal_sampler – Same objects passed to the corresponding training class.
noise_sampler – Same objects passed to the corresponding training class.
processor – Same objects passed to the corresponding training class.
model – Same objects passed to the corresponding training class.
loss_function – Same objects passed to the corresponding training class.
num_iterations (int) – Number of batches per validation epoch.
num_epochs (int) – Total epochs (pre-allocates the
loss_componentstracking tensor).state (Initialize internal Module)
ScriptModule. (shared by both nn.Module and)