Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue regarding the last step of self attention (weighted sum step) #3

Open
pangzss opened this issue Jun 2, 2021 · 3 comments
Open

Comments

@pangzss
Copy link

pangzss commented Jun 2, 2021

Hi, I noticed that the last step of the self-attention calculation doesn't seem so right:

att_weights_ = nn.functional.softmax(logits, dim=-1)       
weights = self.dropout(att_weights_)     
y = torch.matmul(V.transpose(1,0), weights).transpose(1,0)

So here the softmax probability is calculated along the dim -1, which is the column direction.
But then the weighted sum is taken along the row direction according to this line

y = torch.matmul(V.transpose(1,0), weights).transpose(1,0)

I think we should do something like this

y = torch.matmul(weights,V)

How do you think?
I hope I'm the one to be corrected.

@pangzss pangzss changed the title Question regarding the self attention calculation. Issue regarding the last step of self attention (weighted sum step) Jun 2, 2021
@noirsora1605
Copy link

Hi, could you please guide me on how to summarize my own video?

@Junaid112
Copy link
Collaborator

Hi, could you please guide me on how to summarize my own video?

you have to extract features first for frames of the video and then based on trained model you can predict probability to be in a summary. For object features refer https://github.com/VideoAnalysis/EDUVSUM/tree/master/src

Motion feature code I will upload after refactoring.

@mpalaourg
Copy link

I fully agree with @pangzss. If my calculations are right, the used formula/command

y = torch.matmul(V.transpose(1,0), weights).transpose(1,0)

would be correct, only if the weights array was symmetric, but this isn't the case.
Oddly enough, the produced results doesn't change much when the corrected formula/command is used.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants