MCPcopy Create free account
hub / github.com/PyGCL/PyGCL / compute_markov_diffusion

Function compute_markov_diffusion

GCL/augmentors/functional.py:270–286  ·  view source on GitHub ↗
(
        edge_index: torch.LongTensor, edge_weight: torch.FloatTensor = None,
        alpha: float = 0.1, degree: int = 10,
        sp_eps: float = 1e-3, add_self_loop: bool = True)

Source from the content-addressed store, hash-verified

268
269
270def compute_markov_diffusion(
271 edge_index: torch.LongTensor, edge_weight: torch.FloatTensor = None,
272 alpha: float = 0.1, degree: int = 10,
273 sp_eps: float = 1e-3, add_self_loop: bool = True):
274 adj = get_sparse_adj(edge_index, edge_weight, add_self_loop)
275
276 z = adj.to_dense()
277 t = adj.to_dense()
278 for _ in range(degree):
279 t = (1.0 - alpha) * torch.spmm(adj, t)
280 z += t
281 z /= degree
282 z = z + alpha * adj
283
284 adj_t = z.t()
285
286 return GDC().sparsify_dense(adj_t, method='threshold', eps=sp_eps)
287
288
289def coalesce_edge_index(edge_index: torch.Tensor, edge_weights: Optional[torch.Tensor] = None) -> (torch.Tensor, torch.FloatTensor):

Callers 1

augmentMethod · 0.90

Calls 1

get_sparse_adjFunction · 0.85

Tested by

no test coverage detected