You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/padding.jl
+122-3Lines changed: 122 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -23,7 +23,7 @@ If `dims` is not given, it defaults to all dimensions.
23
23
For integer `pad` input, it is applied on both sides
24
24
on every dimension in `dims`.
25
25
26
-
See also [`pad_zeros`](@ref), [`pad_reflect`](@ref)and [`pad_repeat`](@ref).
26
+
See also [`pad_zeros`](@ref), [`pad_repeat`](@ref), [`pad_reflect`](@ref), [`pad_symmetric`](@ref), and [`pad_circular`](@ref).
27
27
28
28
```jldoctest
29
29
julia> r = reshape(1:4, 2, 2)
@@ -174,7 +174,7 @@ on every dimension in `dims`. In this case, `dims`
174
174
defaults to the first `ndims(x)-2` dimensions
175
175
(i.e. excludes the channel and batch dimension).
176
176
177
-
See also [`pad_reflect`](@ref) and [`pad_constant`](@ref).
177
+
See also [`pad_reflect`](@ref), [`pad_symmetric`](@ref), [`pad_circular`](@ref), and [`pad_constant`](@ref).
178
178
179
179
```jldoctest
180
180
julia> r = reshape(1:9, 3, 3)
@@ -235,7 +235,7 @@ on every dimension in `dims`. In this case, `dims`
235
235
defaults to the first `ndims(x)-2` dimensions
236
236
(i.e. excludes the channel and batch dimension).
237
237
238
-
See also [`pad_repeat`](@ref) and [`pad_constant`](@ref).
238
+
See also [`pad_repeat`](@ref), [`pad_symmetric`](@ref), [`pad_circular`](@ref), and [`pad_constant`](@ref).
239
239
240
240
```jldoctest
241
241
julia> r = reshape(1:9, 3, 3)
@@ -277,8 +277,127 @@ function pad_reflect(x::AbstractArray{F,N}, pad::NTuple{2,Int};
277
277
returncat(xl, x, xr, dims = dims)
278
278
end
279
279
280
+
"""
281
+
pad_symmetric(x, pad::Tuple; [dims])
282
+
pad_symmetric(x, pad::Int; [dims])
283
+
284
+
Pad the array `x` reflecting its values symmetrically across the border, i.e. the border values of `x` are present in the padding values, in contrast to [`pad_reflect`](@ref).
285
+
286
+
`pad` can a tuple of integers `(l1, r1, ..., ln, rn)`
287
+
of some length `2n` that specifies the left and right padding size
288
+
for each of the dimensions in `dims`. If `dims` is not given,
289
+
it defaults to the first `n` dimensions.
290
+
291
+
For integer `pad` input instead, it is applied on both sides
292
+
on every dimension in `dims`. In this case, `dims`
293
+
defaults to the first `ndims(x)-2` dimensions
294
+
(i.e. excludes the channel and batch dimension).
295
+
296
+
See also [`pad_repeat`](@ref), [`pad_reflect`](@ref), [`pad_circular`](@ref), and [`pad_constant`](@ref).
297
+
298
+
```jldoctest
299
+
julia> r = reshape(1:9, 3, 3)
300
+
3×3 reshape(::UnitRange{Int64}, 3, 3) with eltype Int64:
0 commit comments