Comments (5)
实现上不一样。假设序列长度为T,你的这种mask的形式首先需要做T x T的attention计算,然后再乘上mask,然而这种计算方法显存会爆炸;我采取的实现方式则是将图(b)的计算分成若干块,每次只需要保存2window_size x 2 window_size的attention value,极大的节省了显存。具体的细节你可以仔细看看 _sliding_window_self_att 函数的实现。祝好~
。
from asformer.
您好,计算full attention再mask这样的计算方式会显存爆炸,你换了一种滑动窗的方式来实现,这一点我很赞同而且理解。
不过,我用你的 construct window mask函数出来的结果如下
我将函数进行微小的改动(就改了一个字符),window_mask[:, :, i:i+self.bl] = 1———>window_mask[:, i, i:i+self.bl] = 1,得到的结果如下
我觉得改动后的函数更符合你想达到的意图
不知道我的理解对不对
from asformer.
或许你可以试试看改成window_mask[:, i, i:i+self.bl] = 1,看性能有无变化。我还没有仔细看,不过感觉你的理解应该没有错。现在的代码的写法有点像一种变相的滑窗,如下图所示,假设窗口size 为2:
我之前做过实验,无论是每一帧滑窗,还是直接把视频分成若干段,每段内部单独做attention,只要保证层级结构(窗口大小倍增或分段长度倍增),性能都是很高的。等闲下来我会仔细checkout一下。谢谢你的发现~
from asformer.
是的,我也发现了这个现象,只要保证这种层级结构性能都会不错!感谢你的回复
from asformer.
哈哈哈哈哈。没错,这就是本文的重要发现,你用什么efficient version都无所谓,所以代码里面也提供了block-wise的做法,两者性能差不多,可视化的图也都一样。
from asformer.
Related Issues (12)
- cross-self attention HOT 1
- about the randomness of code HOT 1
- Error in evaluation code HOT 2
- Feature Extraction HOT 3
- flops,GPU mem code HOT 4
- Long training time HOT 2
- Batch size constraint HOT 6
- Cannot download the model HOT 2
- pre-extracted feature HOT 1
- results on salads50 does not match table 5 HOT 3
- Increase the batchsize and the result is hurt HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from asformer.