|
| 1 | +@testset "upsample bilinear" begin |
| 2 | + m = Upsample(:bilinear, scale=(2, 3)) |
| 3 | + x = rand(Float32, 3, 4, 2, 3) |
| 4 | + y = m(x) |
| 5 | + @test y isa Array{Float32, 4} |
| 6 | + @test size(y) == (6, 12, 2, 3) |
| 7 | + |
| 8 | + m = Upsample(:bilinear, scale=3) |
| 9 | + x = rand(Float32, 3, 4, 2, 3) |
| 10 | + y = m(x) |
| 11 | + @test y isa Array{Float32, 4} |
| 12 | + @test size(y) == (9, 12, 2, 3) |
| 13 | + |
| 14 | + m = Upsample(:bilinear, size=(4, 6)) |
| 15 | + x = rand(Float32, 3, 4, 2, 3) |
| 16 | + y = m(x) |
| 17 | + @test y isa Array{Float32, 4} |
| 18 | + @test size(y) == (4, 6, 2, 3) |
| 19 | +end |
| 20 | + |
| 21 | +@testset "upsample nearest" begin |
| 22 | + x = rand(Float32, 3, 2, 3) |
| 23 | + m = Upsample(:nearest, scale=(2,)) |
| 24 | + y = m(x) |
| 25 | + @test y isa Array{Float32, 3} |
| 26 | + @test size(y) == (6, 2, 3) |
| 27 | + |
| 28 | + x = rand(Float32, 3, 4, 2, 3) |
| 29 | + |
| 30 | + m = Upsample(:nearest, scale=(2, 3)) |
| 31 | + y = m(x) |
| 32 | + @test y isa Array{Float32, 4} |
| 33 | + @test size(y) == (6, 12, 2, 3) |
| 34 | + |
| 35 | + m = Upsample(:nearest, scale=(2,)) |
| 36 | + y = m(x) |
| 37 | + @test y isa Array{Float32, 4} |
| 38 | + @test size(y) == (6, 4, 2, 3) |
| 39 | + |
| 40 | + m = Upsample(:nearest, scale=2) |
| 41 | + y = m(x) |
| 42 | + @test y isa Array{Float32, 4} |
| 43 | + @test size(y) == (6, 8, 2, 3) |
| 44 | + |
| 45 | + m = Upsample(2) |
| 46 | + y2 = m(x) |
| 47 | + @test y2 ≈ y |
| 48 | + |
| 49 | + m = Upsample(:nearest, size=(6,8)) |
| 50 | + y = m(x) |
| 51 | + @test y isa Array{Float32, 4} |
| 52 | + @test size(y) == (6, 8, 2, 3) |
| 53 | +end |
| 54 | + |
| 55 | +@testset "PixelShuffle" begin |
| 56 | + m = PixelShuffle(2) |
| 57 | + x = rand(Float32, 3, 18, 3) |
| 58 | + y = m(x) |
| 59 | + @test y isa Array{Float32, 3} |
| 60 | + @test size(y) == (6, 9, 3) |
| 61 | + |
| 62 | + m = PixelShuffle(3) |
| 63 | + x = rand(Float32, 3, 4, 18, 3) |
| 64 | + y = m(x) |
| 65 | + @test y isa Array{Float32, 4} |
| 66 | + @test size(y) == (9, 12, 2, 3) |
| 67 | +end |
0 commit comments