![]() |
iVS3D v2.0.0
|
Contains utility functions for tensor operations in neural networks. More...
Namespaces | |
| namespace | NN |
| NN Neural Network Library containing Tensor and NeuralNet classes for inference. | |
| namespace | NN::Util |
| Namespace for utility functions related to neural networks and tensors. | |
Functions | |
| template<typename ReduceOp > | |
| auto | NN::Util::bind_reduce (ReduceOp op, int axis) |
| Binds a reduction operation on a specified axis for a tensor. | |
| template<typename ReduceIndexOp > | |
| auto | NN::Util::bind_reduceWithIndex (ReduceIndexOp op, int axis) |
| Binds a reduction operation with index on a specified axis for a tensor. | |
| template<typename Func > | |
| auto | NN::Util::bind_map (Func f) |
| Binds a mapping operation on a tensor. | |
| template<typename Func > | |
| auto | NN::Util::bind_map (Func f, int axis) |
| Binds a mapping operation on a tensor that converts a each element to an array of new elements. | |
| template<typename... Args> | |
| auto | NN::Util::bind_reshape (const std::vector< int64_t > &newShape) |
| Binds a reshape operation to change the shape of a tensor. | |
| template<typename... Args> | |
| auto | NN::Util::bind_squeeze () |
| Binds a squeeze operation to remove dimensions of size 1 from a tensor. | |
| template<typename... Args> | |
| auto | NN::Util::bind_squeeze (int64_t axis) |
| Binds a squeeze operation on a tensor along a specified axis. | |
| template<typename... Args> | |
| auto | NN::Util::bind_unsqueeze (int64_t axis) |
| Binds an unsqueeze operation to add a new dimension of size 1 at a specified axis in a tensor. | |
| template<typename... Args> | |
| auto | NN::Util::bind_toCvMat () |
| Binds a conversion operation from a tensor to an OpenCV Mat format. | |
| template<typename T , typename... Args> | |
| auto | NN::Util::bind_toVector () |
| Binds a conversion operation from a tensor to a vector. | |
| template<typename... Args> | |
| auto | NN::Util::bind_inference (NN::NeuralNetPtr model) |
| Binds an inference operation on a neural network model. | |
Contains utility functions for tensor operations in neural networks.
This functional header provides utility functions to bind tensor operations such as reduction, mapping, reshaping, squeezing, unsqueezing, and converting to OpenCV Mat format. These functions are designed to be used with the Tensor class and can be easily integrated into neural network workflows by using tl::expected::and_then for chaining operations.
| auto NN::Util::bind_inference | ( | NN::NeuralNetPtr | model | ) |
Binds an inference operation on a neural network model.
| model | The neural network model to perform inference on. |
This function allows you to perform inference on a given input tensor using the specified neural network model. It returns the output tensor after processing the input through the model.
| auto NN::Util::bind_map | ( | Func | f | ) |
Binds a mapping operation on a tensor.
| f | The function to apply to each element of the tensor. |
This function allows you to apply a function to each element of the tensor. It can be used to transform the data in the tensor, such as normalizing values or converting types.
| auto NN::Util::bind_map | ( | Func | f, |
| int | axis | ||
| ) |
Binds a mapping operation on a tensor that converts a each element to an array of new elements.
| f | The function to apply to each element of the tensor. |
| axis | where to insert the new dimension from the array. |
This function allows you to apply a function to each element of the tensor and convert it to an array of new elements. It can be used to transform the data in the tensor, such as mapping each element to a color.
| auto NN::Util::bind_reduce | ( | ReduceOp | op, |
| int | axis | ||
| ) |
Binds a reduction operation on a specified axis for a tensor.
| op | The reduction operation to apply, such as ReduceSum, ReduceMin, ReduceMax. |
| axis | The axis along which to perform the reduction. |
| auto NN::Util::bind_reduceWithIndex | ( | ReduceIndexOp | op, |
| int | axis | ||
| ) |
Binds a reduction operation with index on a specified axis for a tensor.
| op | The reduction operation with index to apply, such as ReduceArgMin, ReduceArgMax. |
| axis | The axis along which to perform the reduction. |
| auto NN::Util::bind_reshape | ( | const std::vector< int64_t > & | newShape | ) |
Binds a reshape operation to change the shape of a tensor.
| newShape | The new shape to reshape the tensor to. |
This function allows you to reshape a tensor to a new shape specified by the newShape vector. The new shape must be compatible with the number of elements in the tensor.
| auto NN::Util::bind_squeeze | ( | ) |
Binds a squeeze operation to remove dimensions of size 1 from a tensor.
This function allows you to remove dimensions of size 1 from the tensor, effectively reducing its dimensionality. It can be used to simplify the shape of the tensor after operations that may have added unnecessary dimensions.
| auto NN::Util::bind_squeeze | ( | int64_t | axis | ) |
Binds a squeeze operation on a tensor along a specified axis.
| axis | The axis to squeeze. This must be in the range [0, shape.size()-1] and the dimension at this axis must be 1. |
This function allows you to remove a specific dimension of size 1 from the tensor. It can be used to simplify the shape of the tensor after operations that may have added unnecessary dimensions. If the specified axis is invalid or the dimension at that axis is not 1, an error message will be returned.
| auto NN::Util::bind_toCvMat | ( | ) |
Binds a conversion operation from a tensor to an OpenCV Mat format.
| auto NN::Util::bind_toVector | ( | ) |
Binds a conversion operation from a tensor to a vector.
| auto NN::Util::bind_unsqueeze | ( | int64_t | axis | ) |
Binds an unsqueeze operation to add a new dimension of size 1 at a specified axis in a tensor.
| axis | The axis to insert the new dimension. This must be in the range [0, shape.size()]. |
This function allows you to add a new dimension of size 1 at the specified axis in the tensor. It can be used to prepare the tensor for operations that require a specific dimensionality. If the specified axis is invalid, an error message will be returned.