FlowEvaluator¶
Integrates the ODE, denormalizes predictions, and scores them against ground truth in physical units. Evaluation noise uses a fixed seed, so epoch-to-epoch differences reflect the model rather than the draw.
Set ensemble_size > 1 to score the ensemble mean and report spread — the UQ hook.
evaluation
¶
Sampling-Based Validation for Flow Models¶
The flow-matching training loss is a poor model-selection signal. It regresses
the velocity x_1 - x_0 from x_t alone, but many (x_0, x_1) pairs
produce the same x_t, so the loss has a large irreducible floor set by that
ambiguity. Two checkpoints can differ substantially in sample quality while
their losses differ in the fourth decimal.
The quantity you actually care about is the error of solutions produced by
integrating the learned ODE. FlowEvaluator measures exactly that:
it samples through the solver and scores against ground truth in physical
units.
Usage:
evaluator = FlowEvaluator(
objective, val_loader,
normalizer=normalizer, target_fields=val_ds.target_fields,
)
trainer = Trainer(objective, optimizer, validator=evaluator, monitor='rel_l2')
Sampling noise is drawn from a fixed seed, so the same x_0 is used at every
validation call. Without that, epoch-to-epoch differences would be dominated
by which noise happened to be drawn rather than by model improvement.
FlowEvaluator
¶
Evaluate a flow objective by ODE sampling against ground-truth solutions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
objective
|
Any
|
Object exposing |
required |
data_loader
|
Iterable
|
Validation/test loader yielding batches with the configured target and condition keys. |
required |
target_key
|
Optional[str]
|
Batch key holding ground truth. Defaults to the objective's configured key. |
None
|
condition_key
|
Optional[str]
|
Batch key holding conditioning data. Defaults to the objective's configured key. |
None
|
n_steps
|
int
|
ODE integration steps. |
50
|
solver
|
str
|
Solver name passed through to the sampler. |
'euler'
|
max_batches
|
Optional[int]
|
Cap the number of validation batches, for cheap
in-training monitoring. |
None
|
normalizer
|
Optional[Any]
|
|
None
|
target_fields
|
Optional[Sequence[str]]
|
Raw field names composing the target, in channel order
( |
None
|
metrics
|
Optional[List[str]]
|
Metric names for |
None
|
seed
|
int
|
Seed for the fixed evaluation noise. |
0
|
ensemble_size
|
int
|
Samples drawn per condition. With |
1
|
solver_kwargs
|
Any
|
Extra keyword arguments forwarded to the sampler. |
{}
|
Returns from __call__:
Dict of metric name → float. With ensemble_size > 1 each
configured metric is also reported under mean_<name> (so the
default metric list yields mean_rel_l2), plus sample_spread.
Source code in flowpde/trainers/evaluation.py
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 | |
__call__()
¶
Run one validation pass and return averaged metrics.
Source code in flowpde/trainers/evaluation.py
146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 | |