背景
PyTorch 1.6版本今天釋出了,帶來的最大更新就是自動混合精度。release說明的标題是:
- Stable release of automatic mixed precision (AMP).
- New Beta features include a TensorPipe backend for RPC, memory profiler,
- and several improvements to distributed training for both RPC and DDP.
可見自動混合精度正是PyTorch 1.6的最大更新。這就帶來了幾個問題:
- 什麼是自動混合精度訓練?
- 為什麼需要自動混合精度?
- 如何在PyTorch中使用自動混合精度?
什麼是自動混合精度訓練?
我們知道神經網絡架構的計算核心是Tensor,也就是那個從scaler -> array -> matrix -> tensor 次元一路豐富過來的tensor。在PyTorch中,我們可以這樣建立一個Tensor:
PyTorch的自動混合精度(AMP) - 知乎