[ICLR 2023] LPT: Long-tailed Prompt Tuning for Image Classification

这篇具有很好参考价值的文章主要介绍了[ICLR 2023] LPT: Long-tailed Prompt Tuning for Image Classification。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

Introduction

  • 作者提出 Long-tailed Prompt Tuning (LPT),通过 prompt learning 来解决长尾问题,包括 (1) 使用 shared prompt 学习 general features 并将预训练模型 adapt 到 target domain;(2) 使用 group-specific prompts 学习 group-specific features 来提高模型的 fine-grained discriminative ability

[ICLR 2023] LPT: Long-tailed Prompt Tuning for Image Classification,长尾问题,ICLR,2023

Preliminary Study

Performance Investigation of VPT (Visual Prompt Tuning)

  • 作者首先通过对比 VPT (Visual Prompt Tuning) 和 linear probing 在 Places-LT 数据集上的精度来说明 prompt tuning 对长尾数据集是有效的 (VPT 的输入为 input tokens 加上 learnable prompts (tokens),同时和 linear probing 一样在预训练模型最后加上 linear classifier)
  • 从下表中可以看出:a) prompt tuning 可以持续提高模型的 LTR 性能;b) prompt tuning 对长尾分布具有鲁棒性,能更好地学习尾部类别。同时也可以注意到,简单的 prompt tuning 并不能直接让模型在长尾数据集上达到 SOTA
    [ICLR 2023] LPT: Long-tailed Prompt Tuning for Image Classification,长尾问题,ICLR,2023

Analysis of Prompt Tuning

  • 作者接下来分析了为什么 prompt tuning 适合长尾识别 (但仍然没有从原理上分析为什么)
  • 由下图的 LDA 可视化可以看出 (use the pretrained ViT-B and the ViT-B fine-tuned by VPT on Places-LT to extract features of ImageNet val set and Places-LT val set),prompt tuning 可以很好地将下游任务数据分布 (Places-LT) 和预训练数据分布 (ImageNet) 对齐,可以更好地让预训练模型 adapt 到长尾任务的 target domain (from domain adaptation perspective)
    [ICLR 2023] LPT: Long-tailed Prompt Tuning for Image Classification,长尾问题,ICLR,2023
  • 作者计算了 ViT-B 和 VPT 输出特征的平均类内距离、平均类间距离以及两者之商 γ \gamma γ,可以看到,VPT 的平均类内距离和 γ \gamma γ 都更小,KNN 分类准确率更高,说明 VPT 输出的特征更具有区分度
    [ICLR 2023] LPT: Long-tailed Prompt Tuning for Image Classification,长尾问题,ICLR,2023

Long-tailed Prompt Tuning (LPT)

[ICLR 2023] LPT: Long-tailed Prompt Tuning for Image Classification,长尾问题,ICLR,2023

Phase 1: Shared Prompt Tuning

[ICLR 2023] LPT: Long-tailed Prompt Tuning for Image Classification,长尾问题,ICLR,2023

  • 类似于 VPT-Deep,给 ViT 的 L L L 层都各自加上额外的 prompts,因此 phase 1 需要优化 shared prompt u = [ u 1 , . . . , u L ] \mathbf u=[\mathbf u_1,...,\mathbf u_L] u=[u1,...,uL] 和 cosine classifier f f f,其中 shared prompt 用于学习所有类别的共同特征,并带来了上节讨论的 prompt tuning 的各种好处,包括 domain adaptation 和输出更具区分度的特征
  • 每层里的前向过程
    [ICLR 2023] LPT: Long-tailed Prompt Tuning for Image Classification,长尾问题,ICLR,2023[ICLR 2023] LPT: Long-tailed Prompt Tuning for Image Classification,长尾问题,ICLR,2023[ICLR 2023] LPT: Long-tailed Prompt Tuning for Image Classification,长尾问题,ICLR,2023其中, c \mathbf c c 为 [CLS], z \mathbf z z 为 token embed. 新添加的 prompts 不需要计算对应的自注意力输出,只需要作为 key 和 value 与 token embed 做交互即可
  • 损失函数
    [ICLR 2023] LPT: Long-tailed Prompt Tuning for Image Classification,长尾问题,ICLR,2023[ICLR 2023] LPT: Long-tailed Prompt Tuning for Image Classification,长尾问题,ICLR,2023

Phase 2: Group Prompts Tuning

[ICLR 2023] LPT: Long-tailed Prompt Tuning for Image Classification,长尾问题,ICLR,2023

  • 作者在 phase 2 加入了 m m mgroup-specific prompts R = { ( k 1 , r 1 ) , . . . , ( k m , r m ) } \mathcal R=\{(\mathbf k_1,\mathbf r^1),...,(\mathbf k_m,\mathbf r^m)\} R={(k1,r1),...,(km,rm)} 用于学习 group-specific knowledge 从而增强模型的 fine-grained discriminative ability,其中 k i \mathbf k_i ki i i i-th group 的 key, r i \mathbf r^i ri i i i-th group 的 prompts,包含 L − K L-K LK 个 prompt 序列 (只在后 L − K L-K LK 层使用 group-specific prompts).
  • Phase 2 包含两个步骤:(1) 冻住 shared prompts,经过 L L L 层推理得到 c L \mathbf c_L cL 作为 query q \mathbf q q m m m 个 keys 计算余弦相似度,选出相似度最高的 k k k 个 groups
    [ICLR 2023] LPT: Long-tailed Prompt Tuning for Image Classification,长尾问题,ICLR,2023然后对选出的 k k k 个 groups 的 prompts 进行 prompt ensembling
    [ICLR 2023] LPT: Long-tailed Prompt Tuning for Image Classification,长尾问题,ICLR,2023(2) 重新使用步骤 (1) 在前向传播中得到的 ( c K , z K ) (\mathbf c_K,\mathbf z_K) (cK,zK),在后 L − K L-K LK 层重新进行前向传播,每层的输入包括 [CLS] embed c \mathbf c c、patch embed z \mathbf z z、shared prompt u \mathbf u u 和 group-specific prompt r \mathbf r r,每层里的前向过程为
    [ICLR 2023] LPT: Long-tailed Prompt Tuning for Image Classification,长尾问题,ICLR,2023[ICLR 2023] LPT: Long-tailed Prompt Tuning for Image Classification,长尾问题,ICLR,2023[ICLR 2023] LPT: Long-tailed Prompt Tuning for Image Classification,长尾问题,ICLR,2023
  • 损失函数
    [ICLR 2023] LPT: Long-tailed Prompt Tuning for Image Classification,长尾问题,ICLR,2023[ICLR 2023] LPT: Long-tailed Prompt Tuning for Image Classification,长尾问题,ICLR,2023其中, β \beta β 为 scale factor,第二项损失函数被用于增大 q \mathbf q q 和其匹配的 k k k 个 groups 的 keys 之间的余弦相似度,这是由于 Phase 1 生成的特征已经比较 compact 并且在 Phase 2 是不变的,因此该损失项可以使得 keys 靠近特征空间中的不同聚类中心,使得不同 groups 对应不同的 group-specific feature
  • Dual Sampling. class-balanced sampling 和 instance-balanced sampling 分别容易使得模型对尾部和头部类别过拟合,作者采用 Dual Sampling,从 instance-balanced sampler 和 class-balanced sampler 分别采样一个 mini-batch { I } ins \{\mathbf I\}_{\text{ins}} {I}ins { I } bal \{\mathbf I\}_{\text{bal}} {I}bal. { I } bal \{\mathbf I\}_{\text{bal}} {I}bal 的损失函数对应 β = 1 \beta=1 β=1 时的 L P 2 \mathcal L_{\mathbf P_2} LP2 { I } ins \{\mathbf I\}_{\text{ins}} {I}ins 的损失函数对应 β = η ( E − e ) / E \beta=\eta(E-e)/E β=η(Ee)/E 时的 L P 2 \mathcal L_{\mathbf P_2} LP2,其中 η = 0.5 \eta=0.5 η=0.5 为 initialized weight, E E E 为总的训练 epoch 数, e e e 为当前 epoch 数

Loss Function

  • phase 1/2 中使用的 L cls \mathcal L_{\text{cls}} Lcls 采用 asymmetric GCL loss L A-GCL \mathcal L_{\text{A-GCL}} LA-GCL.
  • 首先根据 GCL 对 logits s ^ \hat {\mathbf s} s^ 进行加上 bias 和 rescale
    [ICLR 2023] LPT: Long-tailed Prompt Tuning for Image Classification,长尾问题,ICLR,2023其中, α \alpha α 为 scaling factor, ϵ \epsilon ϵ 为从高斯分布中采样的随机变量 ( ∥ ϵ ∥ \|\epsilon\| ϵ 为取绝对值), n i n_i ni 为训练集中类别 i i i 的样本数, n m a x n_{max} nmax 为训练集中的最大类别样本数. 对应的 per-class probability 为
    [ICLR 2023] LPT: Long-tailed Prompt Tuning for Image Classification,长尾问题,ICLR,2023
  • 然后根据 ASL 进行 Asymmetric Focusing
    L A − G C L = − y j ( 1 − p j ) λ + log ⁡ ( p j ) − ∑ 1 ≤ i ≤ C , i ≠ j y i ( p i ) λ − log ⁡ ( p i ) \mathcal{L}_{\mathrm{A}-\mathrm{GCL}}=-\mathbf y_{\mathrm j}\left(1-\mathbf{p}_{\mathrm{j}}\right)^{\lambda_{+}} \log \left(\mathbf{p}_{\mathrm{j}}\right)-\sum_{1 \leq \mathrm{i} \leq \mathrm{C}, \mathrm{i} \neq \mathrm{j}}\mathbf y_{\mathrm i}\left(\mathbf{p}_{\mathrm{i}}\right)^{\lambda_{-}} \log \left(\mathbf{p}_{\mathrm{i}}\right) LAGCL=yj(1pj)λ+log(pj)1iC,i=jyi(pi)λlog(pi)其中, j j j 为输入样本的标签类别, λ + = 0 , λ − = 4 λ_+=0,λ_−=4 λ+=0,λ=4 为 focusing parameter, y \mathbf y y 为 label smoothing 后的类别标签向量,即 y j = 0.9 + 0.1 / C , y i = 0.1 / C \mathbf y_{\mathrm j}=0.9+0.1/C,\mathbf y_{\mathrm i}=0.1/C yj=0.9+0.1/C,yi=0.1/C (疑问:ASL 本来是 BCE 上用的,但这里是 CE + label smoothing 之后再加上 ASL 的动态加权, ( 1 − p j ) λ + \left(1-\mathbf{p}_{\mathrm{j}}\right)^{\lambda_{+}} (1pj)λ+ 的意义和 ASL 一样,都是筛选出难样本,但感觉 ( p i ) λ − \left(\mathbf{p}_{\mathrm{i}}\right)^{\lambda_{-}} (pi)λ 的意义已经和 ASL 完全不同了,可以等进一步理解 label smoothing 为什么有用之后再来看)

Experiments

  • Model. ViT-B/16 with ImageNet-21k pretrained model.
  • Shared Prompt. default length of prompt as 10.
  • Group-specific Prompts. shared layer number K = 6 K = 6 K=6 and the size of prompt size m = 20 m = 20 m=20; for each prompt in the set, the prompt length is also set as 10 (Note that setting K = 6 K = 6 K=6 may lead to 1.5x inference cost compared to VPT). prompt ensemble number k = 2 k = 2 k=2.

Comparison with State-of-The-Art Methods

  • Comparison on Places-LT.
    [ICLR 2023] LPT: Long-tailed Prompt Tuning for Image Classification,长尾问题,ICLR,2023[ICLR 2023] LPT: Long-tailed Prompt Tuning for Image Classification,长尾问题,ICLR,2023
  • Comparison on CIFAR100-LT.
    [ICLR 2023] LPT: Long-tailed Prompt Tuning for Image Classification,长尾问题,ICLR,2023
  • Comparison on iNaturalist 2018.
    [ICLR 2023] LPT: Long-tailed Prompt Tuning for Image Classification,长尾问题,ICLR,2023

Robustness with Domain Shift

[ICLR 2023] LPT: Long-tailed Prompt Tuning for Image Classification,长尾问题,ICLR,2023

Ablation Study

  • Different Model Size and Pretrained Models.
    [ICLR 2023] LPT: Long-tailed Prompt Tuning for Image Classification,长尾问题,ICLR,2023[ICLR 2023] LPT: Long-tailed Prompt Tuning for Image Classification,长尾问题,ICLR,2023

  • Effect of Each Phase.
    [ICLR 2023] LPT: Long-tailed Prompt Tuning for Image Classification,长尾问题,ICLR,2023

  • Decoupled Training. during joint training, the shared prompt is still updated simultaneously, thus the query function is sub-optimal during training, resulting in worse matching results.
    [ICLR 2023] LPT: Long-tailed Prompt Tuning for Image Classification,长尾问题,ICLR,2023

  • Query Function and Group Size m m m.
    [ICLR 2023] LPT: Long-tailed Prompt Tuning for Image Classification,长尾问题,ICLR,2023when we further increase the size to 40, the final accuracy declines to 49.87%. A possible reason is that, some classes in the dataset may share some similar group-specific feature or knowledge[ICLR 2023] LPT: Long-tailed Prompt Tuning for Image Classification,长尾问题,ICLR,2023

  • Effect of K K K. K K K 过大会导致无法学得有效的 group-specific knowledge,过小会导致 Phase 2 匹配 groups 时无法充分利用 Phase 1 得到的 adapted feature representation
    [ICLR 2023] LPT: Long-tailed Prompt Tuning for Image Classification,长尾问题,ICLR,2023

  • Effect of Ensemble Number k k k.
    [ICLR 2023] LPT: Long-tailed Prompt Tuning for Image Classification,长尾问题,ICLR,2023

  • Effect of Asymmetric GCL Loss.
    [ICLR 2023] LPT: Long-tailed Prompt Tuning for Image Classification,长尾问题,ICLR,2023

  • Statistic of Prompt Matching.
    [ICLR 2023] LPT: Long-tailed Prompt Tuning for Image Classification,长尾问题,ICLR,2023文章来源地址https://www.toymoban.com/news/detail-666472.html

References

  • Dong, Bowen, et al. “LPT: Long-tailed Prompt Tuning for Image Classification.” (ICLR 2023).
  • code: https://github.com/DongSky/LPT

到了这里,关于[ICLR 2023] LPT: Long-tailed Prompt Tuning for Image Classification的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • 【文生图】DreamBooth: Fine Tuning Text-to-Image Diffusion Models for Subject-Driven Generation

    论文地址:https://arxiv.org/abs/2208.12242v1 项目地址:https://dreambooth.github.io/ DreamBooth 主要的工作目的是实现保留主体的细致特征的情况下使用文本对其进行环境等编辑。整体方法为给定一个主体的3-5个图像和文本提示作为输入,微调预训练的文生图模型(Imagen,但不限于特定模型

    2024年02月05日
    浏览(25)
  • ICLR2023《Crossformer: Transformer Utilizing Cross-Dimension Dependency for Multivariate Time Series》

    这是一篇ICLR2023 top 5%论文 论文链接:https://openreview.net/pdf?id=vSVLM2j9eie 代码:https://github.com/Thinklab-SJTU/Crossformer MTS,多变量时序数据预测。利用MTS的历史值可以预测其未来的趋势,例如心电图(ECG),脑电图(EEG)脑磁图(MEG)的诊断以及系统监测等等都是固有的多变量问题。该

    2024年02月03日
    浏览(23)
  • tune a video:one-shot tuning of image diffusion models for text-to-video generation

    【Diffusion Models】新加坡国立大学、腾讯强强联手Tune-A-Video:One-Shot微调图像扩散模型用于文本到图像的生成!_哔哩哔哩_bilibili 【Diffusion Models】新加坡国立大学、腾讯强强联手Tune-A-Video:One-Shot微调图像扩散模型用于文本到图像的生成!共计2条视频,包括:[论文代码阅读]T

    2023年04月11日
    浏览(41)
  • 【读论文】SwinFusion: Cross-domain Long-range Learning for General Image Fusion via Swin Transformer

    论文:https://ieeexplore.ieee.org/document/9812535 如有侵权请联系博主 Swin Transformer 长期依赖性、全局信息 跨域融合 2022年发表在 IEEE/CAA JOURNAL OF AUTOMA TICA SINICA的一篇文章,该篇论文的作者仍然是我们熟悉的FusionGAN的作者。 简单来说,该篇论文提出了一个基于CNN和Swin Transformer来提取

    2024年02月16日
    浏览(25)
  • 论文精读:用于少样本图像识别的语义提示(Semantic Prompt for Few-Shot Image Recognition)

    原论文于2023.11.6撤稿,原因:缺乏合法的授权 ,详见此处 在小样本学习中(Few-shot Learning, FSL)中,有通过利用额外的语义信息,如类名的文本Embedding,通过将语义原型与视觉原型相结合来解决样本稀少的问题。但这种方法可能会遇到稀有样本中学到噪声特征导致收益有限。

    2024年02月08日
    浏览(37)
  • Empowering Long-tail Item Recommendation through Cross Decoupling Network (CDN)

    来源: KDD\\\'2023 Google Research 目录 Empowering Long-tail Item Recommendation through Cross Decoupling Network (CDN) 长尾问题分析 CDN Item Memorization and Generalization Decoupling 记忆特征(Memorization features) 泛化特征(Generalization features) 物品表征学习 User Sample Decoupling Cross Learning 总结 参考 长尾问题是个

    2024年02月10日
    浏览(29)
  • Prompt Tuning 和instruct tuning

    prompt的思想是,把下游任务的输入转化为预训练模型的原始任务。 以bert作为举例,假设任务是文本分类。“今天天气很好。”我们想判断一下这句话的情感是正面还是负面 fine-tune的方法是在bert之后接一个head,然后调整整个模型。 prompt 的方法是把下游任务转化为预训练任务

    2024年02月11日
    浏览(27)
  • Prompt Tuning训练过程

    目录 0. 入门 0.1. NLP发展的四个阶段: Prompt工程如此强大,我们还需要模型训练吗? - 知乎 Prompt learning系列之prompt engineering(二) 离散型prompt自动构建 Prompt learning系列之训练策略篇 - 知乎 ptuning v2 的 chatglm垂直领域训练记录_路人与大师的博客-云服务器哪家好 Pretrain + Fine-tunin

    2024年02月09日
    浏览(29)
  • Prompt-Tuning(一)

     一、预训练语言模型的发展过程 第一阶段的模型主要是基于自监督学习的训练目标,其中常见的目标包括掩码语言模型(MLM)和下一句预测(NSP)。这些模型采用了Transformer架构,并遵循了Pre-training和Fine-tuning的训练范式。通过预训练模型在大规模无标签数据上进行学习,可

    2024年02月07日
    浏览(30)
  • 大模型PEFT技术原理(一):BitFit、Prefix Tuning、Prompt Tuning

           随着预训练模型的参数越来越大,尤其是175B参数大小的GPT3发布以来,让很多中小公司和个人研究员对于大模型的 全量微调 望而却步,近年来研究者们提出了各种各样的参数高效迁移学习方法(Parameter-efficient Transfer Learning),即固定住Pretrain Language model(PLM)的大部

    2024年01月25日
    浏览(54)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包