| 14 | |
| 15 | |
| 16 | class GConv(torch.nn.Module): |
| 17 | def __init__(self, input_dim, hidden_dim, activation, num_layers): |
| 18 | super(GConv, self).__init__() |
| 19 | self.activation = activation() |
| 20 | self.layers = torch.nn.ModuleList() |
| 21 | self.layers.append(GCNConv(input_dim, hidden_dim, cached=False)) |
| 22 | for _ in range(num_layers - 1): |
| 23 | self.layers.append(GCNConv(hidden_dim, hidden_dim, cached=False)) |
| 24 | |
| 25 | def forward(self, x, edge_index, edge_weight=None): |
| 26 | z = x |
| 27 | for i, conv in enumerate(self.layers): |
| 28 | z = conv(z, edge_index, edge_weight) |
| 29 | z = self.activation(z) |
| 30 | return z |
| 31 | |
| 32 | |
| 33 | class Encoder(torch.nn.Module): |