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

Does the attention used in codes the same with the one in paper? #33

Closed
hapoyige opened this issue Sep 22, 2019 · 4 comments
Closed

Does the attention used in codes the same with the one in paper? #33

hapoyige opened this issue Sep 22, 2019 · 4 comments

Comments

@hapoyige
Copy link

I find in function attn_head() (in utils/layers.py)
'''

simplest self-attention possible

f_1 = tf.layers.conv1d(seq_fts, 1, 1)
f_2 = tf.layers.conv1d(seq_fts, 1, 1)
logits = f_1 + tf.transpose(f_2, [0, 2, 1])
coefs = tf.nn.softmax(tf.nn.leaky_relu(logits) + bias_mat)
'''
In my understanding,the codes equals to $$f_1 W_1 + f_2 W_2$$
but in the paper, the chose attention mechanism use concatenation, and
$$W_1 = W_2 = W$$
Did I get something wrong?

@KL-ice
Copy link

KL-ice commented Sep 22, 2019

Hello, I have encountered the same problem as you.
Also, in ./utils/layers.py, I didn't understand how the code calculates the correlation between f_1 and f_2.
I have seen the code for the pytorch version, and I think the implementation of the two is different in this place.
The pytorch version of the code is sensitive to the choice of random seeds, and switching to a different random seed can make the results very different.

@PetarV-
Copy link
Owner

PetarV- commented Sep 22, 2019

Hello,

Thank you for your issue and interest in GAT!

The way in which attention heads are implemented here is exactly equivalent to the one in the paper, and it uses TensorFlow broadcasting semantics heavily.

For more details, see my response in this issue:
https://github.com/PetarV-/GAT/issues/15

Thanks,
Petar

@KL-ice
Copy link

KL-ice commented Sep 22, 2019

Hi, Peter.
I have read the issue. Thank you very much for your reply, he has helped me a great deal.
Thanks,
Ice

@hapoyige
Copy link
Author

Thanks a lot, Petar, I understood!

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

3 participants