Reduces a Tensor by summing its elements along a specified axis.
This operation initializes an accumulator to zero and adds each element along the specified axis.
if (result) {
std::cout << "Reduced Tensor: " << result.value().toString() << std::endl;
} else {
std::cerr << "Error: " << result.error() << std::endl;
}
A Tensor represents a N-dimensional array containing elements of the same type. Can be used as input ...
Definition Tensor.h:201
tl::expected< Tensor, NeuralError > reduce(const Op &op, uint64_t axis) const
Reduce the Tensor along a given axis by applying an accumulative operation.
Definition Tensor.h:483
Reduces a Tensor by summing its elements along a specified axis.
Definition ReduceOps.h:37
- See also
- Tensor::reduce For the main reduction function that applies this operation.
-
reduce.cpp For an example of using this operation.