UKPLab / coling2018-graph-neural-networks-question-answering

Accompanying code for our COLING 2018 paper "Modeling Semantics with Gated Graph Neural Networks for Knowledge Base Question Answering"
Apache License 2.0
172 stars 29 forks source link

A_node #2

Closed littletomato closed 5 years ago

littletomato commented 5 years ago

Hi, Could you please tell me the kind of the values in variable A_node?Are they 0 or 1 values representing the edges between two nodes? Thanks,

daniilsorokin commented 5 years ago

Hi,

it's bit different from the original GGNN implementation, because it takes a bit less space that way. A_nodes is a matrix that contains for each node the ids of the nodes that are connected to it.

So you could have a graph of 4 nodes with ids [1,2,3,4]. Then the A_nodes matrix could be: [ [2,4,0,0] [4,0,0,0] [4,0,0,0] [2,0,0,0] ]

which means that node 1 has an outgoing connection to 2 and 4 (see the first row), node 2 is connected to 4 (the second row) and so on.

Daniil

littletomato commented 5 years ago

Hi,

Thanks for your reply! I still have another confusion which about the forward function in GNN model. In my opinion, After the function of unsqueeze() and expand(), A_nodes have the dimension of (batch_size, v, 2v, d) and A_edges have the dimension of (batch_size, v, 2r, d),(here d representing the dimension of one node and one edge). The variable nodes have the same dimension with A_nodes after torch.gather() and the variable edges are same with A_edges. So my confusion is how the expression (nodes nodes_mask + edges edges_mask )works with different dimensions(batch_size, v, 2v, d) vs (batch_size, v, 2r,d)?

In addition, in your paper i am confused about the dimension of matrix A_v and the matrix A_r and output A_vt in the formulation one, because i feel that the dimension of the matrix A is different from that in original GGNN.

Thanks, Lin

daniilsorokin commented 5 years ago

Hi,

you are right about (batch_size, v, 2v, d) vs (batch_size, v, 2r,d). In our case we generate the vectors for nodes and the vectors for edges from the same word embeddings, so it is just v==r.

As to your second question, the dimensions are different from the original paper. Since nodes and edges are different for each graph, we store only relevant node and edge vectors and use the A matrices similar to word embedding indices. Let me know if you have a specific questions, I will be happy to dig into it.

I am sorry for the delay with the answer!

Best Daniil

TaylorWPY commented 5 years ago

Hi, Could you also explain the meaning of A_edges?

daniilsorokin commented 5 years ago

We need two matrices: A_nodes and A_edges. A_nodes stores for each node the indices of the nodes that it is connected to and A_edges stores the corresponding relation type for each of theses connection.

daniilsorokin commented 5 years ago

Closing it for now, feel free to reopen if you have more questions.