-
Notifications
You must be signed in to change notification settings - Fork 11
/
model.py
23 lines (20 loc) · 929 Bytes
/
model.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch_geometric.transforms as T
from torch_geometric.nn import GATConv, Linear
class GAT(torch.nn.Module):
def __init__(self, in_channels, hidden_channels, out_channels, heads):
super().__init__()
self.conv1 = GATConv(in_channels, hidden_channels, heads, dropout=0.6)
self.conv2 = GATConv(hidden_channels * heads, int(hidden_channels/4), heads=1, concat=False, dropout=0.6)
self.lin = Linear(int(hidden_channels/4), out_channels)
self.sigmoid = nn.Sigmoid()
def forward(self, x, edge_index, edge_attr):
x = F.dropout(x, p=0.6, training=self.training)
x = F.elu(self.conv1(x, edge_index, edge_attr))
x = F.dropout(x, p=0.6, training=self.training)
x = F.elu(self.conv2(x, edge_index, edge_attr))
x = self.lin(x)
x = self.sigmoid(x)
return x