| 14 | |
| 15 | |
| 16 | class GConv(nn.Module): |
| 17 | def __init__(self, input_dim, hidden_dim, num_layers): |
| 18 | super(GConv, self).__init__() |
| 19 | self.layers = torch.nn.ModuleList() |
| 20 | self.activations = torch.nn.ModuleList() |
| 21 | for i in range(num_layers): |
| 22 | if i == 0: |
| 23 | self.layers.append(GCNConv(input_dim, hidden_dim)) |
| 24 | else: |
| 25 | self.layers.append(GCNConv(hidden_dim, hidden_dim)) |
| 26 | self.activations.append(nn.PReLU(hidden_dim)) |
| 27 | |
| 28 | def forward(self, x, edge_index, edge_weight=None): |
| 29 | z = x |
| 30 | for conv, act in zip(self.layers, self.activations): |
| 31 | z = conv(z, edge_index, edge_weight) |
| 32 | z = act(z) |
| 33 | return z |
| 34 | |
| 35 | |
| 36 | class Encoder(torch.nn.Module): |