(self, edge_index, num_nodes)
| 115 | return test_acc |
| 116 | |
| 117 | def normalize_adjacency_matrix(self, edge_index, num_nodes): |
| 118 | # edge_index = data.edge_index |
| 119 | # num_nodes = data.y.shape[0] |
| 120 | |
| 121 | edge_index_self_loops = torch.stack( |
| 122 | [torch.arange(num_nodes), torch.arange(num_nodes)], dim=0).to(self.args.device) |
| 123 | edge_index = torch.cat([edge_index, edge_index_self_loops], dim=1) |
| 124 | |
| 125 | adj = torch.sparse_coo_tensor(edge_index, torch.ones( |
| 126 | edge_index.shape[1]).to(self.args.device), (num_nodes, num_nodes)) |
| 127 | |
| 128 | deg = torch.sparse.sum(adj, dim=1).to_dense() |
| 129 | deg_inv_sqrt = deg.pow(-0.5) |
| 130 | deg_inv_sqrt[deg_inv_sqrt == float('inf')] = 0 |
| 131 | |
| 132 | adj_normalized = adj |
| 133 | # adj_normalized = adj.coalesce() |
| 134 | deg_inv_sqrt_mat = torch.sparse_coo_tensor(torch.arange(num_nodes).unsqueeze( |
| 135 | 0).repeat(2, 1).to(self.args.device), deg_inv_sqrt, (num_nodes, num_nodes)) |
| 136 | adj_normalized = torch.sparse.mm( |
| 137 | deg_inv_sqrt_mat, torch.sparse.mm(adj_normalized, deg_inv_sqrt_mat)) |
| 138 | |
| 139 | return adj_normalized |
| 140 | |
| 141 | |
| 142 | class Text_Lora(nn.Module): |
no outgoing calls
no test coverage detected