def test_cf_conv(g, idtype): g = g.astype(idtype).to(F.ctx()) cfconv = nn.CFConv(node_in_feats=2, edge_in_feats=3, hidden_feats=2, out_feats=3) ctx = F.ctx() if F.gpu_ctx(): cfconv = cfconv.to(ctx) node_feats = F.randn((g.number_of_nodes(), 2)) edge_feats = F.randn((g.number_of_edges(), 3)) h = cfconv(g, node_feats, edge_feats) # current we only do shape check assert h.shape[-1] == 3
def test_cf_conv(): g = dgl.DGLGraph(sp.sparse.random(100, 100, density=0.1), readonly=True) cfconv = nn.CFConv(node_in_feats=2, edge_in_feats=3, hidden_feats=2, out_feats=3) ctx = F.ctx() if F.gpu_ctx(): cfconv = cfconv.to(ctx) node_feats = F.randn((100, 2)) edge_feats = F.randn((g.number_of_edges(), 3)) h = cfconv(g, node_feats, edge_feats) # current we only do shape check assert h.shape[-1] == 3
def test_cf_conv(g, idtype, out_dim): g = g.astype(idtype).to(F.ctx()) cfconv = nn.CFConv(node_in_feats=2, edge_in_feats=3, hidden_feats=2, out_feats=out_dim) ctx = F.ctx() if F.gpu_ctx(): cfconv = cfconv.to(ctx) src_feats = F.randn((g.number_of_src_nodes(), 2)) edge_feats = F.randn((g.number_of_edges(), 3)) h = cfconv(g, src_feats, edge_feats) # current we only do shape check assert h.shape[-1] == out_dim # case for bipartite graphs dst_feats = F.randn((g.number_of_dst_nodes(), 3)) h = cfconv(g, (src_feats, dst_feats), edge_feats) # current we only do shape check assert h.shape[-1] == out_dim