Skip to content

renjunxiang/Multihead-Attention

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Multihead-Attention

Multihead Attention for PyTorch

项目简介

最近在尝试注意力机制提升模型效果,没有找到PyTorch版本非常合适的Multihead-Attention,就参考部分资料尝试写了一个。

模块结构

Attention里面有两个简单的Self-Attention和Multihead-Attention
Multihead-Attention修改自:
https://www.github.com/kyubyong/transformer
还参考了:
https://github.com/jadore801120/attention-is-all-you-need-pytorch
https://blog.csdn.net/stupid_3/article/details/83184691
一般来说,Q、K、V三者的通道数(即字/词的向量维度)是一致的,K通常等于V,不过PyTorch的nn.LayerNorm和自己实现的略有出入。

About

Multihead Attention for PyTorch

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages