MCPcopy Create free account
hub / github.com/chengsen/PyTorch_TextGCN / preprocess_adj

Function preprocess_adj

utils.py:123–131  ·  view source on GitHub ↗

Preprocessing of adjacency matrix for simple pygGCN model and conversion to tuple representation.

(adj, is_sparse=False)

Source from the content-addressed store, hash-verified

121
122
123def 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
134def sparse_mx_to_torch_sparse_tensor(sparse_mx):

Callers 1

__init__Method · 0.90

Calls 2

normalize_adjFunction · 0.85

Tested by

no test coverage detected