当前位置: 首页 > 科技观察

17个注意力机制PyTorch实现,包括MLP、Re-Parameter系列热门论文

时间:2023-03-19 22:02:00 科技观察

注意力(Attention)机制最早应用于计算机视觉,后来发展到NLP领域。该机制将有限的注意力集中在关键点信息上,从而节省资源并快速获取最有效的信息。2014年谷歌DeepMind发表《Recurrent Models of Visual Attention》,让注意力机制大行其道;2015年,Bahdanau等人。在论文《Neural Machine Translation by Jointly Learning to Align and Translate》中首次将注意力机制应用到NLP领域;2017年,谷歌机器翻译团队发表了在中,完全摒弃了RNN、CNN等网络结构,只将注意力机制用于机器翻译任务,取得了不错的效果。因此,注意力机制成为研究热点。经过几年的发展,该领域已经出现了很多关于注意力机制的研究论文,这些工作在CV和NLP领域都取得了不错的效果。最近在GitHub上,有研究人员介绍了17篇PyTorch论文中attention机制的代码实现和使用。项目地址:https://github.com/xmu-xiaoma666/External-Attention-pytorch项目介绍项目作者将注意力机制分为三个系列:Attention系列、MLP系列、ReP(Re-Parameter)系列。其中,Attention系列收录了著名的《Attention is All You Need》等11篇论文;最近流行的MLP系列有谷歌的MLP-Mixer、gMLP、Facebook的ResMLP、清华的RepMLP;另外,ReP(Re-Parameter)系列包括清华大学。RepVGG,等人提出的ACNet。Attention系列11篇Attention论文的Pytorch实现如下:NIPS2017》Pytorch实现论文《SimplifiedSelfAttentionUsage》Pytorch实现论文《Squeeze-and-ExcitationNetworks---CVPR2018》Pytorch实现论文《SelectiveKernelNetworks-》--CVPR2019》Pytorch实现论文《CBAM:ConvolutionalBlockAttentionModule——-ECCV2018》Pytorch实现论文《BAM:BottleneckAttentionModule---BMCV2018》Pytorch实现论文《ECA-Net:EfficientChannelAttentionforDeepConvolutionalNeuralNetworks---CVPR2020》Pytorch实现论文《DualAttentionNetworkforSceneSegmentation》--CVPR2019《Pytorch实现论文《EPSANet:AnEfficientPyramidSplitAttentionBlockonConvolutionalNeuralNetwork》---arXiv2020.05.30》Pytorch实现论文《ResT:AnEfficientTransformerforVisualRecognition---arXiv2020.05.28》MLP(MultipleLayerPerceptron)系列,包括4篇Pytorch实现论文,论文如下:PytorchImplementationPaper"RepMLP:Re-parameterizingConvolutionsintoFully-connectedLayersforImageRecognition---arXiv2020.05.05》Pytorch实现论文《MLP-Mixer:Anall-MLPArchitectureforVision---arXiv2020.05.17》Pytorch实现论文《ResMLP》:Feedforwardnetworksforimageclassificationwithdata-efficienttraining---arXiv2020.05.07》Pytorch实现论文《关注MLPs---arXiv2020.05.17》ReP(Re-Parameter)系列,包括2篇Pytorch实现论文如下:Pytorch实现论文《RepVGG:MakingVGG-styleConvNetsGreatAgain---CVPR2021》Pytorch实现论文《ACNet:StrengtheningtheKernelSkeletonsforPowerfulCNNviaAsymmetricConvolutionBlocks---ICCV2019》综上所述,该项目分享了Pytorch实现17篇attentionmechanism论文,每篇论文包括题目(论文直接链接)、网络架构、代码,这里举例:论文:《BeyondSelf-attention:ExternalAttentionusingTwoLinearLayersfor视觉任务”。网络框架:代码:fromattention.ExternalAttention*import*ExternalAttentionimporttorchinput=torch.randn(50,49,512)ea=ExternalAttention(d_model=512,S=8)output=ea(input)print(output.shape)