MCPcopy
hub / github.com/dmlc/dgl / test_dense_cheb_conv

Function test_dense_cheb_conv

tests/python/tensorflow/test_nn.py:604–628  ·  view source on GitHub ↗
(out_dim)

Source from the content-addressed store, hash-verified

602
603@pytest.mark.parametrize("out_dim", [1, 2])
604def test_dense_cheb_conv(out_dim):
605 for k in range(3, 4):
606 ctx = F.ctx()
607 g = dgl.DGLGraph(
608 sp.sparse.random(100, 100, density=0.1, random_state=42)
609 )
610 g = g.to(ctx)
611
612 adj = tf.sparse.to_dense(
613 tf.sparse.reorder(g.adj_external(transpose=True, ctx=ctx))
614 )
615 cheb = nn.ChebConv(5, out_dim, k, None, bias=True)
616 dense_cheb = nn.DenseChebConv(5, out_dim, k, bias=True)
617
618 # init cheb modules
619 feat = F.ones((100, 5))
620 out_cheb = cheb(g, feat, [2.0])
621
622 dense_cheb.W = tf.reshape(cheb.linear.weights[0], (k, 5, out_dim))
623 if cheb.linear.bias is not None:
624 dense_cheb.bias = cheb.linear.bias
625
626 out_dense_cheb = dense_cheb(adj, feat, 2.0)
627 print(out_cheb - out_dense_cheb)
628 assert F.allclose(out_cheb, out_dense_cheb)
629
630
631if __name__ == "__main__":

Callers 1

test_nn.pyFile · 0.70

Calls 4

toMethod · 0.95
adj_externalMethod · 0.95
to_denseMethod · 0.80
ctxMethod · 0.45

Tested by

no test coverage detected