torch_geometric.nn.conv.GeneralConv
- class GeneralConv(in_channels: Union[int, Tuple[int, int]], out_channels: Optional[int], in_edge_channels: Optional[int] = None, aggr: str = 'add', skip_linear: str = False, directed_msg: bool = True, heads: int = 1, attention: bool = False, attention_type: str = 'additive', l2_normalize: bool = False, bias: bool = True, **kwargs)[source]
Bases:
MessagePassing一个通用的GNN层,改编自“图神经网络的设计空间”论文。
- Parameters:
in_channels (int or tuple) – Size of each input sample, or
-1to derive the size from the first input(s) to the forward method. A tuple corresponds to the sizes of source and target dimensionalities.out_channels (int) – Size of each output sample.
aggr (str, optional) – The aggregation scheme to use (
"add","mean","max"). (default:"mean")directed_msg (bool, optional) – 如果消息传递是定向的; 否则,消息传递是双向的。(默认值:
True)heads (int, optional) – 消息传递集合的数量。 如果
heads > 1,GNN 层将输出多个消息的集合。 如果使用了注意力机制 (attention=True),这对应于多头注意力机制。(默认值:1)attention_type (str, optional) – 注意力类型:
"additive","dot_product". (默认:"additive")l2_normalize (bool, 可选) – 如果设置为
True, 输出特征 将会被 \(\ell_2\)-归一化, 即, \(\frac{\mathbf{x}^{\prime}_i} {\| \mathbf{x}^{\prime}_i \|_2}\). (默认:False)bias (bool, optional) – If set to
False, the layer will not learn an additive bias. (default:True)**kwargs (optional) – Additional arguments of
torch_geometric.nn.conv.MessagePassing.
- Shapes:
input: node features \((|\mathcal{V}|, F_{in})\) or \(((|\mathcal{V_s}|, F_{s}), (|\mathcal{V_t}|, F_{t}))\) if bipartite, edge indices \((2, |\mathcal{E}|)\), edge attributes \((|\mathcal{E}|, D)\) (optional)
output: node features \((|\mathcal{V}|, F_{out})\) or \((|\mathcal{V}_t|, F_{out})\) if bipartite