torch_geometric.transforms.GDC — pytorch_geometric documentation (original) (raw)
class GDC(self_loop_weight: float = 1.0, normalization_in: str = 'sym', normalization_out: str = 'col', diffusion_kwargs: Dict[str, Any] = {'alpha': 0.15, 'method': 'ppr'}, sparsification_kwargs: Dict[str, Any] = {'avg_degree': 64, 'method': 'threshold'}, exact: bool = True)[source]
Bases: BaseTransform
Processes the graph via Graph Diffusion Convolution (GDC) from the“Diffusion Improves Graph Learning”paper (functional name: gdc
).
Note
The paper offers additional advice on how to choose the hyperparameters. For an example of using GCN with GDC, see examples/gcn.py.
Parameters:
- self_loop_weight (float, optional) – Weight of the added self-loop. Set to None to add no self-loops. (default:
1
) - normalization_in (str, optional) – Normalization of the transition matrix on the original (input) graph. Possible values:
"sym"
,"col"
, and"row"
. SeeGDC.transition_matrix()
for details. (default:"sym"
) - normalization_out (str, optional) – Normalization of the transition matrix on the transformed GDC (output) graph. Possible values:
"sym"
,"col"
,"row"
, and None. SeeGDC.transition_matrix()
for details. (default:"col"
) - diffusion_kwargs (dict, optional) – Dictionary containing the parameters for diffusion.method specifies the diffusion method (
"ppr"
,"heat"
or"coeff"
). Each diffusion method requires different additional parameters. SeeGDC.diffusion_matrix_exact()
orGDC.diffusion_matrix_approx()
for details. (default:dict(method='ppr', alpha=0.15)
) - sparsification_kwargs (dict, optional) – Dictionary containing the parameters for sparsification.method specifies the sparsification method (
"threshold"
or"topk"
). Each sparsification method requires different additional parameters. SeeGDC.sparsify_dense()
for details. (default:dict(method='threshold', avg_degree=64)
) - exact (bool, optional) – Whether to exactly calculate the diffusion matrix. Note that the exact variants are not scalable. They densify the adjacency matrix and calculate either its inverse or its matrix exponential. However, the approximate variants do not support edge weights and currently only personalized PageRank and sparsification by threshold are implemented as fast, approximate versions. (default: True)
Return type: