diff --git a/GNNLux/src/layers/conv.jl b/GNNLux/src/layers/conv.jl index 7acc31e57..c5720ee7a 100644 --- a/GNNLux/src/layers/conv.jl +++ b/GNNLux/src/layers/conv.jl @@ -936,8 +936,10 @@ end function Base.show(io::IO, l::GATConv) (in, ein), out = l.channel - print(io, "GATConv(", ein == 0 ? in : (in, ein), " => ", out ÷ l.heads) + print(io, "GATConv(", ein == 0 ? in : (in, ein), " => ", out) l.σ == identity || print(io, ", ", l.σ) + l.heads == 1 || print(io, ", heads=", l.heads) + l.concat || print(io, ", concat=", l.concat) print(io, ", negative_slope=", l.negative_slope) print(io, ")") end @@ -1094,8 +1096,10 @@ end function Base.show(io::IO, l::GATv2Conv) (in, ein), out = l.channel - print(io, "GATv2Conv(", ein == 0 ? in : (in, ein), " => ", out ÷ l.heads) + print(io, "GATv2Conv(", ein == 0 ? in : (in, ein), " => ", out) l.σ == identity || print(io, ", ", l.σ) + l.heads == 1 || print(io, ", heads=", l.heads) + l.concat || print(io, ", concat=", l.concat) print(io, ", negative_slope=", l.negative_slope) print(io, ")") end diff --git a/GNNLux/test/layers/conv.jl b/GNNLux/test/layers/conv.jl index 972c9e372..6fc1898bc 100644 --- a/GNNLux/test/layers/conv.jl +++ b/GNNLux/test/layers/conv.jl @@ -16,6 +16,32 @@ @test all(isone, ps.dense_e.weight) end +@testitem "GATConv show" setup=[TestModuleLux] begin + using .TestModuleLux + + @test sprint(show, GATConv(6 => 8)) == + "GATConv(6 => 8, negative_slope=0.2)" + @test sprint(show, GATConv(6 => 8; heads = 2)) == + "GATConv(6 => 8, heads=2, negative_slope=0.2)" + @test sprint(show, GATConv(6 => 8; concat = false)) == + "GATConv(6 => 8, concat=false, negative_slope=0.2)" + @test sprint(show, GATConv(6 => 8; heads = 2, concat = false)) == + "GATConv(6 => 8, heads=2, concat=false, negative_slope=0.2)" +end + +@testitem "GATv2Conv show" setup=[TestModuleLux] begin + using .TestModuleLux + + @test sprint(show, GATv2Conv(6 => 8)) == + "GATv2Conv(6 => 8, negative_slope=0.2)" + @test sprint(show, GATv2Conv(6 => 8; heads = 2)) == + "GATv2Conv(6 => 8, heads=2, negative_slope=0.2)" + @test sprint(show, GATv2Conv(6 => 8; concat = false)) == + "GATv2Conv(6 => 8, concat=false, negative_slope=0.2)" + @test sprint(show, GATv2Conv(6 => 8; heads = 2, concat = false)) == + "GATv2Conv(6 => 8, heads=2, concat=false, negative_slope=0.2)" +end + @testitem "layers/conv" setup=[TestModuleLux] begin using .TestModuleLux diff --git a/GraphNeuralNetworks/src/layers/conv.jl b/GraphNeuralNetworks/src/layers/conv.jl index 7e5d190e5..4411b75db 100644 --- a/GraphNeuralNetworks/src/layers/conv.jl +++ b/GraphNeuralNetworks/src/layers/conv.jl @@ -347,8 +347,10 @@ end function Base.show(io::IO, l::GATConv) (in, ein), out = l.channel - print(io, "GATConv(", ein == 0 ? in : (in, ein), " => ", out ÷ l.heads) + print(io, "GATConv(", ein == 0 ? in : (in, ein), " => ", out) l.σ == identity || print(io, ", ", l.σ) + l.heads == 1 || print(io, ", heads=", l.heads) + l.concat || print(io, ", concat=", l.concat) print(io, ", negative_slope=", l.negative_slope) print(io, ")") end @@ -467,8 +469,10 @@ end function Base.show(io::IO, l::GATv2Conv) (in, ein), out = l.channel - print(io, "GATv2Conv(", ein == 0 ? in : (in, ein), " => ", out ÷ l.heads) + print(io, "GATv2Conv(", ein == 0 ? in : (in, ein), " => ", out) l.σ == identity || print(io, ", ", l.σ) + l.heads == 1 || print(io, ", heads=", l.heads) + l.concat || print(io, ", concat=", l.concat) print(io, ", negative_slope=", l.negative_slope) print(io, ")") end diff --git a/GraphNeuralNetworks/test/layers/conv.jl b/GraphNeuralNetworks/test/layers/conv.jl index c09fb70ba..10450f443 100644 --- a/GraphNeuralNetworks/test/layers/conv.jl +++ b/GraphNeuralNetworks/test/layers/conv.jl @@ -172,6 +172,19 @@ end end +@testitem "GATConv show" setup=[TestModule] begin + using .TestModule + + @test sprint(show, GATConv(6 => 8)) == + "GATConv(6 => 8, negative_slope=0.2)" + @test sprint(show, GATConv(6 => 8; heads = 2)) == + "GATConv(6 => 8, heads=2, negative_slope=0.2)" + @test sprint(show, GATConv(6 => 8; concat = false)) == + "GATConv(6 => 8, concat=false, negative_slope=0.2)" + @test sprint(show, GATConv(6 => 8; heads = 2, concat = false)) == + "GATConv(6 => 8, heads=2, concat=false, negative_slope=0.2)" +end + @testitem "GATConv" setup=[TolSnippet, TestModule] begin using .TestModule for heads in (1, 2), concat in (true, false) @@ -219,6 +232,19 @@ end end end +@testitem "GATv2Conv show" setup=[TestModule] begin + using .TestModule + + @test sprint(show, GATv2Conv(6 => 8)) == + "GATv2Conv(6 => 8, negative_slope=0.2)" + @test sprint(show, GATv2Conv(6 => 8; heads = 2)) == + "GATv2Conv(6 => 8, heads=2, negative_slope=0.2)" + @test sprint(show, GATv2Conv(6 => 8; concat = false)) == + "GATv2Conv(6 => 8, concat=false, negative_slope=0.2)" + @test sprint(show, GATv2Conv(6 => 8; heads = 2, concat = false)) == + "GATv2Conv(6 => 8, heads=2, concat=false, negative_slope=0.2)" +end + @testitem "GATv2Conv" setup=[TolSnippet, TestModule] begin using .TestModule for heads in (1, 2), concat in (true, false)