Txeo v0.1
A Developer-Friendly TensorFlow C++ Wrapper
|
Computes error metrics between predicted and validation tensors. More...
#include <Loss.h>
Computes error metrics between predicted and validation tensors.
Supports multiple loss functions that can be selected at runtime:
T | Numeric type of tensor elements (float/double recommended) |
|
default |
|
explicit |
Construct a new Loss object from a label rvalue.
label | Labe tensor containing ground truth values |
func | Initial loss function (default: MSE) |
|
inlineexplicit |
T txeo::Loss< T >::get_loss | ( | const txeo::Tensor< T > & | pred | ) | const |
Compute loss using currently selected function.
pred | Prediction tensor |
LossError | If shapes mismatch or invalid input values |
|
inline |
|
inline |
Definition at line 152 of file Loss.h.
T txeo::Loss< T >::log_cosh_error | ( | const txeo::Tensor< T > & | pred | ) | const |
Compute Log-Cosh Error (LCHE)
\[ LCHE = \frac{1}{N}\sum_{i=1}^{N}\log(\cosh(y_i - \hat{y}_i)) \]
pred | Prediction tensor |
|
inline |
Definition at line 144 of file Loss.h.
T txeo::Loss< T >::mean_absolute_error | ( | const txeo::Tensor< T > & | pred | ) | const |
Compute Mean Absolute Error (MAE)
\[ MAE = \frac{1}{N}\sum_{i=1}^{N}|y_i - \hat{y}_i| \]
pred | Prediction tensor |
T txeo::Loss< T >::mean_squared_error | ( | const txeo::Tensor< T > & | pred | ) | const |
Compute Mean Squared Error (MSE)
\[ MSE = \frac{1}{N}\sum_{i=1}^{N}(y_i - \hat{y}_i)^2 \]
pred | Prediction tensor |
T txeo::Loss< T >::mean_squared_logarithmic_error | ( | const txeo::Tensor< T > & | pred | ) | const |
Compute Mean Squared Logarithmic Error (MSLE)
\[ MSLE = \frac{1}{N}\sum_{i=1}^{N}(\log(1+y_i) - \log(1+\hat{y}_i))^2 \]
pred | Prediction tensor |
LossError | If any values are negative |
|
inline |
|
inline |
Definition at line 148 of file Loss.h.
void txeo::Loss< T >::set_loss | ( | txeo::LossFunc | func | ) |
Set the active loss function.
func | Loss function to use for subsequent calculations |