Replies: 1 comment 12 replies
-
We have an open pull request for this, see #3078. Supporting edge features in class GATConv(MessagePassing):
def __init__(self, ...):
super().__init__(aggr='add')
self.lin = Linear(in_channels, heads * out_channels)
self.att = Parameter(torch.Tensor(1, heads, 2 * out_channels + edge_dim)
def forward(self, x, edge_index, edge_attr):
x = self.lin(x)
return self.propagate(edge_index, x=x=, edge_attr):
def message(self, x_i, x_j, edge_attr, index, size_i):
x_i = x_i.view(-1, heads, out_channels)
x_j = x_j.view(-1, heads, out_channels)
edge_attr = edge_attr.view(-1, 1, edge_dim)
out = torch.cat([x_i, x_j, edge_attr], dim=-1)
alpha = (out * self.att).sum(dim=-1)
alpha = softmax(alpha, index, num_nodes=size_i)
return x_j * alpha.unsqueeze(-1) |
Beta Was this translation helpful? Give feedback.
12 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
I have a set of 35 graphs, with one node feature and one edge feature. They have nodes, that need to be classified into 2 classes.
I am trying to write a GNN of the following form:
Input Layers:
Linear(1,32)
ReLU
Linear(32,32)
ReLU
2 attention layers, using GAT
Output Layer:
Linear(32,32)
ReLU
Linear(32,2)
Softmax
I have so far used the examples here, but have not written a GNN of my own. I am particularly struggling with GAT, since the GATConv doesn't include edge attributes, but I want to include them. Could you please help me write a basic code for this.
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions