nvalchemi.training.evaluating#

nvalchemi.training.evaluating(module)[source]#

Temporarily put a module tree in evaluation mode.

Parameters:

module (torch.nn.Module) – Module whose whole tree is switched to evaluation mode. Every submodule’s own training flag is restored on exit, so a child left in training mode under an evaluation-mode root, or frozen on its own, comes back exactly as it was.

Yields:

None – Control while the module tree is in evaluation mode.

Return type:

Iterator[None]

Notes

torch.nn.Module.train() is recursive, so restoring the root’s flag alone would overwrite every child’s flag with the root’s. This helper records and restores each submodule individually.