|
24 | 24 |
|
25 | 25 | test_graphs = [g1, g_single_vertex]
|
26 | 26 |
|
27 |
| - # @testset "GCNConv" begin |
28 |
| - # l = GCNConv(in_channel => out_channel) |
29 |
| - # for g in test_graphs |
30 |
| - # test_layer(l, g, rtol=1e-5, outsize=(out_channel, g.num_nodes)) |
31 |
| - # end |
32 |
| - |
33 |
| - # l = GCNConv(in_channel => out_channel, tanh, bias=false) |
34 |
| - # for g in test_graphs |
35 |
| - # test_layer(l, g, rtol=1e-5, outsize=(out_channel, g.num_nodes)) |
36 |
| - # end |
37 |
| - |
38 |
| - # l = GCNConv(in_channel => out_channel, add_self_loops=false) |
39 |
| - # test_layer(l, g1, rtol=1e-5, outsize=(out_channel, g1.num_nodes)) |
40 |
| - # end |
41 |
| - |
42 |
| - # @testset "ChebConv" begin |
43 |
| - # k = 3 |
44 |
| - # l = ChebConv(in_channel => out_channel, k) |
45 |
| - # @test size(l.weight) == (out_channel, in_channel, k) |
46 |
| - # @test size(l.bias) == (out_channel,) |
47 |
| - # @test l.k == k |
48 |
| - # for g in test_graphs |
49 |
| - # g = add_self_loops(g) |
50 |
| - # test_layer(l, g, rtol=1e-5, test_gpu=false, outsize=(out_channel, g.num_nodes)) |
51 |
| - # if TEST_GPU |
52 |
| - # @test_broken test_layer(l, g, rtol=1e-5, test_gpu=true, outsize=(out_channel, g.num_nodes)) |
53 |
| - # end |
54 |
| - # end |
| 27 | + @testset "GCNConv" begin |
| 28 | + l = GCNConv(in_channel => out_channel) |
| 29 | + for g in test_graphs |
| 30 | + test_layer(l, g, rtol=1e-5, outsize=(out_channel, g.num_nodes)) |
| 31 | + end |
| 32 | + |
| 33 | + l = GCNConv(in_channel => out_channel, tanh, bias=false) |
| 34 | + for g in test_graphs |
| 35 | + test_layer(l, g, rtol=1e-5, outsize=(out_channel, g.num_nodes)) |
| 36 | + end |
| 37 | + |
| 38 | + l = GCNConv(in_channel => out_channel, add_self_loops=false) |
| 39 | + test_layer(l, g1, rtol=1e-5, outsize=(out_channel, g1.num_nodes)) |
| 40 | + end |
| 41 | + |
| 42 | + @testset "ChebConv" begin |
| 43 | + k = 3 |
| 44 | + l = ChebConv(in_channel => out_channel, k) |
| 45 | + @test size(l.weight) == (out_channel, in_channel, k) |
| 46 | + @test size(l.bias) == (out_channel,) |
| 47 | + @test l.k == k |
| 48 | + for g in test_graphs |
| 49 | + g = add_self_loops(g) |
| 50 | + test_layer(l, g, rtol=1e-5, test_gpu=false, outsize=(out_channel, g.num_nodes)) |
| 51 | + if TEST_GPU |
| 52 | + @test_broken test_layer(l, g, rtol=1e-5, test_gpu=true, outsize=(out_channel, g.num_nodes)) |
| 53 | + end |
| 54 | + end |
55 | 55 |
|
56 |
| - # @testset "bias=false" begin |
57 |
| - # @test length(Flux.params(ChebConv(2=>3, 3))) == 2 |
58 |
| - # @test length(Flux.params(ChebConv(2=>3, 3, bias=false))) == 1 |
59 |
| - # end |
60 |
| - # end |
61 |
| - |
62 |
| - # @testset "GraphConv" begin |
63 |
| - # l = GraphConv(in_channel => out_channel) |
64 |
| - # for g in test_graphs |
65 |
| - # test_layer(l, g, rtol=1e-5, outsize=(out_channel, g.num_nodes)) |
66 |
| - # end |
67 |
| - |
68 |
| - # l = GraphConv(in_channel => out_channel, relu, bias=false, aggr=mean) |
69 |
| - # for g in test_graphs |
70 |
| - # test_layer(l, g, rtol=1e-5, outsize=(out_channel, g.num_nodes)) |
71 |
| - # end |
| 56 | + @testset "bias=false" begin |
| 57 | + @test length(Flux.params(ChebConv(2=>3, 3))) == 2 |
| 58 | + @test length(Flux.params(ChebConv(2=>3, 3, bias=false))) == 1 |
| 59 | + end |
| 60 | + end |
| 61 | + |
| 62 | + @testset "GraphConv" begin |
| 63 | + l = GraphConv(in_channel => out_channel) |
| 64 | + for g in test_graphs |
| 65 | + test_layer(l, g, rtol=1e-5, outsize=(out_channel, g.num_nodes)) |
| 66 | + end |
| 67 | + |
| 68 | + l = GraphConv(in_channel => out_channel, relu, bias=false, aggr=mean) |
| 69 | + for g in test_graphs |
| 70 | + test_layer(l, g, rtol=1e-5, outsize=(out_channel, g.num_nodes)) |
| 71 | + end |
72 | 72 |
|
73 |
| - # @testset "bias=false" begin |
74 |
| - # @test length(Flux.params(GraphConv(2=>3))) == 3 |
75 |
| - # @test length(Flux.params(GraphConv(2=>3, bias=false))) == 2 |
76 |
| - # end |
77 |
| - # end |
78 |
| - |
79 |
| - # @testset "GATConv" begin |
80 |
| - |
81 |
| - # for heads in (1, 2), concat in (true, false) |
82 |
| - # l = GATConv(in_channel => out_channel; heads, concat) |
83 |
| - # for g in test_graphs |
84 |
| - # test_layer(l, g, rtol=1e-4, |
85 |
| - # outsize=(concat ? heads*out_channel : out_channel, g.num_nodes)) |
86 |
| - # end |
87 |
| - # end |
88 |
| - |
89 |
| - # @testset "bias=false" begin |
90 |
| - # @test length(Flux.params(GATConv(2=>3))) == 3 |
91 |
| - # @test length(Flux.params(GATConv(2=>3, bias=false))) == 2 |
92 |
| - # end |
93 |
| - # end |
94 |
| - |
95 |
| - # @testset "GatedGraphConv" begin |
96 |
| - # num_layers = 3 |
97 |
| - # l = GatedGraphConv(out_channel, num_layers) |
98 |
| - # @test size(l.weight) == (out_channel, out_channel, num_layers) |
99 |
| - |
100 |
| - # for g in test_graphs |
101 |
| - # test_layer(l, g, rtol=1e-5, outsize=(out_channel, g.num_nodes)) |
102 |
| - # end |
103 |
| - # end |
104 |
| - |
105 |
| - # @testset "EdgeConv" begin |
106 |
| - # l = EdgeConv(Dense(2*in_channel, out_channel), aggr=+) |
107 |
| - # for g in test_graphs |
108 |
| - # test_layer(l, g, rtol=1e-5, outsize=(out_channel, g.num_nodes)) |
109 |
| - # end |
110 |
| - # end |
111 |
| - |
112 |
| - # @testset "GINConv" begin |
113 |
| - # nn = Dense(in_channel, out_channel) |
114 |
| - # eps = 0.001f0 |
115 |
| - # l = GINConv(nn, eps=eps) |
116 |
| - # for g in test_graphs |
117 |
| - # test_layer(l, g, rtol=1e-5, outsize=(out_channel, g.num_nodes), exclude_grad_fields=[:eps]) |
118 |
| - # end |
| 73 | + @testset "bias=false" begin |
| 74 | + @test length(Flux.params(GraphConv(2=>3))) == 3 |
| 75 | + @test length(Flux.params(GraphConv(2=>3, bias=false))) == 2 |
| 76 | + end |
| 77 | + end |
| 78 | + |
| 79 | + @testset "GATConv" begin |
| 80 | + |
| 81 | + for heads in (1, 2), concat in (true, false) |
| 82 | + l = GATConv(in_channel => out_channel; heads, concat) |
| 83 | + for g in test_graphs |
| 84 | + test_layer(l, g, rtol=1e-4, |
| 85 | + outsize=(concat ? heads*out_channel : out_channel, g.num_nodes)) |
| 86 | + end |
| 87 | + end |
| 88 | + |
| 89 | + @testset "bias=false" begin |
| 90 | + @test length(Flux.params(GATConv(2=>3))) == 3 |
| 91 | + @test length(Flux.params(GATConv(2=>3, bias=false))) == 2 |
| 92 | + end |
| 93 | + end |
| 94 | + |
| 95 | + @testset "GatedGraphConv" begin |
| 96 | + num_layers = 3 |
| 97 | + l = GatedGraphConv(out_channel, num_layers) |
| 98 | + @test size(l.weight) == (out_channel, out_channel, num_layers) |
| 99 | + |
| 100 | + for g in test_graphs |
| 101 | + test_layer(l, g, rtol=1e-5, outsize=(out_channel, g.num_nodes)) |
| 102 | + end |
| 103 | + end |
| 104 | + |
| 105 | + @testset "EdgeConv" begin |
| 106 | + l = EdgeConv(Dense(2*in_channel, out_channel), aggr=+) |
| 107 | + for g in test_graphs |
| 108 | + test_layer(l, g, rtol=1e-5, outsize=(out_channel, g.num_nodes)) |
| 109 | + end |
| 110 | + end |
| 111 | + |
| 112 | + @testset "GINConv" begin |
| 113 | + nn = Dense(in_channel, out_channel) |
| 114 | + eps = 0.001f0 |
| 115 | + l = GINConv(nn, eps=eps) |
| 116 | + for g in test_graphs |
| 117 | + test_layer(l, g, rtol=1e-5, outsize=(out_channel, g.num_nodes), exclude_grad_fields=[:eps]) |
| 118 | + end |
119 | 119 |
|
120 |
| - # @test !in(:eps, Flux.trainable(l)) |
121 |
| - # end |
| 120 | + @test !in(:eps, Flux.trainable(l)) |
| 121 | + end |
122 | 122 |
|
123 |
| - # @testset "NNConv" begin |
124 |
| - # edim = 10 |
125 |
| - # nn = Dense(edim, out_channel * in_channel) |
| 123 | + @testset "NNConv" begin |
| 124 | + edim = 10 |
| 125 | + nn = Dense(edim, out_channel * in_channel) |
126 | 126 |
|
127 |
| - # l = NNConv(in_channel => out_channel, nn) |
128 |
| - # for g in test_graphs |
129 |
| - # g = GNNGraph(g, edata=rand(T, edim, g.num_edges)) |
130 |
| - # test_layer(l, g, rtol=1e-5, outsize=(out_channel, g.num_nodes)) |
131 |
| - # end |
| 127 | + l = NNConv(in_channel => out_channel, nn) |
| 128 | + for g in test_graphs |
| 129 | + g = GNNGraph(g, edata=rand(T, edim, g.num_edges)) |
| 130 | + test_layer(l, g, rtol=1e-5, outsize=(out_channel, g.num_nodes)) |
| 131 | + end |
132 | 132 |
|
133 |
| - # l = NNConv(in_channel => out_channel, nn, tanh, bias=false, aggr=mean) |
134 |
| - # for g in test_graphs |
135 |
| - # g = GNNGraph(g, edata=rand(T, edim, g.num_edges)) |
136 |
| - # test_layer(l, g, rtol=1e-5, outsize=(out_channel, g.num_nodes)) |
137 |
| - # end |
138 |
| - # end |
139 |
| - |
140 |
| - # @testset "SAGEConv" begin |
141 |
| - # l = SAGEConv(in_channel => out_channel) |
142 |
| - # @test l.aggr == mean |
143 |
| - # for g in test_graphs |
144 |
| - # test_layer(l, g, rtol=1e-5, outsize=(out_channel, g.num_nodes)) |
145 |
| - # end |
| 133 | + l = NNConv(in_channel => out_channel, nn, tanh, bias=false, aggr=mean) |
| 134 | + for g in test_graphs |
| 135 | + g = GNNGraph(g, edata=rand(T, edim, g.num_edges)) |
| 136 | + test_layer(l, g, rtol=1e-5, outsize=(out_channel, g.num_nodes)) |
| 137 | + end |
| 138 | + end |
| 139 | + |
| 140 | + @testset "SAGEConv" begin |
| 141 | + l = SAGEConv(in_channel => out_channel) |
| 142 | + @test l.aggr == mean |
| 143 | + for g in test_graphs |
| 144 | + test_layer(l, g, rtol=1e-5, outsize=(out_channel, g.num_nodes)) |
| 145 | + end |
146 | 146 |
|
147 |
| - # l = SAGEConv(in_channel => out_channel, tanh, bias=false, aggr=+) |
148 |
| - # for g in test_graphs |
149 |
| - # test_layer(l, g, rtol=1e-5, outsize=(out_channel, g.num_nodes)) |
150 |
| - # end |
151 |
| - # end |
| 147 | + l = SAGEConv(in_channel => out_channel, tanh, bias=false, aggr=+) |
| 148 | + for g in test_graphs |
| 149 | + test_layer(l, g, rtol=1e-5, outsize=(out_channel, g.num_nodes)) |
| 150 | + end |
| 151 | + end |
152 | 152 |
|
153 | 153 |
|
154 | 154 | @testset "ResGatedGraphConv" begin
|
|
0 commit comments