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

我们建议在密集图上应用ChebConv时使用此模块。

Parameters:
  • in_feats (int) – 输入特征的维度 \(h_i^{(l)}\)

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

  • k (int) – 切比雪夫滤波器大小。

  • activation (function, optional) – 激活函数,默认为ReLu。

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

示例

>>> 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>)

另请参阅

ChebConv

forward(adj, feat, lambda_max=None)[source]

计算(密集)切比雪夫谱图卷积层

Parameters:
  • adj (torch.Tensor) – 要应用图卷积的图的邻接矩阵, 应为形状 \((N, N)\),其中一行表示目标节点, 一列表示源节点。

  • 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 (floatNone, 可选) – 一个浮点值,表示给定图的最大特征值。 默认值: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]

重新初始化可学习的参数。