sliding_window#
- ivy.sliding_window(input, kernel_size, /, *, stride=1, dilation=1, padding='VALID')[source]#
Slide a window of specified dimension over all elements of an array.
- Parameters:
input (
Union
[Array
,NativeArray
]) – An array representing the base area on which the window is going to slide over.window_size – Size of the sliding window for each dimension of the input.
stride (
Union
[int
,Tuple
[int
,int
]], default:1
) – The stride of the sliding window for each dimension of inputpadding (
Union
[str
,int
,Tuple
[int
,int
]], default:'VALID'
) – Either the string ‘SAME’ (padding with zeros evenly), the string ‘VALID’ (no padding), or a sequence of n (low, high) integer pairs that give the padding to apply before and after each spatial dimension.dilation (
Union
[int
,Tuple
[int
,int
]], default:1
) – The stride between elements within a sliding window, must be > 0.
- Return type:
- Returns:
ret – The result of the sliding window operation.
Examples
>>> x = ivy.array([[1, 2, 3, 4], >>> [5, 6, 7, 8], >>> [9, 10, 11, 12]]) >>> ivy.sliding_window(x, (2, 2)) ivy.array([[[ 1, 2, 5, 6], [ 2, 3, 6, 7], [ 3, 4, 7, 8]],
[[ 5, 6, 9, 10], [ 6, 7, 10, 11], [ 7, 8, 11, 12]]])
- Array.sliding_window(self, window_size, /, *, stride=1, dilation=1, padding='VALID')[source]#
Slide a window of specified dimension over all elements of an array.
- Parameters:
input – An array representing the base area on which the window is going to slide over.
window_size (
Union
[int
,Tuple
[int
,int
],Tuple
[int
,int
,int
]]) – Size of the sliding window for each dimension of the input.stride (
Union
[int
,Tuple
[int
,int
]], default:1
) – The stride of the sliding window for each dimension of inputpadding (
Union
[str
,int
,Sequence
[Tuple
[int
,int
]]], default:'VALID'
) – Either the string ‘SAME’ (padding with zeros evenly), the string ‘VALID’ (no padding), or a sequence of n (low, high) integer pairs that give the padding to apply before and after each spatial dimension.dilation (
Union
[int
,Tuple
[int
,int
]], default:1
) – The stride between elements within a sliding window, must be > 0.
- Return type:
Array
- Returns:
ret – The result of the sliding window operation.
Examples
>>> x = ivy.array([[1, 2, 3, 4], >>> [5, 6, 7, 8], >>> [9, 10, 11, 12]]) >>> x.sliding_window((2, 2)) ivy.array([[[ 1, 2, 5, 6], [ 2, 3, 6, 7], [ 3, 4, 7, 8]],
[[ 5, 6, 9, 10], [ 6, 7, 10, 11], [ 7, 8, 11, 12]]])
- Container.sliding_window(self, window_size, /, *, stride=1, dilation=1, padding='VALID', key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False)[source]#
ivy.Container instance method variant of ivy.sliding_window. This method simply wraps the function, and so the docstring for ivy.sliding_window also applies to this method with minimal changes.
- Parameters:
input – An array representing the base area on which the window is going to slide over.
window_size (
Union
[int
,Tuple
[int
,int
],Tuple
[int
,int
,int
],Container
]) – Size of the sliding window for each dimension of the input.stride (
Union
[int
,Tuple
[int
,int
],Container
], default:1
) – The stride of the sliding window for each dimension of inputpadding (
Union
[str
,int
,Sequence
[Tuple
[int
,int
]],Container
], default:'VALID'
) – Either the string ‘SAME’ (padding with zeros evenly), the string ‘VALID’ (no padding), or a sequence of n (low, high) integer pairs that give the padding to apply before and after each spatial dimension.dilation (
Union
[int
,Tuple
[int
,int
],Container
], default:1
) – The stride between elements within a sliding window, must be > 0.
- Return type:
Container
- Returns:
ret – The result of the sliding window operation.
Examples
>>> x = ivy.Container( ... a=ivy.array([[1, 2, 3, 4], ... [5, 6, 7, 8], ... [9, 10, 11, 12]]), ... b=ivy.array([[13, 14, 15, 16], ... [17, 18, 19, 20], ... [21, 22, 23, 24]]) ... ) >>> x.sliding_window((2, 2)) { a: ivy.array([[[ 1, 2, 5, 6], [ 2, 3, 6, 7], [ 3, 4, 7, 8]], [[ 5, 6, 9, 10], [ 6, 7, 10, 11], [ 7, 8, 11, 12]]]), b: ivy.array([[[13, 14, 17, 18], [14, 15, 18, 19], [15, 16, 19, 20]], [[17, 18, 21, 22], [18, 19, 22, 23], [19, 20, 23, 24]]]) }