knowledge_graph_attention_network icon indicating copy to clipboard operation
knowledge_graph_attention_network copied to clipboard

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

Open chengaojie0011 opened this issue 5 years ago • 5 comments

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.

chengaojie0011 avatar Jul 22 '20 09:07 chengaojie0011

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?

johnnyjana730 avatar Jul 31 '20 07:07 johnnyjana730

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 .

xiangwang1223 avatar Aug 03 '20 14:08 xiangwang1223

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.

chengaojie0011 avatar Aug 03 '20 15:08 chengaojie0011

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.

xiangwang1223 avatar Aug 04 '20 08:08 xiangwang1223

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. https://github.com/xiangwang1223/knowledge_graph_attention_network/blob/c03737be46ac26a0b5431efe149828e982ffbbfb/Model/KGAT.py#L465-L466

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

ljch2018 avatar Jul 02 '21 09:07 ljch2018