Deep Learning / Representation and acceptance evidence / Lesson 18
Ablations and inference acceptance
Assemble mathematical, experimental, and input-contract evidence before accepting a network.
On this page
Lesson goals
- Design a fair architectural ablation.
- Validate a complete input-to-output contract.
- Write acceptance criteria that match the intended use.
Ablation asks a specific counterfactual design question
An ablation compares a procedure with and without a component under controlled conditions. State whether the question concerns representation, optimization, parameter count, compute budget, or final task performance. Removing a block can alter all of these, so a single comparison rarely isolates every explanation. Keep splits, objective, selection rules, and measurement conditions consistent, and report changes that cannot be held equal. Pair comparable trials where justified, but do not treat different random draws or datasets as interchangeable. A convincing average improvement still needs uncertainty and relevant slices rather than only a favorable headline.
The inference function includes preprocessing and meaning
The accepted function starts at a documented input boundary and ends with a documented output, not merely a weight matrix. Feature order, scaling, missingness, valid ranges, class mapping, thresholds, and mode can all affect behavior. The first fixture defines a narrow two-feature score and rejects malformed or nonfinite inputs with one explicit error. Its linear rule is deliberately simple so contract behavior is visible. A real application needs a justified policy for unsupported inputs and should avoid silently substituting plausible-looking numbers that change the task without recording the change.
from math import isfinite
def predict(row):
if len(row) != 2 or not all(isinstance(x,(int,float)) and not isinstance(x,bool) and isfinite(x) for x in row):
raise ValueError("expected two finite numeric features")
length, width = row
return 2*length - width
print(predict([3.0, 1.0]))
try:
predict([3.0, float("nan")])
except ValueError as error:
print(str(error))
5.0
expected two finite numeric features
A narrow synthetic inference contract rejects nonfinite or malformed inputs before evaluating the fixed score.
Check equivalence at boundaries that matter
Compare a saved-and-restored or transformed model against a reference using known valid cases, boundary cases, and permitted batches. Decide whether equality means exact labels, probabilities within tolerance, or downstream decisions under an error budget. A small logit difference near a threshold can change a decision even when a global numeric error is tiny. Check individual examples as well as aggregate loss. If batch-dependent state is unintended at inference, verify that adding unrelated companions does not change a fixed example. These tests connect earlier lessons on shape, masking, mode, precision, and checkpoint state.
Interpret a paired comparison within its scope
The second fixture calculates three invented paired loss improvements from adding a block. All are positive and their mean is 0.03. This arithmetic is not a confidence interval, a significance test, or evidence of real external quality. A small number of selected trials can be misleading, and selection across many ablations consumes validation evidence. Record the complete comparison set and any negative results relevant to the decision. Also report resource changes and maintenance implications. A more complex network can be rejected when its benefit is uncertain or does not justify its cost under the intended contract.
baseline = [0.40, 0.42, 0.38]
with_block = [0.35, 0.39, 0.37]
differences = [b-c for b,c in zip(baseline,with_block)]
print("paired improvements", [round(x,2) for x in differences])
print(f"mean improvement={sum(differences)/len(differences):.2f}")
print("all positive", all(x > 0 for x in differences))
paired improvements [0.05, 0.03, 0.01]
mean improvement=0.03
all positive True
Three invented paired loss comparisons illustrate an ablation summary, not statistical significance or external performance.
Acceptance is a documented decision under limitations
Set primary performance criteria, important slices, calibration or abstention requirements when relevant, resource limits, invalid-input behavior, and a fallback before inspecting final outcomes. Require the same input and label contracts used in evaluation, and identify conditions outside the supported scope. Passing tiny synthetic checks establishes local arithmetic and boundary behavior, while held-out evidence assesses a declared population; neither alone establishes all required properties. Keep the decision and its evidence reviewable. The framework tracks implement tensor-specific training and serialization, and MLOps handles ongoing lifecycle controls; this conceptual course ends with the evidence needed to hand those implementations a precise task.
Common errors and fixes
An ablation changes several factors but claims one cause
- Why it happens
- Capacity, optimization budget, and preprocessing moved together.
- How to fix it
- Narrow the question or report the confounded design honestly.
- Prevent it next time
- Write controlled variables and unavoidable changes before running.
A transformed model has close logits but different actions
- Why it happens
- A decision threshold lies near the small numeric difference.
- How to fix it
- Evaluate the actual downstream decision contract and tolerances.
- Prevent it next time
- Include threshold-near examples in equivalence checks.
Acceptance criteria appear after the final score
- Why it happens
- The decision rule was adapted to assessment outcomes.
- How to fix it
- Define criteria with permitted selection evidence and protect final evaluation.
- Prevent it next time
- Record criteria and known limitations before final assessment.
Check your understanding
1. A block lowers average validation loss but doubles latency beyond the agreed limit. Should it automatically be accepted?
Show worked solution
No. The acceptance contract includes both predictive evidence and resource limits. Check whether a justified redesign or changed requirement is authorized, otherwise prefer a candidate meeting the existing contract. A lower average loss alone cannot override a stated operational limit.
2. Give three contract tests beyond checking a model file loads.
Show worked solution
Check a known input with documented feature order and expected output; reject malformed or nonfinite inputs with the declared policy; and compare a fixed example alone versus with unrelated batch companions under inference mode. Add threshold-near and round-trip cases where they affect decisions.
Key takeaways
- An ablation needs a clearly controlled question.
- The accepted model includes input and decision semantics.
- Acceptance criteria and limitations precede final assessment.