graphstorm.model.SAGEConv

class graphstorm.model.SAGEConv(in_feat, out_feat, aggregator_type='mean', bias=True, dropout=0.0, activation=<function relu>, num_ffn_layers_in_gnn=0, ffn_activation=<function relu>, norm=None)

GraphSage Convolutional layerfrom Inductive Representation Learning on Large Graphs

\[ \begin{align}\begin{aligned}h_{\mathcal{N}(i)}^{(l+1)} &= \mathrm{aggregate} \left(\{h_{j}^{l}, \forall j \in \mathcal{N}(i) \}\right)\\h_{i}^{(l+1)} &= \sigma \left(W \cdot \mathrm{concat} (h_{i}^{l}, h_{\mathcal{N}(i)}^{l+1}) \right)\\h_{i}^{(l+1)} &= \mathrm{norm}(h_{i}^{(l+1)})\end{aligned}\end{align} \]

If a weight tensor on each edge is provided, the aggregation becomes:

\[h_{\mathcal{N}(i)}^{(l+1)} = \mathrm{aggregate} \left(\{e_{ji} h_{j}^{l}, \forall j \in \mathcal{N}(i) \}\right)\]

where \(e_{ji}\) is the scalar weight on the edge from node \(j\) to node \(i\). Please make sure that \(e_{ji}\) is broadcastable with \(h_j^{l}\).

Note:

  • SAGEConv is only effective on the homogeneous graph, not like other conv implementation.

Examples:

# suppose graph and input_feature are ready
from graphstorm.model.sage_encoder import SAGEConv

layer = SAGEConv(h_dim, h_dim, aggregator_type,
                        bias, activation, dropout,
                        num_ffn_layers_in_gnn, norm)
h = layer(g, input_feature)

Parameters

in_featint

Input feature size.

out_featint

Output feature size.

aggregator_typestr

One of mean, gcn, pool, lstm

biasbool, optional

True if bias is added. Default: True

activationcallable, optional

Activation function. Default: None

dropoutfloat, optional

Dropout rate. Default: 0.0

num_ffn_layers_in_gnn: int, optional

Number of layers of ngnn between gnn layers

ffn_actication: torch.nn.functional

Activation Method for ngnn

normstr, optional

Normalization Method. Default: None