(encoder_model, dataloader)
| 94 | |
| 95 | |
| 96 | def test(encoder_model, dataloader): |
| 97 | encoder_model.eval() |
| 98 | x = [] |
| 99 | y = [] |
| 100 | for data in dataloader: |
| 101 | data = data.to('cuda') |
| 102 | if data.x is None: |
| 103 | num_nodes = data.batch.size(0) |
| 104 | data.x = torch.ones((num_nodes, 1), dtype=torch.float32, device=data.batch.device) |
| 105 | _, _, g1, g2 = encoder_model(data.x, data.edge_index, data.batch) |
| 106 | x.append(g1 + g2) |
| 107 | y.append(data.y) |
| 108 | x = torch.cat(x, dim=0) |
| 109 | y = torch.cat(y, dim=0) |
| 110 | |
| 111 | split = get_split(num_samples=x.size()[0], train_ratio=0.8, test_ratio=0.1) |
| 112 | result = SVMEvaluator(linear=True)(x, y, split) |
| 113 | return result |
| 114 | |
| 115 | |
| 116 | def main(): |
no test coverage detected