Cross-entropy loss function with softmax activation.
More...
#include <CCE_Softmax.hpp>
|
| CCESoftmax (std::shared_ptr< Softmax > softmax, std::shared_ptr< CCE > cce) |
| Construct a new CCESoftmax object.
|
|
void | forward (Eigen::MatrixXd &sample_losses, const Eigen::MatrixXd &predictions, const Eigen::MatrixXd &labels) const |
| Forward pass of the CCE loss function with softmax activation.
|
|
void | backward (Eigen::MatrixXd &out, const Eigen::MatrixXd &predictions, const Eigen::MatrixXd &labels) const |
| Backward pass of the CCE loss function with softmax activation.
|
|
Eigen::MatrixXd & | softmax_out () const |
| Get the softmax output.
|
|
| 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.
|
|
Cross-entropy loss function with softmax activation.
This class implements the cross-entropy loss function with softmax activation.
◆ CCESoftmax()
NNFS::CCESoftmax::CCESoftmax |
( |
std::shared_ptr< Softmax > |
softmax, |
|
|
std::shared_ptr< CCE > |
cce |
|
) |
| |
|
inline |
Construct a new CCESoftmax object.
- Parameters
-
softmax | Softmax activation layer |
cce | Cross-entropy loss function |
◆ backward()
void NNFS::CCESoftmax::backward |
( |
Eigen::MatrixXd & |
out, |
|
|
const Eigen::MatrixXd & |
predictions, |
|
|
const Eigen::MatrixXd & |
labels |
|
) |
| const |
|
inlinevirtual |
Backward pass of the CCE loss function with softmax activation.
- Parameters
-
[out] | out | Output gradient |
[in] | predictions | Predictions |
[in] | labels | Labels |
Implements NNFS::Loss.
◆ forward()
void NNFS::CCESoftmax::forward |
( |
Eigen::MatrixXd & |
sample_losses, |
|
|
const Eigen::MatrixXd & |
predictions, |
|
|
const Eigen::MatrixXd & |
labels |
|
) |
| const |
|
inlinevirtual |
Forward pass of the CCE loss function with softmax activation.
- Parameters
-
[out] | sample_losses | Sample losses |
[in] | predictions | Predictions |
[in] | labels | Labels |
Implements NNFS::Loss.
◆ softmax_out()
Eigen::MatrixXd & NNFS::CCESoftmax::softmax_out |
( |
| ) |
const |
|
inline |
Get the softmax output.
- Returns
- Eigen::MatrixXd& Softmax output
The documentation for this class was generated from the following file: