Similarity-Preserving Knowledge Distillation(2019ICCV)----论文阅读笔记

本文介绍了一种新颖的知识提取方法——保持相似性知识提取(Similarity-Preserving Knowledge Distillation),它通过比较学生和教师网络对相似输入的激活模式来训练学生网络。这种方法区别于传统方法,强调在学生网络的表示空间内维护输入对的相似性,实验证明其在CIFAR-10、迁移学习和CINIC-10数据集上有效增强网络性能。
摘要由CSDN通过智能技术生成

Abstract

在训练网络的过程中,语义相似的输入倾向于在引发相似的激活模式。保持相似性的知识提取指导学生网络的训练,使在教师网络中产生相似(不同)激活的输入指导学生网络中产生相似(不同)激活。与以前的提取方法不同,学生不需要模仿教师的表示空间,而是要在自己的表示空间中保留成对的相似性。

1. Introduction

图1.保持相似性的知识提取指导学生网络的训练,使得在预先训练的教师网络中产生相似(不同)激活的输入对在学生网络中产生相似(不同)激活。给定一小批b张输入的图像,我们从激活图中导出b×b成对相似矩阵,并计算学生和教师产生的矩阵上的蒸馏损失。

这篇文章的想法和RKD的想法及其相似,不知道谁参考谁的,让人难免有点copy的感觉。

贡献:

  • 我们引入了保持相似性的知识提取,这是一种新的知识提取形式,它使用每个输入小批量中的成对激活相似性来监督学生网络和经过训练的教师网络的训练。(实例间的相似矩阵)
  • 我们在三个公共数据集上实验验证了我们的方法。我们的实验表明,保持相似性的知识提取不仅可以提高学生网络的训练效果,而且可以补充传统的知识提取方法。

在这里插入图片描述

2. Method

在这里插入图片描述

注释

  • AT AS 来说是对应的特征图
  • 通道 和 h w 都可以不一致
  • l 和 l’ 可以是corresponding layer 对应层或者说相同深度的层
    这里和RKD已经非常相似。
    在这里插入图片描述
    做法也比较简单,求出实例间的关系矩阵,且归一化。 GT GS

在这里插入图片描述

where γ is a balancing hyperparameter.

3. Experiments

3.1. CIFAR-10

在这里插入图片描述

3.2. Transfer learning combining distillation with fine-tuning

在这里插入图片描述

3.3. CINIC-10

在这里插入图片描述

代码

from __future__ import print_function

import torch
import torch.nn as nn
import torch.nn.functional as F


class Similarity(nn.Module):
    """Similarity-Preserving Knowledge Distillation, ICCV2019, verified by original author"""
    def __init__(self):
        super(Similarity, self).__init__()

    def forward(self, g_s, g_t):
        return [self.similarity_loss(f_s, f_t) for f_s, f_t in zip(g_s, g_t)]

    def similarity_loss(self, f_s, f_t):
        bsz = f_s.shape[0]
        f_s = f_s.view(bsz, -1)
        f_t = f_t.view(bsz, -1)

        G_s = torch.mm(f_s, torch.t(f_s))
        # G_s = G_s / G_s.norm(2)
        G_s = torch.nn.functional.normalize(G_s)
        G_t = torch.mm(f_t, torch.t(f_t))
        # G_t = G_t / G_t.norm(2)
        G_t = torch.nn.functional.normalize(G_t)

        G_diff = G_t - G_s
        loss = (G_diff * G_diff).view(-1, 1).sum(0) / (bsz * bsz)
        return loss

加速基于相似性模型匹配的On-The-Fly相似性保持哈希 摘要: 在软件工程中,模型匹配是一项核心任务,广泛应用于模型驱动工程、软件重构、需求管理、代码检查等领域。由于模型通常包含大量的元素和复杂的结构,模型匹配问题变得越来越具有挑战性。相似性匹配是一种流行的模型匹配方法,它通过计算语义相似度来匹配模型元素。然而,由于相似性匹配算法的计算复杂度很高,导致它们的效率低下。 为了提高相似性匹配的效率,我们提出了一种基于On-The-Fly相似性保持哈希的加速方法。该方法利用哈希表将元素映射到桶中,并在桶中使用相似性保持哈希函数计算相似性,从而避免了在匹配过程中进行昂贵的相似性计算。此外,我们还提出了一种基于哈希冲突的剪枝策略,以进一步提高匹配效率。 我们在多个数据集上进行了实验,并与现有相似性匹配算法进行了比较。实验结果表明,我们的方法可以显著提高匹配效率,同时保持高精度。 关键词:模型匹配,相似性匹配,哈希,剪枝 Abstract: In software engineering, model matching is a core task widely applied in model-driven engineering, software refactoring, requirement management, code inspection, etc. Due to the fact that models usually contain a large number of elements and complex structures, model matching problems become increasingly challenging. Similarity-based matching is a popular model matching approach that matches model elements by computing semantic similarities. However, due to the high computational complexity of similarity-based matching algorithms, they suffer from poor efficiency. To improve the efficiency of similarity-based matching, we propose an acceleration method based on On-The-Fly similarity preserving hashing. This method uses a hash table to map elements to buckets and employs similarity preserving hash functions to compute similarities within buckets, thus avoiding expensive similarity computations during the matching process. In addition, we propose a hash conflict-based pruning strategy to further improve the matching efficiency. We conduct experiments on multiple datasets and compare our method with existing similarity-based matching algorithms. Experimental results show that our method can significantly improve the matching efficiency while maintaining high accuracy. Keywords: Model matching, similarity-based matching, hashing, pruning.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值