Preprocessing of adjacency matrix for simple pygGCN model and conversion to tuple representation.
(adj, is_sparse=False)
| 121 | |
| 122 | |
| 123 | def preprocess_adj(adj, is_sparse=False): |
| 124 | """Preprocessing of adjacency matrix for simple pygGCN model and conversion to |
| 125 | tuple representation.""" |
| 126 | adj_normalized = normalize_adj(adj + sp.eye(adj.shape[0])) |
| 127 | if is_sparse: |
| 128 | adj_normalized = sparse_mx_to_torch_sparse_tensor(adj_normalized) |
| 129 | return adj_normalized |
| 130 | else: |
| 131 | return th.from_numpy(adj_normalized.A).float() |
| 132 | |
| 133 | |
| 134 | def sparse_mx_to_torch_sparse_tensor(sparse_mx): |
no test coverage detected