Reductions¶
Collection of reduction Ivy functions

ivy.
einsum
(equation, *operands, f=None)[source]¶ Sums the product of the elements of the input operands along dimensions specified using a notation based on the Einstein summation convention.
 Parameters
equation (str) – A str describing the contraction, in the same format as numpy.einsum.
operands (seq of arrays) – the inputs to contract (each one an ivy.Array), whose shapes should be consistent with equation.
f (ml_framework, optional) – Machine learning framework. Inferred from inputs if None.
 Returns
The array with sums computed.

ivy.
reduce_max
(x, axis=None, keepdims=False, f=None)[source]¶ Computes the maximum value along the specified axis. The maximum is taken over the flattened array by default, otherwise over the specified axis.
 Parameters
x (array) – Array containing numbers whose max is desired.
axis (int or sequence of ints) – Axis or axes along which the maxes are computed. The default is to compute the max of the flattened array. If this is a tuple of ints, a max is performed over multiple axes, instead of a single axis or all the axes as before.
keepdims (bool, optional) – If this is set to True, the axes which are reduced are left in the result as dimensions with size one. With this option, the result will broadcast correctly against the input array.
f (ml_framework, optional) – Machine learning framework. Inferred from inputs if None.
 Returns
The array with maxes computed.

ivy.
reduce_mean
(x, axis=None, keepdims=False, f=None)[source]¶ Computes the arithmetic mean along a given axis. Returns the average of the array elements. The average is taken over the flattened array by default, otherwise over the specified axis.
 Parameters
x (array) – Array containing numbers whose mean is desired.
axis (int or sequence of ints) – Axis or axes along which the means are computed. The default is to compute the mean of the flattened array. If this is a tuple of ints, a mean is performed over multiple axes, instead of a single axis or all the axes as before.
keepdims (bool, optional) – If this is set to True, the axes which are reduced are left in the result as dimensions with size one. With this option, the result will broadcast correctly against the input array.
f (ml_framework, optional) – Machine learning framework. Inferred from inputs if None.
 Returns
The array with means computed.

ivy.
reduce_min
(x, axis=None, keepdims=False, f=None)[source]¶ Computes the minimum value along the specified axis. The minimum is taken over the flattened array by default, otherwise over the specified axis.
 Parameters
x (array) – Array containing numbers whose min is desired.
axis (int or sequence of ints) – Axis or axes along which the mins are computed. The default is to compute the min of the flattened array. If this is a tuple of ints, a min is performed over multiple axes, instead of a single axis or all the axes as before.
keepdims (bool, optional) – If this is set to True, the axes which are reduced are left in the result as dimensions with size one. With this option, the result will broadcast correctly against the input array.
f (ml_framework, optional) – Machine learning framework. Inferred from inputs if None.
 Returns
The array with mins computed.

ivy.
reduce_prod
(x, axis=None, keepdims=False, f=None)[source]¶ Multiplies array elements along a given axis.
 Parameters
x (array) – Elements to multiply.
axis (int or sequence of ints) – Axis or axes along which a multiplication is performed. The default, axis=None, will multiply all of the elements of the input array. If axis is negative it counts from the last to the first axis. If axis is a tuple of ints, a multiplication is performed on all of the axes specified in the tuple instead of a single axis or all the axes as before.
keepdims (bool, optional) – If this is set to True, the axes which are reduced are left in the result as dimensions with size one. With this option, the result will broadcast correctly against the input array.
f (ml_framework, optional) – Machine learning framework. Inferred from inputs if None.
 Returns
The array with multiplications computed.

ivy.
reduce_std
(x, axis=None, keepdims=False, f=None)[source]¶ Computes the arithmetic standard deviation along a given axis. The standard deviation is taken over the flattened array by default, otherwise over the specified axis.
 Parameters
x (array) – Array containing numbers whose standard deviation is desired.
axis (int or sequence of ints) – Axis or axes along which the means are computed. The default is to compute the mean of the flattened array. If this is a tuple of ints, a mean is performed over multiple axes, instead of a single axis or all the axes as before.
keepdims (bool, optional) – If this is set to True, the axes which are reduced are left in the result as dimensions with size one. With this option, the result will broadcast correctly against the input array.
f (ml_framework, optional) – Machine learning framework. Inferred from inputs if None.
 Returns
The array with standard deviations computed.

ivy.
reduce_sum
(x, axis=None, keepdims=False, f=None)[source]¶ Computes sum of array elements along a given axis.
 Parameters
x (array) – Elements to sum.
axis (int or sequence of ints) – Axis or axes along which a sum is performed. The default, axis=None, will sum all of the elements of the input array. If axis is negative it counts from the last to the first axis. If axis is a tuple of ints, a sum is performed on all of the axes specified in the tuple instead of a single axis or all the axes as before.
keepdims (bool, optional) – If this is set to True, the axes which are reduced are left in the result as dimensions with size one. With this option, the result will broadcast correctly against the input array.
f (ml_framework, optional) – Machine learning framework. Inferred from inputs if None.
 Returns
The array with sums computed.

ivy.
reduce_var
(x, axis=None, keepdims=False, f=None)[source]¶ Computes the arithmetic variance along a given axis. The variance is taken over the flattened array by default, otherwise over the specified axis.
 Parameters
x (array) – Array containing numbers whose variance is desired.
axis (int or sequence of ints) – Axis or axes along which the means are computed. The default is to compute the mean of the flattened array. If this is a tuple of ints, a mean is performed over multiple axes, instead of a single axis or all the axes as before.
keepdims (bool, optional) – If this is set to True, the axes which are reduced are left in the result as dimensions with size one. With this option, the result will broadcast correctly against the input array.
f (ml_framework, optional) – Machine learning framework. Inferred from inputs if None.
 Returns
The array with variances computed.