MCPcopy Create free account
hub / github.com/RolnickLab/climart / in_degree_normalization

Function in_degree_normalization

climart/data_transform/normalization.py:18–29  ·  view source on GitHub ↗

For Graph networks :param adj: A N x N adjacency matrix :return: In-degree normalized matrix (Row-normalized matrix)

(adj: np.ndarray)

Source from the content-addressed store, hash-verified

16
17
18def in_degree_normalization(adj: np.ndarray):
19 """
20 For Graph networks
21 :param adj: A N x N adjacency matrix
22 :return: In-degree normalized matrix (Row-normalized matrix)
23 """
24 rowsum = np.array(adj.sum(1))
25 r_inv = np.power(rowsum, -1).flatten()
26 r_inv[np.isinf(r_inv)] = 0.0
27 r_mat_inv = np.diag(r_inv)
28 mx = r_mat_inv @ adj
29 return mx
30
31
32

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected