Validation (validate_spec / validate_capture)
If a ModelSpec disagrees with the real model, the inference log may not be recorded correctly.
Always validate once against the real model before saving or using a spec.
from ml_debugger.spec import validate_spec
report = validate_spec(spec, model, sample_batch) # ground_truth=... is accepted too
print(report.summary()) # a multi-line summary of every finding
report.raise_if_errors() # raise if there are any errors
if report.ok: # True when there are zero errors
... # inspect report.errors / report.warnings / report.infos
spec.verify(model, sample_batch) runs the same checks as a method. Either is fine.
report = spec.verify(model, sample_batch)
report.raise_if_errors()
Each finding carries severity (error / warning / info), code, message, and check
(the check group). A single error must be fixed before you use the spec.
Checking the recorded rows too (validate_capture)
validate_capture runs the same checks as validate_spec, then actually records the sample
through the ordinary recording path and checks what was recorded: whether every prediction was
stored with usable values, whether the per-class confidences match the declaration, how many rows
each input produced, and — when ground_truth is given — whether the ground truth shares the
predictions' coordinate space and the predictions land on it. Run it before you start collecting.
from ml_debugger.spec import validate_capture
report = validate_capture(spec, model, sample_batch, ground_truth=ground_truth)
print(report.summary())
report.raise_if_errors()
- The recording goes into a throwaway local database and is deleted afterwards; nothing is sent to the server.
ground_truthis optional. Without it only the prediction side is checked, and the ground-truth checks are reported as not run.- For a spec with
heads, pass the ground truth as{head name: ground truth}.
Recommended procedure
- Write the
ModelSpecusing the per-field pages. - Run
validate_spec(spec, model, sample_batch)and clear every error inreport.summary(). - Run
validate_capture(spec, model, sample_batch, ground_truth=...)to confirm the recorded rows too.
What each check group means
Findings are grouped by check. When something is reported, review that group's concern and the
corresponding field declaration.
| Check group | What it looks at | Field to review |
|---|---|---|
model-call |
Whether the inference call succeeds at all | invoke= / inputs= |
output |
Whether the declared structure resolves against the real output, and whether boxes / scores / labels / class_confs have matching row counts | output= / raw_output= |
class-confs |
Whether the per-class confidence width matches n_class (+ background) and the highest column agrees with the predicted class |
labels= |
n-class |
Whether the attribute named by NClassFrom exists on the model |
labels= |
coords |
Whether the box scale is plausible (declared pixel but all values ≤ 1, …) and coordinates do not flip after conversion | output= |
score |
Whether scores fall in [0, 1] after the declared activation | output= |
image-size |
Whether an image size is available to restore normalized coordinates | inputs= / size_from= |
nms |
Whether the declared NMS threshold attributes are readable/writable and consistent with the model's final detections | postprocess= |
candidates |
Whether the model's candidate boxes outnumber the final detections | raw_output= |
postprocess |
Whether your custom post-processing function runs without raising | postprocess= |
head-hook |
Whether the layer named by HeadHook actually yields an output |
raw_output= |
gt |
Whether GT boxes resolve and share the coordinate space of the predictions | labels= |
empty |
Whether the zero-detection case resolves as declared | output= |
parse-hook |
Whether an injected end-to-end parse succeeded | — |
spec |
Whether the ModelSpec itself is valid |
— |
class-confs and nms are empirical checks
These two detect declaration mistakes empirically, from measured agreement rates and
consistency with the final detections. When they warn, review the S.LabelId base, the
S.ClassConfs background channel, and the S.Coords format / scale first.
Common findings and what to do
| Symptom | What to suspect |
|---|---|
| Boxes all look like 0–1, or land outside the image | Wrong scale on S.Coords, or no reference size → output= |
| Classes are off by one | The S.LabelId(base) base or the S.ClassConfs(background) position → labels= |
| Reported as having fewer candidates than detections | The candidates point at the final output → declare raw_output= with a hook |
| The model call fails | The invoke= method / kwargs / unpacking → invoke= |
If a finding persists, send us the report.summary() output at
support@adansons.ai.