# DenseChebConv¶

class dgl.nn.pytorch.conv.DenseChebConv(in_feats, out_feats, k, bias=True)[source]

Bases: torch.nn.modules.module.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
• in_feats (int) – Dimension of input features $$h_i^{(l)}$$.

• out_feats (int) – Dimension of output features $$h_i^{(l+1)}$$.

• k (int) – Chebyshev filter size.

• activation (function, optional) – Activation function, default is ReLu.

• bias (bool, optional) – If True, adds a learnable bias to the output. Default: True.

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],


ChebConv

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 $$(N, N)$$, where a row represents the destination and a column represents the source.

• feat (torch.Tensor) – The input feature of shape $$(N, D_{in})$$ where $$D_{in}$$ is size of input feature, $$N$$ 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 $$(N, D_{out})$$ where $$D_{out}$$ is size of output feature.

Return type

torch.Tensor

reset_parameters()[source]

Reinitialize learnable parameters.