[{"data":1,"prerenderedAt":260},["ShallowReactive",2],{"content-query-HiGIvqdRdH":3},{"_path":4,"_dir":5,"_draft":6,"_partial":6,"_locale":7,"title":8,"description":9,"date":10,"cover":11,"type":12,"body":13,"_type":254,"_id":255,"_source":256,"_file":257,"_stem":258,"_extension":259},"/technology-blogs/zh/2961","zh",false,"","任意模型都能蒸馏，异构模型的知识蒸馏方法OFAKD已在昇思MindSpore开源","作者：王云鹤 ｜来源：知乎","2024-01-23","https://obs-mindspore-file.obs.cn-north-4.myhuaweicloud.com/file/2024/01/26/65a5572868a543cab40511d899af7193.png","technology-blogs",{"type":14,"children":15,"toc":249},"root",[16,24,43,51,56,61,66,77,82,91,99,106,111,116,124,131,136,141,148,153,165,172,177,182,189,194,199,206,211,216,223,228,233,244],{"type":17,"tag":18,"props":19,"children":21},"element","h1",{"id":20},"任意模型都能蒸馏异构模型的知识蒸馏方法ofakd已在昇思mindspore开源",[22],{"type":23,"value":8},"text",{"type":17,"tag":25,"props":26,"children":27},"p",{},[28,30,36,38],{"type":23,"value":29},"**作者：**",{"type":17,"tag":31,"props":32,"children":33},"strong",{},[34],{"type":23,"value":35},"王云鹤",{"type":23,"value":37}," ｜",{"type":17,"tag":31,"props":39,"children":40},{},[41],{"type":23,"value":42},"来源：知乎",{"type":17,"tag":25,"props":44,"children":45},{},[46],{"type":17,"tag":47,"props":48,"children":50},"img",{"alt":7,"src":49},"https://obs-mindspore-file.obs.cn-north-4.myhuaweicloud.com/file/2024/01/26/88f36535136e494fa1118c5be5fab1f9.png",[],{"type":17,"tag":25,"props":52,"children":53},{},[54],{"type":23,"value":55},"自知识蒸馏方法在2014年被首次提出以来，其开始广泛被应用于模型压缩领域。在更强大教师模型辅助监督信息的帮助下，学生模型往往能够实现比直接训练更高的精度。然而，现有的知识蒸馏相关研究只考虑了同架构模型的蒸馏方法，而忽略了教师模型与学生模型异构的情形。例如，最先进的MLP模型在ImageNet上仅能达到83%的精度，无法获取精度更高的同架构教师模型以使用知识蒸馏方法进一步提高MLP模型的精度。因此，对异构模型知识蒸馏的研究具有实际应用意义。",{"type":17,"tag":25,"props":57,"children":58},{},[59],{"type":23,"value":60},"本文的研究者们分析了针对异构模型（CNN，ViT，MLP）特征的差异性，指出特征中模型架构相关的信息会阻碍知识蒸馏的过程。基于此观察，研究者们提出了名为OFAKD异构模型知识蒸馏方法：该方法将特征映射到架构无关的统一空间进行异构模型蒸馏，并使用一种能够自适应增强目标类别信息的损失函数。在CIFAR-100和ImageNet数据集上，该方法实现了对现有同架构知识蒸馏方法的超越。",{"type":17,"tag":25,"props":62,"children":63},{},[64],{"type":23,"value":65},"论文见：",{"type":17,"tag":25,"props":67,"children":68},{},[69],{"type":17,"tag":70,"props":71,"children":75},"a",{"href":72,"rel":73},"https://arxiv.org/abs/2310.19444",[74],"nofollow",[76],{"type":23,"value":72},{"type":17,"tag":25,"props":78,"children":79},{},[80],{"type":23,"value":81},"MindSpore代码：",{"type":17,"tag":25,"props":83,"children":84},{},[85],{"type":17,"tag":70,"props":86,"children":89},{"href":87,"rel":88},"https://gitee.com/mindspore/models/tree/master/research/cv/",[74],[90],{"type":23,"value":87},{"type":17,"tag":25,"props":92,"children":93},{},[94],{"type":17,"tag":31,"props":95,"children":96},{},[97],{"type":23,"value":98},"异构模型间的特征差异",{"type":17,"tag":25,"props":100,"children":101},{},[102],{"type":17,"tag":47,"props":103,"children":105},{"alt":7,"src":104},"https://obs-mindspore-file.obs.cn-north-4.myhuaweicloud.com/file/2024/01/26/96186ce8ba2c4e30ad45087c1c56e063.png",[],{"type":17,"tag":25,"props":107,"children":108},{},[109],{"type":23,"value":110},"图1 异构模型学习到的特征对比",{"type":17,"tag":25,"props":112,"children":113},{},[114],{"type":23,"value":115},"相比于仅使用logits的蒸馏方法，同步使用模型中间层特征进行蒸馏的方法通常能取得更好的性能。然而在异构模型的情况下，由于不同架构模型对特征的不同学习偏好，它们的中间层特征往往具有较大的差异，直接将针对同架构模型涉及的蒸馏方法迁移到异构模型会导致性能下降。",{"type":17,"tag":25,"props":117,"children":118},{},[119],{"type":17,"tag":31,"props":120,"children":121},{},[122],{"type":23,"value":123},"通用的异构模型蒸馏方法",{"type":17,"tag":25,"props":125,"children":126},{},[127],{"type":17,"tag":47,"props":128,"children":130},{"alt":7,"src":129},"https://obs-mindspore-file.obs.cn-north-4.myhuaweicloud.com/file/2024/01/26/c07f2cc2cc4548e2b49af55e51fb2efe.png",[],{"type":17,"tag":25,"props":132,"children":133},{},[134],{"type":23,"value":135},"图2 异构模型的知识蒸馏方法",{"type":17,"tag":25,"props":137,"children":138},{},[139],{"type":23,"value":140},"为了在异构模型蒸馏过程中利用中间层特征，需要排除特征中模型架构相关信息的干扰，仅保留任务相关信息。基于此，研究者们提出通过将学生模型的中间层特征映射到logits空间，实现对模型架构相关信息的过滤。此外通过在原始基于KL散度的蒸馏损失函数中引入一项额外的调节系数，修正后的损失函数能够实现对目标类别信息的自适应增强，进一步减缓异构模型蒸馏时无关信息的干扰。",{"type":17,"tag":25,"props":142,"children":143},{},[144],{"type":17,"tag":47,"props":145,"children":147},{"alt":7,"src":146},"https://obs-mindspore-file.obs.cn-north-4.myhuaweicloud.com/file/2024/01/26/bd88646d46a14ee684e981ef664eeacc.png",[],{"type":17,"tag":25,"props":149,"children":150},{},[151],{"type":23,"value":152},"图3 原始蒸馏损失与改进后蒸馏损失的对比",{"type":17,"tag":154,"props":155,"children":157},"h3",{"id":156},"实验结果",[158],{"type":17,"tag":31,"props":159,"children":160},{},[161],{"type":17,"tag":31,"props":162,"children":163},{},[164],{"type":23,"value":156},{"type":17,"tag":25,"props":166,"children":167},{},[168],{"type":17,"tag":47,"props":169,"children":171},{"alt":7,"src":170},"https://obs-mindspore-file.obs.cn-north-4.myhuaweicloud.com/file/2024/01/26/3fa33b4090564a54a90cedefd990229e.png",[],{"type":17,"tag":25,"props":173,"children":174},{},[175],{"type":23,"value":176},"图4 在ImageNet上的异构模型蒸馏结果",{"type":17,"tag":25,"props":178,"children":179},{},[180],{"type":23,"value":181},"上表展示了在ImageNet上的异构蒸馏结果。在所有架构的六种可能异构组合中，本文OFAKD方法都得到了超越现有方法结果。",{"type":17,"tag":25,"props":183,"children":184},{},[185],{"type":17,"tag":47,"props":186,"children":188},{"alt":7,"src":187},"https://obs-mindspore-file.obs.cn-north-4.myhuaweicloud.com/file/2024/01/26/d40e6d01d0ca447c8565b7c69e3fa082.png",[],{"type":17,"tag":25,"props":190,"children":191},{},[192],{"type":23,"value":193},"图5 不同值对结果的影响",{"type":17,"tag":25,"props":195,"children":196},{},[197],{"type":23,"value":198},"上表在ImageNet上比较了不同的值设置对结果的影响。可以看出，通过选取合适的值设置，改进后的蒸馏损失函数能得到超越原始蒸馏损失函数的结果。",{"type":17,"tag":25,"props":200,"children":201},{},[202],{"type":17,"tag":47,"props":203,"children":205},{"alt":7,"src":204},"https://obs-mindspore-file.obs.cn-north-4.myhuaweicloud.com/file/2024/01/26/5a0e8049ec854a468608967d56ff190f.png",[],{"type":17,"tag":25,"props":207,"children":208},{},[209],{"type":23,"value":210},"图6 在ImageNet上的同构模型蒸馏结果",{"type":17,"tag":25,"props":212,"children":213},{},[214],{"type":23,"value":215},"本文在ImageNet上与传统同构模型蒸馏方法进行了对比。在常见的ResNet34和ResNet18同构教师学生模型组合上，OFAKD也具有与现有SOTA方法相当的表现。",{"type":17,"tag":25,"props":217,"children":218},{},[219],{"type":17,"tag":47,"props":220,"children":222},{"alt":7,"src":221},"https://obs-mindspore-file.obs.cn-north-4.myhuaweicloud.com/file/2024/01/26/caa0377fc38e49b588db5dc53681d60a.png",[],{"type":17,"tag":25,"props":224,"children":225},{},[226],{"type":23,"value":227},"图7 MLP学生模型的蒸馏结果",{"type":17,"tag":25,"props":229,"children":230},{},[231],{"type":23,"value":232},"最后，本文比较了文首提到的MLP作为学生模型时的蒸馏结果。通过选用ViT架构的BEiT v2-base作为教师模型，仅中等尺寸的CycleMLP-B3就刷新了MLP模型在ImageNet上的最佳结果。",{"type":17,"tag":25,"props":234,"children":235},{},[236],{"type":17,"tag":31,"props":237,"children":238},{},[239],{"type":17,"tag":31,"props":240,"children":241},{},[242],{"type":23,"value":243},"结论",{"type":17,"tag":25,"props":245,"children":246},{},[247],{"type":23,"value":248},"本文研究了异构模型之间的知识蒸馏方法，通过将学生模型中间层特征映射到logits空间来拟合教师模型最终输出，并使用在原始知识蒸馏损失函数基础上改进而来的自适应目标信息增强损失，提出的OFAKD方法在多种数据集和教师学生模型组合上实现了对现有方法的超越，扩展了知识蒸馏的应用范围。",{"title":7,"searchDepth":250,"depth":250,"links":251},4,[252],{"id":156,"depth":253,"text":156},3,"markdown","content:technology-blogs:zh:2961.md","content","technology-blogs/zh/2961.md","technology-blogs/zh/2961","md",1776506124674]