Visualizing Attention for Sequence Data in the Frequency domain

5 ビュー (過去 30 日間)
Luca
Luca 2024 年 5 月 28 日
回答済み: Kaustab Pal 2024 年 7 月 11 日
I have trouble finding out how i can map my attention weights onto my input data.
My input data is in a 512*1 Cell, it represents a vibration in the frequency-domain, after going through different layers (mainly 2 CNN and 2 Bi-GRU), i have a high level representation of it(480*1), that enters a self attention layer.
I am able to extract the attention weights (256*1), but I am unsure on how to map them to my input sequence, am i able to just upscale the attention vector and overlay it onto my input?
I've added a screenshots of the model structure, to help you understand the problem.
The whole problem is further illustrated in this research paper.
I would be grateful for anyone, who can help me understand how I need to proceed.

回答 (1 件)

Kaustab Pal
Kaustab Pal 2024 年 7 月 11 日
Hi @Luca,
To upscale your attention weights from a 256x1 dimension to 512x1, you can utilize the "imresize" function.
You can refer to the imresizefunction documentation available here: https://www.mathworks.com/help/matlab/ref/imresize.html
Below is an example demonstrating how to achieve this:
A = randn(256,1); % dummy data of size 256x1
B = imresize(A,[512,1]); % resize to required size
size(B) % return an image B of size 512x1
ans = 1x2
512 1
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
I hope this solves your issue.

カテゴリ

Help Center および File ExchangeGet Started with MATLAB についてさらに検索

製品


リリース

R2023b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by