Reduction Operations
Reduce ops take an array as input, perform reduction operations along specified axes, and return a new array. All reduce ops work on real valued as well as complex valued arrays.
reduce_add
def reduce_add(arg0: Array, axis: List[Int]) -> Array
Reduces the input array along the specified axis by summing the elements.
Args
arg0: The input array. axis: The axis along which to reduce the array.
Returns
An array containing the sum of the input array along the specified axis.
Note
This function supports:
- Automatic differentiation (forward and reverse modes).
- Complex valued arguments.
Example
a = Array([[1, 2], [3, 4]])
result = reduce_add(a, List(0))
print(result)
sum
def sum(arg0: Array) -> Array
Computes the sum of the input array along all axes.
mean
def mean(arg0: Array, axes: List[Int], keepdims: Bool = False) -> Array
Computes the mean of the input array along the specified axes.
Args
arg0: The input array. axes: The axes along which to compute the mean. keepdims: If True, the reduced axes are retained in the output array.
Returns
An array containing the mean of the input array along the specified axes.
Note
This function supports:
- Automatic differentiation (forward and reverse modes).
- Complex valued arguments.
Example
a = Array([[1, 2], [3, 4]])
result = mean(a, List(0), keepdims=True)
print(result)
variance
def variance(arg0: Array, axes: List[Int], unbiased: Bool = True, keepdims: Bool = False) -> Array
Computes the variance of the input array along the specified axes.
Args
arg0: The input array. axes: The axes along which to compute the mean. unbiased: If True, the variance is computed using the unbiased estimator. keepdims: If True, the reduced axes are retained in the output array.
Returns
An array containing the variance of the input array along the specified axes.
Note
This function supports:
- Automatic differentiation (forward and reverse modes).
- Complex valued arguments.
Example
a = Array([[1, 2], [3, 4]])
result = variance(a, List(0), unbiased=True, keepdims=True)
print(result)
std
def std(arg0: Array, axes: List[Int], unbiased: Bool = True, keepdims: Bool = False) -> Array
Computes the standard deviation of the input array along the specified axes.
Args
arg0: The input array. axes: The axes along which to compute the mean. unbiased: If True, the standard deviation is computed using the unbiased estimator. keepdims: If True, the reduced axes are retained in the output array.
Returns
An array containing the standard deviation of the input array along the specified axes.
Note
This function supports:
- Automatic differentiation (forward and reverse modes).
- Complex valued arguments.
reduce_min
def reduce_min(arg0: Array, axes: List[Int], keepdims: Bool = False) -> Array
Computes the minimum of the input array along the specified axes.
Args
arg0: The input array. axes: The axes along which to compute the minimum. keepdims: If True, the reduced axes are retained in the output array.
Returns
An array containing the minimum of the input array along the specified axes.
Note
This function supports:
- Complex valued arguments.
Example
a = Array([[1, 2], [3, 4]])
result = reduce_min(a, List(0), keepdims=True)
print(result)
reduce_argmin
def reduce_argmin(arg0: Array, axes: List[Int]) -> Array
Computes the indices of the minimum values along the specified axes.
Args
arg0: The input array. axes: The axes along which to compute the indices of the minimum values.
Returns
An array containing the indices of the minimum values along the specified axes.
Note
This function supports:
- Complex valued arguments.
Example
a = Array([[1, 2], [3, 4]])
result = reduce_argmin(a, List(0))
print(result)
reduce_max
def reduce_max(arg0: Array, axes: List[Int], keepdims: Bool = False) -> Array
Computes the maximum of the input array along the specified axes.
Args
arg0: The input array. axes: The axes along which to compute the maximum. keepdims: If True, the reduced axes are retained in the output array.
Returns
An array containing the maximum of the input array along the specified axes.
Note
This function supports:
- Complex valued arguments.
Example
a = Array([[1, 2], [3, 4]])
result = reduce_max(a, List(0), keepdims=True)
print(result)
reduce_argmax
def reduce_argmax(arg0: Array, axes: List[Int]) -> Array
Computes the indices of the maximum values along the specified axes.
Args
arg0: The input array. axes: The axes along which to compute the indices of the maximum values.
Returns
An array containing the indices of the maximum values along the specified axes.
Note
This function supports:
- Complex valued arguments.
Example
a = Array([[1, 2], [3, 4]])
result = reduce_argmax(a, List(0))
print(result)