arXivDaily arXiv每日学术速递 周一至周五更新
感恩节,周五至周末无更新,大家顺遂。周一再来吧
arXiv 2211.09359cs.CVcs.LG
收藏

如何用SGD微调视觉模型

How to Fine-Tune Vision Models with SGD

Microsoft(微软)

Ananya Kumar, Ruoqi Shen, Sebastien Bubeck, Suriya Gunasekar

AI总结:

本文发现微调视觉模型时,冻结嵌入层可使SGD在性能和内存上优于AdamW,并在五个分布偏移基准上达到最先进准确率。

摘要:

SGD和AdamW是计算机视觉中微调大型神经网络最常用的两种优化器。当这两种方法表现相同时,SGD更受青睐,因为它比AdamW使用更少的内存(带动量时每参数12字节,不带动量时每参数8字节,而AdamW为每参数16字节)。然而,在一系列下游任务中,特别是在存在分布偏移的任务上,我们发现使用AdamW微调现代Vision Transformer和ConvNeXt模型的效果明显优于SGD。我们发现,当第一个“嵌入”层中的微调梯度远大于模型其余部分时,SGD和AdamW之间的性能差距会很大。我们的分析提出了一个简单且在不同数据集和模型上始终有效的修复方法:冻结嵌入层(参数占比不到1%)使得SGD(无论是否带动量)的表现略优于AdamW,同时使用更少的内存(例如,在ViT-L上,SGD使用的GPU内存减少33%)。我们的见解在五个流行的分布偏移基准上取得了最先进的准确率:WILDS-FMoW、WILDS-Camelyon、BREEDS-Living-17、Waterbirds和DomainNet。

英文摘要:

SGD 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 with momentum and 8 bytes/parameter without) than AdamW (16 bytes/parameter). However, on a suite of downstream tasks, especially those with distribution shifts, we find 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: freezing the embedding layer (less than 1% of the parameters) leads to SGD with or without momentum performing slightly better than AdamW while using less memory (e.g., on ViT-L, SGD uses 33% less GPU memory). Our insights result in state-of-the-art accuracies on five popular distribution shift benchmarks: WILDS-FMoW, WILDS-Camelyon, BREEDS-Living-17, Waterbirds, and DomainNet.

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

↑