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

The use of func (model.update_attentive_A) maybe wrong in your code. #30

Open
chengaojie0011 opened this issue Jul 22, 2020 · 5 comments

Comments

@chengaojie0011
Copy link

Thank you for offering the code of KGAT paper, and it helps me a lot.
In running code, I found that the function (model.update_attentive_A) use self.A_in to update the matrix A. But as far as I know, TensorFlow cannot change the value of the variable in the static graph in this way. I found experimentally that whatever self.A_in is assigned, it doesn't change the result of the model. If so, KGAT does not use dynamic weights to implement GAT. Look forward to your reply.

@johnnyjana730
Copy link

I am also interested to that question. Have you tried to randomly assign self.A_in and then try to call _create_xxx_embed() again to generate ua_embeddings, ea_embeddings?

@xiangwang1223
Copy link
Owner

Sorry for the late reply after the busy weeks.

  • Please distinguish the self.A_values, which is set as a placeholder, and self.A_in, which is used to feed the values of self.A_values.
  • I have tested the code and show the value in self.A_in (the first 20 values for limited space) in the following picture. As the figure shows, the self.A_in is updated as the epoch increases.
    image

Hope this is helpful for you @chengaojie0011 @johnnyjana730 .

@chengaojie0011
Copy link
Author

Sorry for the late reply after the busy weeks.

  • Please distinguish the self.A_values, which is set as a placeholder, and self.A_in, which is used to feed the values of self.A_values.
  • I have tested the code and show the value in self.A_in (the first 20 values for limited space) in the following picture. As the figure shows, the self.A_in is updated as the epoch increases.
    image

Hope this is helpful for you @chengaojie0011 @johnnyjana730 .

Many thanks for your kind reply. The value of self.A_in has updated in class KGAT(object), but it doesn't update in the model because Tensorflow builds a static graph before a model can run.
I'm not sure If I've explained this problem clearly. If you try to replace self.A_in with any value, you may find the model will still work, and the results of the model also not change.

@xiangwang1223
Copy link
Owner

I have tested three variants, setting self.A_in's values as all zeros, all ones, and random values. The training performance is shown as follows:

  • all-ones
    image

  • all-zeros
    image

  • randoms
    image

Some observations:

  1. The results of three variants w.r.t. four evaluation metrics are different. It thus verifies that the model.update_attentive_A works.
  2. However, the differences are not that significant. We attribute this to some possible reasons: (1) the attention values are iteratively updated, rather than jointly updated with the other parameters. (2) simply applying the attention networks is insufficient to model the relational information. We have an ongoing work towards solving these issues and will later release the code when the work is finished.

Hope this is helpful. Thanks for your insightful comments.

@ljch2018
Copy link

ljch2018 commented Jul 2, 2021

I think @chengaojie0011 is right. Because self.A_in is not a placeholder in graph, the assignment will not work, and never affect the network.

self.A_in = sp.coo_matrix((new_A_values, (rows, cols)), shape=(self.n_users + self.n_entities,
self.n_users + self.n_entities))

if you set this exactly self.A_in to zero or one, the performance of the model will stay unchanged.

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