General#
- ivy.reduce(operand, init_value, computation, /, *, axes=0, keepdims=False)[source]#
Reduces the input array’s dimensions by applying a function along one or more axes.
- Parameters:
operand (
Union
[Array
,NativeArray
]) – The array to act on.init_value (
Union
[int
,float
]) – The value with which to start the reduction.computation (
Callable
) – The reduction function.axes (
Union
[int
,Sequence
[int
]]) – The dimensions along which the reduction is performed. (default:0
)keepdims (
bool
) – If this is set to True, the axes which are reduced are left in the result as (default:False
) dimensions with size one.
- Return type:
- Returns:
ret – The reduced array.
Examples
>>> x = ivy.array([[1, 2, 3], [4, 5, 6]]) >>> ivy.reduce(x, 0, ivy.add, 0) ivy.array([6, 15])
>>> x = ivy.array([[1, 2, 3], [4, 5, 6]]) >>> ivy.reduce(x, 0, ivy.add, 1) ivy.array([5, 7, 9])