(out_dim)
| 602 | |
| 603 | @pytest.mark.parametrize("out_dim", [1, 2]) |
| 604 | def 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 | |
| 631 | if __name__ == "__main__": |
no test coverage detected