Skip to content

Commit 8b189d0

Browse files
committed
Add doctests in upsample.jl
1 parent 0b01b77 commit 8b189d0

File tree

1 file changed

+33
-1
lines changed

1 file changed

+33
-1
lines changed

src/layers/upsample.jl

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,41 @@ end
7575
"""
7676
PixelShuffle(r::Int)
7777
78-
Pixel shuffling layer with upscale factor `r`.
78+
Pixel shuffling layer with upscale factor `r`. Usually used for generating higher
79+
resolution images while upscaling them.
7980
8081
See [`NNlib.pixel_shuffle`](@ref).
82+
83+
# Examples
84+
```jldoctest; filter = r"[+-]?([0-9]*[.])?[0-9]+"
85+
julia> p = PixelShuffle(2);
86+
87+
julia> xs = rand(2, 2, 4, 1) # an image with 4 channels having 2X2 pixels in each channel
88+
2×2×4×1 Array{Float64, 4}:
89+
[:, :, 1, 1] =
90+
0.826452 0.0519244
91+
0.0686387 0.438346
92+
93+
[:, :, 2, 1] =
94+
0.343179 0.445101
95+
0.543927 0.740905
96+
97+
[:, :, 3, 1] =
98+
0.105997 0.422996
99+
0.32957 0.167205
100+
101+
[:, :, 4, 1] =
102+
0.825737 0.98609
103+
0.757365 0.294784
104+
105+
julia> p(xs) # an image with only 1 channel with 4X4 pixels in the single channel
106+
4×4×1×1 Array{Float64, 4}:
107+
[:, :, 1, 1] =
108+
0.826452 0.105997 0.0519244 0.422996
109+
0.343179 0.825737 0.445101 0.98609
110+
0.0686387 0.32957 0.438346 0.167205
111+
0.543927 0.757365 0.740905 0.294784
112+
```
81113
"""
82114
struct PixelShuffle
83115
r::Int

0 commit comments

Comments
 (0)