|
51 | 51 | @test size(g.bias) == size(cc.bias) |
52 | 52 | end |
53 | 53 |
|
54 | | - # @testset "GraphConv" begin |
55 | | - # gc = GraphConv(fg, in_channel=>out_channel) |> gpu |
56 | | - # @test size(gc.weight1) == (out_channel, in_channel) |
57 | | - # @test size(gc.weight2) == (out_channel, in_channel) |
58 | | - # @test size(gc.bias) == (out_channel,) |
59 | | - |
60 | | - # X = rand(in_channel, N) |> gpu |
61 | | - # Y = gc(X) |
62 | | - # @test size(Y) == (out_channel, N) |
63 | | - |
64 | | - # g = Zygote.gradient(x -> sum(gc(x)), X)[1] |
65 | | - # @test size(g) == size(X) |
66 | | - |
67 | | - # g = Zygote.gradient(model -> sum(model(X)), gc)[1] |
68 | | - # @test size(g.weight1) == size(gc.weight1) |
69 | | - # @test size(g.weight2) == size(gc.weight2) |
70 | | - # @test size(g.bias) == size(gc.bias) |
71 | | - # end |
72 | | - |
73 | | - # @testset "GATConv" begin |
74 | | - # gat = GATConv(fg, in_channel=>out_channel) |> gpu |
75 | | - # @test size(gat.weight) == (out_channel, in_channel) |
76 | | - # @test size(gat.bias) == (out_channel,) |
77 | | - |
78 | | - # X = rand(in_channel, N) |> gpu |
79 | | - # Y = gat(X) |
80 | | - # @test size(Y) == (out_channel, N) |
81 | | - |
82 | | - # g = Zygote.gradient(x -> sum(gat(x)), X)[1] |
83 | | - # @test size(g) == size(X) |
84 | | - |
85 | | - # g = Zygote.gradient(model -> sum(model(X)), gat)[1] |
86 | | - # @test size(g.weight) == size(gat.weight) |
87 | | - # @test size(g.bias) == size(gat.bias) |
88 | | - # @test size(g.a) == size(gat.a) |
89 | | - # end |
90 | | - |
91 | | - # @testset "GatedGraphConv" begin |
92 | | - # num_layers = 3 |
93 | | - # ggc = GatedGraphConv(fg, out_channel, num_layers) |> gpu |
94 | | - # @test size(ggc.weight) == (out_channel, out_channel, num_layers) |
95 | | - |
96 | | - # X = rand(in_channel, N) |> gpu |
97 | | - # Y = ggc(X) |
98 | | - # @test size(Y) == (out_channel, N) |
99 | | - |
100 | | - # g = Zygote.gradient(x -> sum(ggc(x)), X)[1] |
101 | | - # @test size(g) == size(X) |
102 | | - |
103 | | - # g = Zygote.gradient(model -> sum(model(X)), ggc)[1] |
104 | | - # @test size(g.weight) == size(ggc.weight) |
105 | | - # end |
106 | | - |
107 | | - # @testset "EdgeConv" begin |
108 | | - # ec = EdgeConv(fg, Dense(2*in_channel, out_channel)) |> gpu |
109 | | - # X = rand(in_channel, N) |> gpu |
110 | | - # Y = ec(X) |
111 | | - # @test size(Y) == (out_channel, N) |
112 | | - |
113 | | - # g = Zygote.gradient(x -> sum(ec(x)), X)[1] |
114 | | - # @test size(g) == size(X) |
115 | | - |
116 | | - # g = Zygote.gradient(model -> sum(model(X)), ec)[1] |
117 | | - # @test size(g.nn.weight) == size(ec.nn.weight) |
118 | | - # @test size(g.nn.bias) == size(ec.nn.bias) |
119 | | - # end |
| 54 | + @testset "GraphConv" begin |
| 55 | + gc = GraphConv(fg, in_channel=>out_channel) |> gpu |
| 56 | + @test size(gc.weight1) == (out_channel, in_channel) |
| 57 | + @test size(gc.weight2) == (out_channel, in_channel) |
| 58 | + @test size(gc.bias) == (out_channel,) |
| 59 | + |
| 60 | + X = rand(in_channel, N) |> gpu |
| 61 | + Y = gc(X) |
| 62 | + @test size(Y) == (out_channel, N) |
| 63 | + |
| 64 | + g = Zygote.gradient(x -> sum(gc(x)), X)[1] |
| 65 | + @test size(g) == size(X) |
| 66 | + |
| 67 | + g = Zygote.gradient(model -> sum(model(X)), gc)[1] |
| 68 | + @test size(g.weight1) == size(gc.weight1) |
| 69 | + @test size(g.weight2) == size(gc.weight2) |
| 70 | + @test size(g.bias) == size(gc.bias) |
| 71 | + end |
| 72 | + |
| 73 | + @testset "GATConv" begin |
| 74 | + adj = T[1 1 0 1; |
| 75 | + 1 1 1 0; |
| 76 | + 0 1 1 1; |
| 77 | + 1 0 1 1] |
| 78 | + |
| 79 | + fg = FeaturedGraph(adj) |
| 80 | + |
| 81 | + gat = GATConv(fg, in_channel=>out_channel) |> gpu |
| 82 | + @test size(gat.weight) == (out_channel, in_channel) |
| 83 | + @test size(gat.bias) == (out_channel,) |
| 84 | + |
| 85 | + X = rand(in_channel, N) |> gpu |
| 86 | + Y = gat(X) |
| 87 | + @test size(Y) == (out_channel, N) |
| 88 | + |
| 89 | + g = Zygote.gradient(x -> sum(gat(x)), X)[1] |
| 90 | + @test size(g) == size(X) |
| 91 | + |
| 92 | + g = Zygote.gradient(model -> sum(model(X)), gat)[1] |
| 93 | + @test size(g.weight) == size(gat.weight) |
| 94 | + @test size(g.bias) == size(gat.bias) |
| 95 | + @test size(g.a) == size(gat.a) |
| 96 | + end |
| 97 | + |
| 98 | + @testset "GatedGraphConv" begin |
| 99 | + num_layers = 3 |
| 100 | + ggc = GatedGraphConv(fg, out_channel, num_layers) |> gpu |
| 101 | + @test size(ggc.weight) == (out_channel, out_channel, num_layers) |
| 102 | + |
| 103 | + X = rand(in_channel, N) |> gpu |
| 104 | + Y = ggc(X) |
| 105 | + @test size(Y) == (out_channel, N) |
| 106 | + |
| 107 | + g = Zygote.gradient(x -> sum(ggc(x)), X)[1] |
| 108 | + @test size(g) == size(X) |
| 109 | + |
| 110 | + g = Zygote.gradient(model -> sum(model(X)), ggc)[1] |
| 111 | + @test size(g.weight) == size(ggc.weight) |
| 112 | + end |
| 113 | + |
| 114 | + @testset "EdgeConv" begin |
| 115 | + ec = EdgeConv(fg, Dense(2*in_channel, out_channel)) |> gpu |
| 116 | + X = rand(in_channel, N) |> gpu |
| 117 | + Y = ec(X) |
| 118 | + @test size(Y) == (out_channel, N) |
| 119 | + |
| 120 | + g = Zygote.gradient(x -> sum(ec(x)), X)[1] |
| 121 | + @test size(g) == size(X) |
| 122 | + |
| 123 | + g = Zygote.gradient(model -> sum(model(X)), ec)[1] |
| 124 | + @test size(g.nn.weight) == size(ec.nn.weight) |
| 125 | + @test size(g.nn.bias) == size(ec.nn.bias) |
| 126 | + end |
120 | 127 | end |
0 commit comments