【论文笔记】Model soups模型汤google
论文地址:https://arxiv.org/pdf/2203.05482.pdf论文相关讲解:https://baijiahao.baidu.com/s?id=1727838067837303006&wfr=spider&for=pc论文贡献:在imagenet上通过该方法对于ViT-G模型,达到sota 90.94%的效果模型汤方法可以用在图像分类和NLP领域,提高下游的out
论文地址:https://arxiv.org/pdf/2203.05482.pdf
论文相关讲解:https://baijiahao.baidu.com/s?id=1727838067837303006&wfr=spider&for=pc
论文贡献:
- 在imagenet上通过该方法对于ViT-G模型,达到sota 90.94%的效果
- 模型汤方法可以用在图像分类和NLP领域,提高下游的out-of-distribution和zero-shot效果
- Finally, we analytically relate the performance similarity of weight-averaging and logit-ensembling to flatness of the loss and confidence of the predictions, and validate this relation empirically
2.Method
一共三种方式:
- uniform soup
- greedy(main) soup
- learned soup
uniform soup
所有finetune模型的平均
greedy soupII
当在验证集上有提高时,放入model soup。在最后执行总程序前,按照在val上的效果从高到低排列,这样,最后训练出来的结果不会比val最好的那个模型差。
learn soup
通过将各个模型在模型汤中的权重作为可学习参数(附录B.1)。要求一次性把所有模型都加载到内存,所以没办法训练大模型汤。
3.实验(重点!!)
3.1 实验计划
使用的模型:CLIP(ViT-B/32)、ALIGN、在JFT-3B上预训练的ViT-G/14、以及文本分类的transformer模型
初始化方法:有两种,一种是linear probe(LP),一种是zero-shot初始化,比如使用CLIP或ALIGN的文本tower产生的分类器作为初始化。如无特殊说明,用的就是LP
集成baseline:如无特殊说明,用的是有监督cross-entropy+ImageNet。结果对五个自然分布shift进行评估:ImageNetV2,ImageNet-R, ImageNet-Sketch, ObjectNet, 和ImageNet-A。由于ImageNet的val数据集被用作test set,我们使用训练集的2%作为验证集来验证greedy soup
3.2 Intuition with error landscape visualizations
错误landscape可视化。
使用CLIP在ImageNet上,我们可视化训练loss和测试error的两个维度切片。
在这个实验中我们验证了ImageNet training loss、ImageNet test error和五个之前提到的数据集的test error。使用CLIP的zero-shot初始化,并且两种finetune 1和2。
0五角星是zero-shot初始化,1蓝色方块是lr为3x10-5 ,2是和1lr相同但随机种子不同或者lr是3x10-6.
损失误差可以看到都是盆地型,这三点都不是最佳
图片证明了两点:
1)相较于单一模型,两个finetune的可以提高acc
2)more uncorrelated solutions:通过linear interpolation路径,模型呈90度夹角可能可以获取更高的acc
后来实验讨论角度对于acc的影响,可以参考fig3,更多细节在附录B2.
3.3 模型汤
结论:多个模型平均可以代替单个val最高的模型
模型:
CLIP和ALIGN finetune在ImageNet、WILDS(3.3.1);
在JFT-3B上预训练的ViT-G,finetune在ImageNet(3.3.2);
transformer模型finetune在文本分类任务上(3.3.3)。
附录E额外展示了CLIP ViT-L finetune在CIFAR-10上;在ImageNet-22k上预训练的ViT-B/32在ImageNet上预训练。
3.3.1 finetune CLIP和ALIGN
CLIP:随机超参数search on学习率、衰退权重、epoch、label smoothing、数据增强,获得了72个finetune模型
ALIGN:12个finetune模型。
贪婪汤中,按照val的acc,从高到低排列,分别选择5个模型。fig1和fig4展示了这两个模型的uniform和greedy汤结果。
结论:
1)贪婪汤分别高了0.7和0.5个点。
2)贪婪汤需要更少的模型达到于best val相同的acc
fig5展示了uniform和greedy汤的性能,以及best single model、logit ensemble。
可以看到
1)greedy性能比单个best模型强,不论在ImageNet还是out-of-distribution测试集;
2)greedy比uniform强,在这两个数据集上;
3)logit ensemble在ImageNet上比greedy强,但是out-of-distribution较差
table3展示了CLIP汤和baselines的性能。
fig6展示了CLIP在wilds数据集的结果。
总体总结如下:
1)贪婪汤效果比best单模型好—没有额外的训练和推理计算,我们可以有更好的模型。
2)只有所有单模型获得了高准确率时,uniform汤可以比best单模型好。否则会像图2中一样,成为error barrier
3.3.2 Fine-tuning a ViT-G model pre-trained on JFT-3B
冲击sota
在ImageNet上finetune了58个模型,使用sharpness-aware minimization(SAM)训练了4个模型。还有EMA的一系列做法。
贪婪唐选择了14个模型。
图可以看到:
1)除了ObjectNet,soup明显比best val单模型好,甚至我们也选择了test最好的。(?)
this soup performs statistically significantly better than the best individually fine-tuned model selected based on our held out validation set on all datasets except for ObjectNet. Even when we give an unfair advantage to individually fine-tuned models by selecting them based on their performance on each test set (denoted “oracle” in Table 4),
2)在in-distribution大部分数据集中,贪婪汤性能优越。只有在ReaL和ObjectNet上,有单模型效果比soup好,而且在两个数据集上,best模型是不一样的。(?)
3)greedy ensembling在ImageNet top1和multilabel上,acc和soup类似,但在ReaL上更好,在all distribution shift上(除了ImageNet-V2)更差。
3.3.3 finetune在文本分类上
效果没有图像分类明显,但是在许多情况下时可以提高性能的
3.4 鲁棒性测试
使用WiSE-FT方法,提高鲁棒性。
3.5 cross-dataset 汤
左:模型汤(分别在dataset上训练的模型和zero-shot模型)可以提高在CIFAR-100上的zero-shot 6.4个点。
右:对于模型汤中微调模型的选择会对汤的结果产生重大影响
4. Analytically comparing soups to ensembles
更多推荐
所有评论(0)