SGD performs worse than Adam by a significant margin on Transformers, but the reason remains unclear. In this work, we provide an explanation through the lens of Hessian: (i) Transformers are "heterogeneous": the Hessian spectrum across parameter blocks vary dramatically, a phenomenon we call "block heterogeneity"; (ii) Heterogeneity hampers SGD: SGD performs worse than Adam on problems with block heterogeneity. To validate (i) and (ii), we check various Transformers, CNNs, MLPs, and quadratic problems, and find that SGD can perform on par with Adam on problems without block heterogeneity, but performs worse than Adam when the heterogeneity exists. Our initial theoretical analysis indicates that SGD performs worse because it applies one single learning rate to all blocks, which cannot handle the heterogeneity among blocks. This limitation could be ameliorated if we use coordinate-wise learning rates, as designed in Adam.
翻译:在Transformer模型上,SGD的表现显著劣于Adam,但其原因尚不明确。本研究从Hessian矩阵的视角提供解释:(i)Transformer具有“异质性”:不同参数块的Hessian谱差异显著,我们将此现象称为“块异质性”;(ii)异质性损害SGD性能:在存在块异质性的问题上,SGD表现不及Adam。为验证(i)与(ii),我们检测了多种Transformer、CNN、MLP及二次优化问题,发现SGD在无块异质性的问题上可与Adam表现相当,但在存在异质性的情况下表现更差。我们的初步理论分析表明,SGD表现较差是因为其对所有参数块使用单一学习率,无法处理块间的异质性。若采用如Adam所设计的逐坐标学习率,这一局限可能得到改善。