arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2405.13698cs.LGcs.AI
收藏

如何在扩大模型和数据集规模时设置AdamW的权重衰减

How to set AdamW's weight decay as you scale model and dataset size

Johns Hopkins University(约翰斯·霍普金斯大学);University of Bristol(布里斯托大学)

Xi Wang, Laurence Aitchison

AI总结:

研究AdamW权重衰减随模型和数据集规模的扩展规律,提出将其视为近期更新的指数移动平均,发现最优EMA时间尺度以epoch为单位大致恒定,从而推导出权重衰减的缩放规则,并验证了其对muP学习率缩放稳定性的重要性。

摘要:

随着我们寻求构建更大的模型,最优AdamW权重衰减超参数随模型和数据集规模的扩展变得至关重要,但目前对此理解甚少。我们表明,由AdamW学习到的权重可以被理解为近期更新的指数移动平均(EMA)。这为如何设置AdamW中的权重衰减,以及权重衰减应如何随模型和数据集规模扩展提供了关键见解。具体而言,指数移动平均的关键超参数是EMA时间尺度。直观上,EMA时间尺度可以理解为EMA所平均的近期迭代次数。我们发现,以epoch为单位测量的最优时间尺度,在我们改变模型和数据集规模时大致保持恒定。此外,给定学习率,从EMA时间尺度到权重衰减超参数存在一一映射。因此,如果最优EMA时间尺度是恒定的,这意味着随着数据集规模增加,最优权重衰减应该下降;而随着模型规模增加,最优权重衰减应该上升(如果我们遵循muP关于缩放学习率的建议)。我们在CIFAR-10和ImageNet上训练的ResNet-18和Vision Transformers,以及在OpenWebText上进行预训练的NanoGPT上验证了这些缩放规则。最后,我们发现,随着训练的进行,除非适当地缩放权重衰减,否则muP的学习率缩放对于AdamW会失效。

英文摘要:

The scaling of the optimal AdamW weight decay hyperparameter with model and dataset size is critical as we seek to build larger models, but is poorly understood. We show that weights learned by AdamW can be understood as an exponential moving average (EMA) of recent updates. This gives critical insights for how to set the weight decay in AdamW, and how the weight decay should scale with model and dataset size. In particular, the key hyperparameter for an exponential moving average is the EMA timescale. Intuitively, the EMA timescale can be understood as the number of recent iterations the EMA averages over. We find that the optimal timescale, measured in epochs, is roughly constant as we change model and dataset size. Moreover, given a learning rate, there is a one-to-one mapping from the EMA timescale to the weight decay hyperparameter. Thus, if the optimal EMA timescale is constant, that implies that as the dataset size increases, the optimal weight decay should fall and as the model size increases, the optimal weight decay should increase (if we follow the muP recommendation for scaling the learning rate). We validate these scaling rules on ResNet-18 and Vision Transformers trained on CIFAR-10 and ImageNet, and on NanoGPT pre-training on OpenWebText. Finally, we found that as training progresses, muP's learning rate scaling breaks down for AdamW unless weight decay is scaled appropriately.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑