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

Attention layer output #9

Open
krayush07 opened this issue Jul 27, 2017 · 5 comments
Open

Attention layer output #9

krayush07 opened this issue Jul 27, 2017 · 5 comments

Comments

@krayush07
Copy link

The method task_specific_attention applies attention to the projected vectors instead of the hidden vectors (output from RNN cell).

Has it been applied purposefully or has the information on attention according to the paper been missed out where final sentence vector is weighted summation of hidden states and NOT inner projected vector?

@krayush07 krayush07 changed the title Attended layer output Attention layer output Jul 27, 2017
@diegow88
Copy link

@krayush07 you are right. Have you tested the implementation by changing the attention to the hidden vectors?

@heisenbugfix
Copy link

heisenbugfix commented Apr 19, 2018

@krayush07 - In the paper this is how the projection is done:
Lets say your hidden state output is h_it. Then you first calculate u_it as:
u_it = tanh(W*h_it + b_w)
Then attention weights are calculated using u_it. So u_it here is the projected vector

@krayush07
Copy link
Author

@heisenbugfix I agree to what you mentioned in the previous comment. However, final attention is applied on hidden states and NOT projected vector.

As per my understanding, here are the steps apply attention:

  1. Collect 'hidden_states'
  2. Apply projection to get projected vector.
  3. Use projected vector and attention vector to find attention weights.
  4. Use attention weights and hidden_states to apply attention.

I find a mismatch in 4th step in your code. Please correct me if I am wrong.

@heisenbugfix
Copy link

heisenbugfix commented Apr 20, 2018

@krayush07 Ah I get it. Thanks for clarifying.
P.S It is not my code :D although its an awesome code.

@momih
Copy link

momih commented Jun 11, 2018

@krayush07 I think it's more of a personal choice where to apply attention weights. In the paper, the authors project the hidden state to the same dimension and then compute attention and apply it to the hidden state. However, in this implementation he projects the hidden state to a lower dimension to compute attention.
So I'm guessing he applies attention to the projected vector instead because he wants a lower dimension for the encoded sentence vector.

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