mindspore_gl.nn.ChebConv

class mindspore_gl.nn.ChebConv(in_channels: int, out_channels: int, k: int = 3, bias: bool = True)[源代码]

切比雪夫谱图卷积层。来自论文 Convolutional Neural Networks on Graphs with Fast Localized Spectral Filtering

X=σ(k=1KβkTk(L^)X)L^=2L/λmaxI

Tk 递归计算方式为

Tk(L^)=2L^Tk1Tk2

其中 k 是1或2

T0(L^)=IT1(L^)=L^
参数:
  • in_channels (int) - 输入节点特征大小。

  • out_channels (int) - 输出节点特征大小。

  • k (int, 可选) - Chebyshev过滤器大小。默认值:3。

  • bias (bool, 可选) - 是否使用偏置。默认值:True。

输入:
  • x (Tensor) - 输入节点功能。Shape为 (N,Din) 其中 N 应等于参数中的 in_channels

  • edge_weight (Tensor) - 边权重。Shape为 (N_e,) 其中 N_e 是边的数量。

  • g (Graph) - 输入图。

输出:
  • Tensor,输出节点特征的Shape为 (N,Dout) 其中 (Dout) 应与参数中的 out_size 相等。

异常:
  • TypeError - 如果 in_channelsout_channelsk 不是int。

  • TypeError - 如果 bias 不是bool。

支持平台:

Ascend GPU

样例:

>>> import mindspore as ms
>>> from mindspore_gl.nn import ChebConv
>>> from mindspore_gl import GraphField
>>> from mindspore_gl.utils import norm
>>> n_nodes = 2
>>> feat_size = 4
>>> edge_index = [[0, 1], [1, 0]]
>>> edge_index = ms.Tensor(edge_index, ms.int32)
>>> ones = ms.ops.Ones()
>>> feat = ones((n_nodes, feat_size), ms.float32)
>>> edge_index, edge_weight = norm(edge_index, n_nodes)
>>> feat = ones((n_nodes, feat_size), ms.float32)
>>> checonv = ChebConv(in_channels=feat_size, out_channels=4, k=3)
>>> res = checonv(feat, edge_weight, *graph_field.get_graph())
>>> print(res.shape)
(2, 4)