|
NNFS
Neural network library from scratch
|
Base class for all loss functions. More...
#include <Loss.hpp>
Public Member Functions | |
| Loss (LossType type) | |
| Construct a new Loss object. | |
| virtual | ~Loss ()=default |
| Basic destructor. | |
| virtual void | forward (Eigen::MatrixXd &sample_losses, const Eigen::MatrixXd &predictions, const Eigen::MatrixXd &labels) const =0 |
| Forward pass of the loss function. | |
| virtual void | backward (Eigen::MatrixXd &out, const Eigen::MatrixXd &predictions, const Eigen::MatrixXd &labels) const =0 |
| Backward pass of the loss function. | |
| void | calculate (double &loss, const Eigen::MatrixXd &predictions, const Eigen::MatrixXd &labels) |
| Calculate the loss. | |
| double | regularization_loss (const std::shared_ptr< Dense > &layer) |
| Calculate l1 and l2 regularization loss. | |
Public Attributes | |
| LossType | type |
Base class for all loss functions.
This class is the base class for all losses. It provides the interface for all loss functions.
|
inline |
Construct a new Loss object.
| type | Type of loss function |
|
virtualdefault |
Basic destructor.
|
pure virtual |
Backward pass of the loss function.
| [out] | out | Output gradient |
| [in] | predictions | Predictions |
| [in] | labels | Labels |
Implemented in NNFS::CCE, and NNFS::CCESoftmax.
|
inline |
Calculate the loss.
| [out] | loss | Loss |
| [in] | predictions | Predictions |
| [in] | labels | Labels |
|
pure virtual |
Forward pass of the loss function.
| [out] | sample_losses | Sample losses |
| [in] | predictions | Predictions |
| [in] | labels | Labels |
Implemented in NNFS::CCE, and NNFS::CCESoftmax.
|
inline |
Calculate l1 and l2 regularization loss.
| layer | Layer to calculate regularization loss |
| LossType NNFS::Loss::type |