GINEConv

class dgl.nn.pytorch.conv.GINEConv(apply_func=None, init_eps=0, learn_eps=False)[source]

Bases: Module

Graph Isomorphism Network with Edge Features, introduced by Strategies for Pre-training Graph Neural Networks

hi(l+1)=fΘ((1+Ο΅)hil+βˆ‘j∈N(i)ReLU(hjl+ej,il))

where ej,il is the edge feature.

Parameters:
  • apply_func (callable module or None) – The fΘ in the formula. If not None, it will be applied to the updated node features. The default value is None.

  • init_eps (float, optional) – Initial Ο΅ value, default: 0.

  • learn_eps (bool, optional) – If True, Ο΅ will be a learnable parameter. Default: False.

Examples

>>> import dgl
>>> import torch
>>> import torch.nn as nn
>>> from dgl.nn import GINEConv
>>> g = dgl.graph(([0, 1, 2], [1, 1, 3]))
>>> in_feats = 10
>>> out_feats = 20
>>> nfeat = torch.randn(g.num_nodes(), in_feats)
>>> efeat = torch.randn(g.num_edges(), in_feats)
>>> conv = GINEConv(nn.Linear(in_feats, out_feats))
>>> res = conv(g, nfeat, efeat)
>>> print(res.shape)
torch.Size([4, 20])
forward(graph, node_feat, edge_feat)[source]

Forward computation.

Parameters:
  • graph (DGLGraph) – The graph.

  • node_feat (torch.Tensor or pair of torch.Tensor) – If a torch.Tensor is given, it is the input feature of shape (N,Din) where Din is size of input feature, N is the number of nodes. If a pair of torch.Tensor is given, the pair must contain two tensors of shape (Nin,Din) and (Nout,Din). If apply_func is not None, Din should fit the input feature size requirement of apply_func.

  • edge_feat (torch.Tensor) – Edge feature. It is a tensor of shape (E,Din) where E is the number of edges.

Returns:

The output feature of shape (N,Dout) where Dout is the output feature size of apply_func. If apply_func is None, Dout should be the same as Din.

Return type:

torch.Tensor