SGD (with momentum) and AdamW are the two most used optimizers for fine-tuning large neural networks in computer vision. When the two methods perform the same, SGD is preferable because it uses less memory (12 bytes/parameter) than AdamW (16 bytes/parameter). However, on a suite of downstream tasks, especially those with distribution shifts, we show that fine-tuning with AdamW performs substantially better than SGD on modern Vision Transformer and ConvNeXt models. We find that large gaps in performance between SGD and AdamW occur when the fine-tuning gradients in the first "embedding" layer are much larger than in the rest of the model. Our analysis suggests an easy fix that works consistently across datasets and models: merely freezing the embedding layer (less than 1\% of the parameters) leads to SGD performing competitively with AdamW while using less memory. Our insights result in state-of-the-art accuracies on five popular distribution shift benchmarks: WILDS-FMoW, WILDS-Camelyon, Living-17, Waterbirds, and DomainNet.
翻译:SGD (具有动力) 和 AdamW 是计算机视觉中微调大型神经网络最常用的两种优化器。 当两种方法都使用相同时, SGD 更可取,因为它比 AdamW (16 字节/ 参数) 使用较少的内存(12 字节/ 参数) 。 但是, 在一组下游任务中, 特别是分布变换的下游任务中, 我们显示与 AdamW 的微调比 SGD 在现代视觉变换器和ConvNeXt 模型上的SGD表现要好得多。 我们发现, SGD 和 AdamW 之间的性能差距很大, 当第一个“ 组合” 层的微调梯度比模型的其余部分大得多时。 我们的分析表明, 一种在数据集和模型之间一致工作的简单方法: 仅仅冻结嵌入层( 低于 1 ⁇ 参数) 导致SGDDGD在使用记忆较少的情况下与 Adam 具有竞争力的 SGDDD 。 我们的洞察到五个流行分布变换基准的状态: WILDS- FMOW、 WILDS- Camelyonbirls and Domaint and DomainalNet。