Txeo v0.1
A Developer-Friendly TensorFlow C++ Wrapper
|
A utility class for common math functions on tensors. More...
#include <TensorFunc.h>
Public Member Functions | |
TensorFunc (const TensorFunc &)=delete | |
TensorFunc (TensorFunc &&)=delete | |
TensorFunc & | operator= (const TensorFunc &)=default |
TensorFunc & | operator= (TensorFunc &&)=delete |
~TensorFunc ()=default | |
Static Public Member Functions | |
static txeo::Tensor< T > | power_elem (const txeo::Tensor< T > &tensor, const T &exponent) |
Returns the element-wise potentiation of a tensor. | |
static txeo::Tensor< T > & | power_elem_by (txeo::Tensor< T > &tensor, const T &exponent) |
Performs element-wise potentiation of the tensor (in-place) | |
static txeo::Tensor< T > | square (const txeo::Tensor< T > &tensor) |
Computes the element-wise square of a tensor. | |
static txeo::Tensor< T > & | square_by (txeo::Tensor< T > &tensor) |
Computes the element-wise square of a tensor in-place. | |
static txeo::Tensor< T > | sqrt (const txeo::Tensor< T > &tensor) |
Computes the element-wise square root of a tensor. | |
static txeo::Tensor< T > & | sqrt_by (txeo::Tensor< T > &tensor) |
Computes the element-wise square root of a tensor in-place. | |
static txeo::Tensor< T > | abs (const txeo::Tensor< T > &tensor) |
Computes the element-wise absolute value of a tensor. | |
static txeo::Tensor< T > & | abs_by (txeo::Tensor< T > &tensor) |
Computes the element-wise absolute value of a tensor in-place. | |
static txeo::Tensor< T > | permute (const txeo::Tensor< T > &tensor, const std::vector< size_t > &axes) |
Permutes the axes of a tensor. | |
static txeo::Tensor< T > & | permute_by (txeo::Tensor< T > &tensor, const std::vector< size_t > &axes) |
Permutes the axes of a tensor in-place. | |
static txeo::Tensor< T > & | normalize_by (txeo::Tensor< T > &tensor, size_t axis, txeo::NormalizationType type) |
Normalizes the input tensor along a specified axis in-place. | |
static txeo::Tensor< T > | normalize (const txeo::Tensor< T > &tensor, size_t axis, txeo::NormalizationType type) |
Creates a normalized copy of the input tensor along a specified axis. | |
static std::vector< std::function< T(const T &)> > | make_normalize_functions (const txeo::Tensor< T > &tensor, size_t axis, txeo::NormalizationType type) |
Construct the normalization functions for each dimension of the specified axis. | |
static Tensor< T > & | normalize_by (txeo::Tensor< T > &tensor, txeo::NormalizationType type) |
Normalizes the entire tensor in-place (global normalization) | |
static txeo::Tensor< T > | normalize (const txeo::Tensor< T > &tensor, txeo::NormalizationType type) |
Creates a normalized copy of the entire tensor (global normalization) | |
static std::function< T(const T &)> | make_normalize_function (const txeo::Tensor< T > &tensor, txeo::NormalizationType type) |
Construct the normalization function for the elements of the specified tensor. | |
static txeo::Matrix< T > | transpose (const txeo::Matrix< T > &matrix) |
Transposes a matrix. | |
static txeo::Matrix< T > & | transpose_by (txeo::Matrix< T > &matrix) |
Transposes a matrix in-place. | |
static txeo::Matrix< T > | compute_gram_matrix (const txeo::Matrix< T > &matrix) |
Computes the Gram matrix ( \(A^TA\)) of the input matrix. | |
A utility class for common math functions on tensors.
This class provides static methods for common tensor functions, such as square.
T | The data type of the tensor elements (e.g., int, double). |
Definition at line 27 of file TensorFunc.h.
|
delete |
|
delete |
|
default |
|
static |
Computes the element-wise absolute value of a tensor.
tensor | The input tensor to be modified. |
Example Usage:
|
static |
Computes the element-wise absolute value of a tensor in-place.
tensor | The input tensor to be modified. |
Example Usage:
|
static |
Computes the Gram matrix ( \(A^TA\)) of the input matrix.
matrix | Input matrix where rows represent samples and columns represent features |
TensorFuncError |
The Gram matrix is calculated as the matrix product of the transpose of the input matrix with the original matrix. This produces a symmetric positive semi-definite matrix where each element (i,j) represents the inner product of column i and column j from the original matrix.
Example Usage:
|
static |
Construct the normalization function for the elements of the specified tensor.
tensor | Tensor to be inspected |
type | NOrmalization type |
std::TensorFuncError |
|
static |
Construct the normalization functions for each dimension of the specified axis.
tensor | Tensor to be inspected |
axis | Axis from which the normalization functions will be computed |
type | NOrmalization type |
std::TensorFuncError |
|
static |
Creates a normalized copy of the input tensor along a specified axis.
tensor | The input tensor to normalize |
axis | The dimension along which to apply normalization |
type | The normalization method (MIN_MAX or Z_SCORE) |
std::TensorFuncError |
Example Usage:
|
static |
Creates a normalized copy of the entire tensor (global normalization)
tensor | The input tensor to normalize |
type | The normalization method (MIN_MAX or Z_SCORE) |
std::TensorFuncError |
Example Usage:
|
static |
Normalizes the input tensor along a specified axis in-place.
[in,out] | tensor | The tensor to be normalized (modified in-place) |
axis | The dimension along which to apply normalization | |
type | The normalization method from NormalizationType enum:
|
std::TensorFuncError |
Example Usage:
|
static |
Normalizes the entire tensor in-place (global normalization)
[in,out] | tensor | The tensor to be normalized (modified in-place) |
type | The normalization method (MIN_MAX or Z_SCORE) |
std::TensorFuncError |
Example Usage:
|
default |
|
delete |
|
static |
Permutes the axes of a tensor.
tensor | The input tensor. |
axes | The new order of the tensor axes. Must be a valid permutation of the tensor's dimensions. |
std::invalid_argument | If the axes are invalid (e.g., size mismatch or out of range). |
Example Usage:
|
static |
Permutes the axes of a tensor in-place.
tensor | The input tensor to be modified. |
axes | The new order of axes. Must be a valid permutation of the tensor's dimensions. |
std::TensorFuncError |
Example Usage:
|
static |
Returns the element-wise potentiation of a tensor.
tensor | Tensor to be powered |
exponent | Exponent of the potentiation |
Example Usage:
|
static |
Performs element-wise potentiation of the tensor (in-place)
tensor | Tensor to be modified |
exponent | Exponent of the potentiation |
Example Usage:
|
static |
Computes the element-wise square root of a tensor.
tensor | The input tensor. |
Example Usage:
|
static |
Computes the element-wise square root of a tensor in-place.
tensor | The input tensor to be modified. |
Example Usage:
|
static |
Computes the element-wise square of a tensor.
tensor | The input tensor. |
Example Usage:
|
static |
Computes the element-wise square of a tensor in-place.
tensor | The input tensor to be modified. |
Example Usage:
|
static |
Transposes a matrix.
matrix | The input matrix. |
Example Usage:
|
static |
Transposes a matrix in-place.
matrix | The input matrix to be modified. |
Example Usage: