GithubHelp home page GithubHelp logo

Comments (5)

krayush07 avatar krayush07 commented on July 26, 2024 1

@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.

from hierarchical-attention-networks.

diegow88 avatar diegow88 commented on July 26, 2024

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

from hierarchical-attention-networks.

heisenbugfix avatar heisenbugfix commented on July 26, 2024

@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

from hierarchical-attention-networks.

heisenbugfix avatar heisenbugfix commented on July 26, 2024

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

from hierarchical-attention-networks.

momih avatar momih commented on July 26, 2024

@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.

from hierarchical-attention-networks.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.