(self, input_dim, layer_num=2, hidden_size=128, output_dim=128, activation="relu", dropout=0.5, norm='id', last_activation=True)
| 316 | @register.encoder_register |
| 317 | class MLP_Encoder(torch.nn.Module): |
| 318 | def __init__(self, input_dim, layer_num=2, hidden_size=128, output_dim=128, activation="relu", dropout=0.5, norm='id', last_activation=True): |
| 319 | super(MLP_Encoder, self).__init__() |
| 320 | self.layer_num = layer_num |
| 321 | self.hidden_size = hidden_size |
| 322 | self.input_dim = input_dim |
| 323 | self.activation = get_activation(activation) |
| 324 | self.dropout = torch.nn.Dropout(dropout) |
| 325 | self.last_act = last_activation |
| 326 | self.norm_type = norm |
| 327 | |
| 328 | self.convs = ModuleList() |
| 329 | self.norms = ModuleList() |
| 330 | |
| 331 | self.readout = global_mean_pool |
| 332 | # self.acts = ModuleList() |
| 333 | if self.layer_num > 1: |
| 334 | self.convs.append(nn.Linear(input_dim, hidden_size)) |
| 335 | for i in range(layer_num-2): |
| 336 | self.convs.append(nn.Linear(hidden_size, hidden_size)) |
| 337 | self.convs.append(nn.Linear(hidden_size, output_dim)) |
| 338 | # glorot(self.convs[-1].weight) |
| 339 | for i in range(layer_num-1): |
| 340 | self.norms.append(get_norm(self.norm_type)(hidden_size)) |
| 341 | self.norms.append(get_norm(self.norm_type)(output_dim)) |
| 342 | |
| 343 | else: # one layer gcn |
| 344 | self.convs.append(nn.Linear(input_dim, output_dim)) |
| 345 | # glorot(self.convs[-1].weight) |
| 346 | self.norms.append(get_norm(self.norm_type)(output_dim)) |
| 347 | # self.acts.append(self.activation) |
| 348 | |
| 349 | def forward(self, x, edge_index=None, **kwargs): |
| 350 | for i in range(self.layer_num): |
nothing calls this directly
no test coverage detected