DenseChebConvο
- class dgl.nn.pytorch.conv.DenseChebConv(in_feats, out_feats, k, bias=True)[source]ο
Bases:
Module
Chebyshev Spectral Graph Convolution layer from Convolutional Neural Networks on Graphs with Fast Localized Spectral Filtering
We recommend to use this module when applying ChebConv on dense graphs.
- Parameters:
Example
>>> import dgl >>> import numpy as np >>> import torch as th >>> from dgl.nn import DenseChebConv >>> >>> feat = th.ones(6, 10) >>> adj = th.tensor([[0., 0., 1., 0., 0., 0.], ... [1., 0., 0., 0., 0., 0.], ... [0., 1., 0., 0., 0., 0.], ... [0., 0., 1., 0., 0., 1.], ... [0., 0., 0., 1., 0., 0.], ... [0., 0., 0., 0., 0., 0.]]) >>> conv = DenseChebConv(10, 2, 2) >>> res = conv(adj, feat) >>> res tensor([[-3.3516, -2.4797], [-3.3516, -2.4797], [-3.3516, -2.4797], [-4.5192, -3.0835], [-2.5259, -2.0527], [-0.5327, -1.0219]], grad_fn=<AddBackward0>)
See also
- forward(adj, feat, lambda_max=None)[source]ο
Compute (Dense) Chebyshev Spectral Graph Convolution layer
- Parameters:
adj (torch.Tensor) β The adjacency matrix of the graph to apply Graph Convolution on, should be of shape
, where a row represents the destination and a column represents the source.feat (torch.Tensor) β The input feature of shape
where is size of input feature, is the number of nodes.lambda_max (float or None, optional) β A float value indicates the largest eigenvalue of given graph. Default: None.
- Returns:
The output feature of shape
where is size of output feature.- Return type:
torch.Tensor