def test_agnn_conv_bi(g, idtype): g = g.astype(idtype).to(F.ctx()) ctx = F.ctx() agnn_conv = nn.AGNNConv(0.1, True) agnn_conv.initialize(ctx=ctx) print(agnn_conv) feat = (F.randn((g.number_of_src_nodes(), 5)), F.randn((g.number_of_dst_nodes(), 5))) h = agnn_conv(g, feat) assert h.shape == (g.number_of_dst_nodes(), 5)
def test_agnn_conv(): g = dgl.DGLGraph(nx.erdos_renyi_graph(20, 0.3)) ctx = F.ctx() agnn_conv = nn.AGNNConv(0.1, True) agnn_conv.initialize(ctx=ctx) print(agnn_conv) # test#1: basic h0 = F.randn((20, 10)) h1 = agnn_conv(g, h0) assert h1.shape == (20, 10)
def test_agnn_conv(): g = dgl.DGLGraph(nx.erdos_renyi_graph(20, 0.3)) ctx = F.ctx() agnn_conv = nn.AGNNConv(0.1, True) agnn_conv.initialize(ctx=ctx) print(agnn_conv) # test#1: basic feat = F.randn((20, 10)) h = agnn_conv(g, feat) assert h.shape == (20, 10) g = dgl.bipartite(sp.sparse.random(100, 200, density=0.1)) feat = (F.randn((100, 5)), F.randn((200, 5))) h = agnn_conv(g, feat) assert h.shape == (200, 5)
def test_agnn_conv(): g = dgl.DGLGraph(nx.erdos_renyi_graph(20, 0.3)) ctx = F.ctx() agnn_conv = nn.AGNNConv(0.1, True) agnn_conv.initialize(ctx=ctx) print(agnn_conv) # test#1: basic feat = F.randn((20, 10)) h = agnn_conv(g, feat) assert h.shape == (20, 10) g = dgl.bipartite(sp.sparse.random(100, 200, density=0.1)) feat = (F.randn((100, 5)), F.randn((200, 5))) h = agnn_conv(g, feat) assert h.shape == (200, 5) g = dgl.graph(sp.sparse.random(100, 100, density=0.001)) seed_nodes = np.unique(g.edges()[1].asnumpy()) block = dgl.to_block(g, seed_nodes) feat = F.randn((block.number_of_src_nodes(), 5)) h = agnn_conv(block, feat) assert h.shape == (block.number_of_dst_nodes(), 5)