NNFS
Neural network library from scratch
Loading...
Searching...
No Matches
NNFS::CCESoftmax Class Reference

Cross-entropy loss function with softmax activation. More...

#include <CCE_Softmax.hpp>

Inheritance diagram for NNFS::CCESoftmax:
[legend]

Public Member Functions

 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.
 
- Public Member Functions inherited from NNFS::Loss
 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.
 

Additional Inherited Members

- Public Attributes inherited from NNFS::Loss
LossType type
 

Detailed Description

Cross-entropy loss function with softmax activation.

This class implements the cross-entropy loss function with softmax activation.

Constructor & Destructor Documentation

◆ CCESoftmax()

NNFS::CCESoftmax::CCESoftmax ( std::shared_ptr< Softmax softmax,
std::shared_ptr< CCE cce 
)
inline

Construct a new CCESoftmax object.

Parameters
softmaxSoftmax activation layer
cceCross-entropy loss function

Member Function Documentation

◆ 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]outOutput gradient
[in]predictionsPredictions
[in]labelsLabels

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_lossesSample losses
[in]predictionsPredictions
[in]labelsLabels

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: