GCNNorm

class dgl.transforms.GCNNorm(eweight_name='w')[source]

Bases: dgl.transforms.module.BaseTransform

Apply symmetric adjacency normalization to an input graph and save the result edge weights, as described in Semi-Supervised Classification with Graph Convolutional Networks.

For a heterogeneous graph, this only applies to symmetric canonical edge types, whose source and destination node types are identical.

Parameters

eweight_name (str, optional) – edata name to retrieve and store edge weights. The edge weights are optional.

Example

>>> import dgl
>>> import torch
>>> from dgl import GCNNorm
>>> transform = GCNNorm()
>>> g = dgl.graph(([0, 1, 2], [0, 0, 1]))

Case1: Transform an unweighted graph

>>> g = transform(g)
>>> print(g.edata['w'])
tensor([0.5000, 0.7071, 0.0000])

Case2: Transform a weighted graph

>>> g.edata['w'] = torch.tensor([0.1, 0.2, 0.3])
>>> g = transform(g)
>>> print(g.edata['w'])
tensor([0.3333, 0.6667, 0.0000])