mindspore_gl.nn.GCNConv2
- class mindspore_gl.nn.GCNConv2(in_feat_size: int, out_size: int)[source]
Graph Convolution Network Layer. from the paper Semi-Supervised Classification with Graph Convolutional Networks .
\[h_i^{(l+1)} = (\sum_{j\in\mathcal{N}(i)}h_j^{(l)}W_1^{(l)}+b^{(l)} )+h_i^{(l)}W_2^{(l)}\]\(\mathcal{N}(i)\) represents the neighbour node of \(i\). \(W_1\) and \(W_2\) correspond to fc layers for neighbor nodes and root node.
- Inputs:
x (Tensor) - The input node features. The shape is \((N, D_{in})\) where \(N\) is the number of nodes, and \(D_{in}\) should be equal to in_feat_size in Args.
g (Graph) - The input graph.
- Outputs:
Tensor, output node features with shape of \((N, D_{out})\), where \((D_{out})\) should be the same as out_size in Args.
- Raises
TypeError – If in_feat_size or out_size is not an int.
- Supported Platforms:
Ascend
GPU
Examples
>>> import mindspore as ms >>> from mindspore_gl.nn import GCNConv2 >>> from mindspore_gl import GraphField >>> n_nodes = 4 >>> n_edges = 7 >>> feat_size = 4 >>> src_idx = ms.Tensor([0, 1, 1, 2, 2, 3, 3], ms.int32) >>> dst_idx = ms.Tensor([0, 0, 2, 1, 3, 0, 1], ms.int32) >>> ones = ms.ops.Ones() >>> feat = ones((n_nodes, feat_size), ms.float32) >>> graph_field = GraphField(src_idx, dst_idx, n_nodes, n_edges) >>> gcnconv2 = GCNConv2(in_feat_size=4, out_size=2) >>> res = gcnconv2(feat, *graph_field.get_graph()) >>> print(res.shape) (4, 2)