| 4 | import dgl.function as fn |
| 5 | |
| 6 | class MLP(torch.nn.Module): |
| 7 | def __init__(self, *sizes, batchnorm=False): |
| 8 | super().__init__() |
| 9 | fcs = [] |
| 10 | for i in range(1, len(sizes)): |
| 11 | fcs.append(torch.nn.Linear(sizes[i - 1], sizes[i])) |
| 12 | if i < len(sizes) - 1: |
| 13 | fcs.append(torch.nn.LeakyReLU(negative_slope=0.2)) |
| 14 | if batchnorm: fcs.append(torch.nn.BatchNorm1d(sizes[i])) |
| 15 | self.layers = torch.nn.Sequential(*fcs) |
| 16 | |
| 17 | def forward(self, x): |
| 18 | return self.layers(x) |
| 19 | |
| 20 | class NetConv(torch.nn.Module): |
| 21 | def __init__(self, in_nf, in_ef, out_nf, h1=16, h2=16): |