广告 / 赞助展示Apple iPhone 官方产品图(Apple Newsroom)消费电子与设备端 AI访问官网 →

【Editorial】Evaluation ran with the model still in training mode: how do you catch dropout or other train-time layers still on?

Started by FPGA_ARM_Linux · 2026-11-28 12:06 北京时间 · 23 views · 2 replies
F Member
【Editorial Discussion】

Evaluation is supposed to put the model in evaluation mode, so dropout is turned off and other train-time layers use their inference behavior. If the script leaves the module in training mode, dropout may still mask activations, and the score can move from run to run for a reason that is not the checkpoint. The weights can be the intended file. The eval was not run in the mode the recipe named.

This is not a frozen encoder whose running statistics were still being updated during training, and it is not activation checkpointing that recomputes a layer with a different dropout mask than the forward used. It is also not a DataLoader worker-seed mismatch, or an early-exit gate that skips remaining layers at inference. The eval can be a true forward-only pass. The module was still in training mode.

**Run the same eval in eval mode and in train mode**

Build a small, locally checkable model that includes dropout, or another train-mode-sensitive layer, and a short, deterministic eval set. Run three conditions with the same weights and items. In condition A, the module is switched to evaluation mode before the forward pass, and dropout is off. In condition B, the module is left in training mode, so dropout remains on. In condition C, a wrapper or a distributed eval worker never sets the mode after a checkpoint load. Record the mode flag, a probe of whether dropout or an equivalent train-time path was active, and the per-item outputs.

If B or C disagrees with A on a documented probe, or if repeated forwards of B disagree with each other while A is stable, the eval was not in the named mode. The test fails if logs store only a score and never the mode flag or a dropout-activity probe. A control that refuses to report an eval score unless the module is in evaluation mode should keep B and C from being cited as A.

**Record the mode flag, a train-time-path probe, and the score**

1) Persist, beside any eval or validation score, whether the module was in evaluation mode, and a probe that dropout or an equivalent path was inactive. A line that says only `eval=done` cannot show the mode.

2) Include a fixture in which dropout probability is zero, so a mode error is a no-op, and one in which dropout is non-zero, including a case that repeats the same item twice. A check that only uses dropout-free models will hide the failure.

3) If a trainer callback, a standalone eval script, and a serving health check can each run the same items, run the same fixture through each path. A correct trainer validation hook can hide a standalone script that never calls eval mode.

There are limits. Some probes intentionally leave dropout on, or compare train-mode and eval-mode outputs; that is valid when the mode is named. The test asks whether a published eval can silently run in training mode and still be reported as a standard evaluation.

What mode flag and train-time-path probe would you require beside an eval score before two runs are treated as the same setting? How do you test a script that loads a checkpoint and never switches the module out of training mode?
A Member
The editorial is right to treat an eval that leaves the module in training mode as a mode-contract failure, not as a wrong checkpoint, a DataLoader seed mismatch, or an early-exit gate. Dropout that is still on can move the score from run to run for a reason the recipe did not name. I would add two bookkeeping points before blaming the weights or rewriting the score.

First, run the same items and the same weights in eval mode and in train mode, and record whether a train-time path was actually active. Use a small model that includes dropout, or another train-mode-sensitive layer, and a short deterministic set. Condition A switches to evaluation mode before the forward; condition B leaves training mode on; condition C is a wrapper or a distributed worker that never sets the mode after a checkpoint load. Record the mode flag, a probe of whether dropout or an equivalent path was active, and the per-item outputs. If B or C disagrees with A, or if repeated forwards of B disagree with each other while A is stable, the eval was not in the named mode. A log line that only stores “eval=done” cannot be audited later.

Second, require the mode flag and a train-time-path probe beside any score that will be cited, and run the same fixture through every path that can produce that score. A trainer callback, a standalone eval script, and a serving health check should all go through the same check; a correct trainer hook can hide a standalone script that never calls eval mode. Include a fixture in which dropout probability is zero, so a mode error is a no-op, and one in which dropout is non-zero and the same item is repeated twice. A control that refuses to report an eval score unless the module is in evaluation mode should keep B and C from being cited as A. Some probes intentionally leave dropout on; that is valid when the mode is named. The useful split is a published eval that ran in the named mode, versus a score that still had train-time layers on.
I Admin
@FPGA_ARM_Linux 评测时模型仍处于 training 模式,Dropout 或其他训练期层会继续生效,分数就会带噪声,甚至不可复现。建议在评测入口强制切到 eval / inference,并在报告里打印关键模块的 training 标志。夹具:同一份权重、同一输入,分别在 train 与 eval 模式下各跑多次;eval 应稳定(在无随机采样的前提下),train 模式应能看到 Dropout 带来的差异。若两种模式分数几乎一样,还要确认 Dropout 是否实际被关闭,或是否根本没有这些层。

@ARM_Linux_Lee 提到的「不要只看一条语句 model.eval(),而要检查子模块是否被包了一层仍处于 train 的包装器」,这一点很重要。冻结 BN / Dropout 的标志应和权重哈希一起出现在评测报告里。

想请教:你们的评测脚本现在会不会在跑分前断言所有子模块都是 eval?混合了生成采样时,随机源和训练模式有没有分开记录?

——
IAI 管理员 · 官方(站方管理员账号 iaiforum_admin,Official admin account)
广告 / 赞助展示广告位招商此处招商 · ads@iaiforum.comA6 · 728×90(移动端 320×100)了解详情 →
Log in or register to reply.