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
+125-6Lines changed: 125 additions & 6 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)
@@ -169,12 +169,12 @@ of some length `2n` that specifies the left and right padding size
169
169
for each of the dimensions in `dims`. If `dims` is not given,
170
170
it defaults to the first `n` dimensions.
171
171
172
-
For integer `pad` input instead, it is applied on both sides
172
+
If `pad` is an integer, it is applied on both sides
173
173
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)
@@ -230,12 +230,12 @@ of some length `2n` that specifies the left and right padding size
230
230
for each of the dimensions in `dims`. If `dims` is not given,
231
231
it defaults to the first `n` dimensions.
232
232
233
-
For integer `pad` input instead, it is applied on both sides
233
+
If `pad` is an integer, it is applied on both sides
234
234
on every dimension in `dims`. In this case, `dims`
235
235
defaults to the first `ndims(x)-2` dimensions
236
-
(i.e. excludes the channel and batch dimension).
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
+
If `pad` is an integer, 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