raw_output= — Raw Output Shape and Location
raw_output= declares the model's raw output — what exists before post-processing — and where it lives.
Where output= describes the final output the model call returns, raw_output= describes the value
just upstream of it. If your model's return value already is the final detections you do not need it;
as a rule, you declare it alongside postprocess=, as the input that feeds it.
What postprocess= holds |
raw_output= |
|---|---|
TopK(...) |
Required (unless you declare TopK(decode=...)) |
| A custom post-processing function | Required — it is the function's input |
NMS(custom=<selection fn>) / an S.KeepIndex leaf |
Required — declares where the candidates are, via hook= |
NMS(...) (a plain NMS only) |
Optional |
from ml_debugger.spec import RawOutputSchema, LayerHook
from ml_debugger.spec import schema as S
RawOutputSchema fields
| Field | Type | Contents |
|---|---|---|
structure |
structure node | The raw-output container structure. Omit it when the callable passed to postprocess= consumes the raw output directly |
hook |
LayerHook / HeadHook |
Where the raw output is captured. Omitted = the model's return value; set = that module's forward output |
At least one of structure / hook is required (omitting both raises at construction time).
A structure node passed straight to raw_output= becomes RawOutputSchema(structure=...).
How to write it
# (a) the raw output is part of the return value: pass the structure only
raw_output=S.Dict(
logits=S.DetAxis[S.ClassConfs(3, "softmax", "last")], # (B, Q, C)
pred_boxes=S.DetAxis[S.Coords("cxcywh", "normalized")], # (B, Q, 4)
)
# (b) the raw output lives elsewhere (a layer output): point at it with a hook
raw_output=RawOutputSchema(
S.Dict(
cls_logits=S.DetAxis[S.ClassConfs(3, "raw", "none")],
box_preds=S.DetAxis[S.Coords("cxcywh", "normalized")],
),
hook=LayerHook("cls_head"),
)
# (c) location only (the structure follows from the post-processing declaration)
raw_output=RawOutputSchema(hook=LayerHook("cls_head"))
Pointing at the location: LayerHook / HeadHook
| Hook | What it captures | Field |
|---|---|---|
LayerHook("layer.name") |
That layer's forward output | layer: a path from named_modules() |
HeadHook("head.name") |
The whole detection-head output (used for query-head models) | layer: a path from named_modules() |
raw_output=RawOutputSchema(hook=LayerHook("cls_head"))
raw_output=RawOutputSchema(structure, hook=HeadHook("pts_bbox_head"))
Finding layer names
for name, _ in model.named_modules():
print(name)
Classification
For classification, the location of the prediction resolves the same way whether you write it in
output= or raw_output= (if both are given, raw_output= wins).
The draft produced by AutoMode uses raw_output=.
spec = ModelSpec(
labels=LabelSchema(n_class=1000),
raw_output=S.Dict(logits=S.ClassConfs(activation="raw")),
)
Related pages
- postprocess= — raw output → final output
- output= — the final output structure
- Validation — the
head-hookcheck group