# CFConv¶

class dgl.nn.pytorch.conv.CFConv(node_in_feats, edge_in_feats, hidden_feats, out_feats)[source]

Bases: torch.nn.modules.module.Module

It combines node and edge features in message passing and updates node representations.

$h_i^{(l+1)} = \sum_{j\in \mathcal{N}(i)} h_j^{l} \circ W^{(l)}e_ij$

where $$\circ$$ represents element-wise multiplication and for $$\text{SPP}$$ :

$\text{SSP}(x) = \frac{1}{\beta} * \log(1 + \exp(\beta * x)) - \log(\text{shift})$
Parameters
• node_in_feats (int) – Size for the input node features $$h_j^{(l)}$$.

• edge_in_feats (int) – Size for the input edge features $$e_ij$$.

• hidden_feats (int) – Size for the hidden representations.

• out_feats (int) – Size for the output representations $$h_j^{(l+1)}$$.

Example

>>> import dgl
>>> import numpy as np
>>> import torch as th
>>> from dgl.nn import CFConv
>>> g = dgl.graph(([0,1,2,3,2,5], [1,2,3,4,0,3]))
>>> nfeat = th.ones(6, 10)
>>> efeat = th.ones(6, 5)
>>> conv = CFConv(10, 5, 3, 2)
>>> res = conv(g, nfeat, efeat)
>>> res
tensor([[-0.1209, -0.2289],
[-0.1209, -0.2289],
[-0.1209, -0.2289],
[-0.1135, -0.2338],
[-0.1209, -0.2289],

forward(g, node_feats, edge_feats)[source]

Performs message passing and updates node representations.

Parameters
• g (DGLGraph) – The graph.

• node_feats (torch.Tensor or pair of torch.Tensor) – The input node features. If a torch.Tensor is given, it represents the input node feature of shape $$(N, D_{in})$$ where $$D_{in}$$ is size of input feature, $$N$$ is the number of nodes. If a pair of torch.Tensor is given, which is the case for bipartite graph, the pair must contain two tensors of shape $$(N_{src}, D_{in_{src}})$$ and $$(N_{dst}, D_{in_{dst}})$$ separately for the source and destination nodes.

• edge_feats (torch.Tensor) – The input edge feature of shape $$(E, edge_in_feats)$$ where $$E$$ is the number of edges.

Returns

The output node feature of shape $$(N_{out}, out_feats)$$ where $$N_{out}$$ is the number of destination nodes.

Return type

torch.Tensor