rikdz / GraphWriter

Code for "Text Generation from Knowledge Graphs with Graph Transformers"
517 stars 90 forks source link

MkGraphs Code in lastDataset.py #25

Open anthorax1234 opened 4 years ago

anthorax1234 commented 4 years ago

Hi, I am going over the input data code, particularly the mkGraphs function. I'm a bit confused on the rel matrix, where rel is the list. What exactly is this rel list? Why does it start with [2] and is further extended with ([y[1]+3,y[1]+3+self.REL.size]). Thanks!

wutaiqiang commented 4 years ago

[2] marks the edge to Global Node,y1+3 marks the orgin type edge, and y1+3+self.real.size marks the inversed type edge, they are just numbers and represent the directed edge with different type you can read the paper to know more about the Graph LEVI transfrom

wutaiqiang commented 4 years ago

maybe you can print the rel to see what it is exactly

anthorax1234 commented 4 years ago

Thanks!

Edit: I understood that they represent the directed edge with different type and have printed it before, so were the [2] and "+3" are just chosen arbitrarily?

p.s. Although the paper doesn't explicitly mention anything LEVI Graph transforms, the transform is implicitly one.

ahhussein commented 4 years ago

I understood that they represent the directed edge with different type and have printed it before, so were the [2] and "+3" are just chosen arbitrarily?

The rel root is specified in the REL vocab. See that line self.REL.special = ['<pad>','<unk>','ROOT'] in lastDataset and hence [2] is the index to that root in the REL.special list.