def test_gmm_conv(): ctx = F.ctx() g = dgl.DGLGraph(sp.sparse.random(100, 100, density=0.1), readonly=True) gmmconv = nn.GMMConv(5, 10, 3, 4, 'mean') feat = F.randn((100, 5)) pseudo = F.randn((g.number_of_edges(), 3)) gmmconv = gmmconv.to(ctx) h = gmmconv(g, feat, pseudo) # currently we only do shape check assert h.shape[-1] == 10 g = dgl.graph(sp.sparse.random(100, 100, density=0.1), readonly=True) gmmconv = nn.GMMConv(5, 10, 3, 4, 'mean') feat = F.randn((100, 5)) pseudo = F.randn((g.number_of_edges(), 3)) gmmconv = gmmconv.to(ctx) h = gmmconv(g, feat, pseudo) # currently we only do shape check assert h.shape[-1] == 10 g = dgl.bipartite(sp.sparse.random(100, 50, density=0.1), readonly=True) gmmconv = nn.GMMConv((5, 2), 10, 3, 4, 'mean') feat = F.randn((100, 5)) feat_dst = F.randn((50, 2)) pseudo = F.randn((g.number_of_edges(), 3)) gmmconv = gmmconv.to(ctx) h = gmmconv(g, (feat, feat_dst), pseudo) # currently we only do shape check assert h.shape[-1] == 10
def test_gmm_conv(g, idtype): g = g.astype(idtype).to(F.ctx()) ctx = F.ctx() gmmconv = nn.GMMConv(5, 10, 3, 4, 'mean') feat = F.randn((g.number_of_nodes(), 5)) pseudo = F.randn((g.number_of_edges(), 3)) gmmconv = gmmconv.to(ctx) h = gmmconv(g, feat, pseudo) # currently we only do shape check assert h.shape[-1] == 10
def test_gmm_conv(): ctx = F.ctx() g = dgl.DGLGraph(sp.sparse.random(100, 100, density=0.1), readonly=True) gmmconv = nn.GMMConv(5, 10, 3, 4, 'mean') feat = F.randn((100, 5)) pseudo = F.randn((g.number_of_edges(), 3)) gmmconv = gmmconv.to(ctx) h = gmmconv(g, feat, pseudo) # currently we only do shape check assert h.shape[-1] == 10 g = dgl.graph(sp.sparse.random(100, 100, density=0.1), readonly=True) gmmconv = nn.GMMConv(5, 10, 3, 4, 'mean') feat = F.randn((100, 5)) pseudo = F.randn((g.number_of_edges(), 3)) gmmconv = gmmconv.to(ctx) h = gmmconv(g, feat, pseudo) # currently we only do shape check assert h.shape[-1] == 10 g = dgl.bipartite(sp.sparse.random(100, 50, density=0.1), readonly=True) gmmconv = nn.GMMConv((5, 2), 10, 3, 4, 'mean') feat = F.randn((100, 5)) feat_dst = F.randn((50, 2)) pseudo = F.randn((g.number_of_edges(), 3)) gmmconv = gmmconv.to(ctx) h = gmmconv(g, (feat, feat_dst), pseudo) # currently we only do shape check assert h.shape[-1] == 10 g = dgl.graph(sp.sparse.random(100, 100, density=0.001)) seed_nodes = th.unique(g.edges()[1]) block = dgl.to_block(g, seed_nodes) gmmconv = nn.GMMConv(5, 10, 3, 4, 'mean') feat = F.randn((block.number_of_src_nodes(), 5)) pseudo = F.randn((block.number_of_edges(), 3)) gmmconv = gmmconv.to(ctx) h = gmmconv(block, feat, pseudo) assert h.shape[0] == block.number_of_dst_nodes() assert h.shape[-1] == 10
def test_gmm_conv(): ctx = F.ctx() g = dgl.DGLGraph(sp.sparse.random(100, 100, density=0.1), readonly=True) gmmconv = nn.GMMConv(5, 10, 3, 4, 'mean') feat = F.randn((100, 5)) pseudo = F.randn((g.number_of_edges(), 3)) if F.gpu_ctx(): gmmconv = gmmconv.to(ctx) feat = feat.to(ctx) pseudo = pseudo.to(ctx) h = gmmconv(g, feat, pseudo) # currently we only do shape check assert h.shape[-1] == 10