人工智能:Pytorch训练可重复性(Reproducibility)
在不同的 PyTorch 版本或不同平台上,不能保证完全可复现的结果。此外,即使使用相同的随机种子,CPU 和 GPU 执行之间的结果也可能无法复现。但是,您可以采取措施来限制平台、设备和 PyTorch 版本的非确定性行为来源。首先,您可以控制随机性的来源,这些来源会导致应用程序的多次执行表现不同。其次,您可以将 PyTorch 配置为避免对某些操作使用非确定性算法,以便在给定相同输入的情况下,对这些操作的多次调用将产生相同的结果。最后,在执行多进程数据加载时还需注意控制加载的随机性工作进程种子。本文内容参考 Pytorch 官方文档:https://pytorch.org/docs/stable/notes/randomness.html#controlling-sources-of-randomness
Deterministic operations are often slower than nondeterministic operations, so single-run performance may decrease for your model. However, determinism may save time in development by facilitating experimentation, debugging, and regression testing.