Skip to content

Commit 2bac906

Browse files
committed
More examples for SamePad
1 parent 6ab72bd commit 2bac906

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

src/layers/conv.jl

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,25 @@ See also [`Conv`](@ref), [`MaxPool`](@ref).
2222
2323
# Examples
2424
```jldoctest
25-
julia> Conv((2,2), 1 => 1, pad=SamePad())
26-
Conv((2, 2), 1 => 1, pad=(1, 0, 1, 0)) # 5 parameters
25+
julia> xs = rand(Float32, 100, 100, 3, 50); # a batch of image
26+
27+
julia> layer = Conv((2,2), 3 => 7, pad=SamePad())
28+
Conv((2, 2), 3 => 7, pad=(1, 0, 1, 0)) # 91 parameters
29+
30+
julia> layer(xs) |> size # notice how the dimensions would stay same as "same" padding is applied
31+
(100, 100, 7, 50)
32+
33+
julia> layer2 = Conv((2,2), 3 => 7)
34+
Conv((2, 2), 3 => 7) # 91 parameters
35+
36+
julia> layer2(xs) |> size # the output dimension changes as the padding was not "same"
37+
(99, 99, 7, 50)
38+
39+
julia> layer3 = Conv((2,2), 3 => 7, stride=2, pad=SamePad())
40+
Conv((2, 2), 3 => 7, pad=(1, 0, 1, 0), stride=2) # 91 parameters
41+
42+
julia> layer3(xs) |> size # output size = `ceil(input_size/stride)` = 50
43+
(50, 50, 7, 50)
2744
```
2845
"""
2946
struct SamePad end

0 commit comments

Comments
 (0)