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

Cross-entropy loss function. More...

#include <CCE.hpp>

Inheritance diagram for NNFS::CCE:
[legend]

Public Member Functions

 CCE ()
 Construct a new CCE object.
 
void forward (Eigen::MatrixXd &sample_losses, const Eigen::MatrixXd &predictions, const Eigen::MatrixXd &labels) const
 Forward pass of the CCE loss function.
 
void backward (Eigen::MatrixXd &out, const Eigen::MatrixXd &predictions, const Eigen::MatrixXd &labels) const
 Backward pass of the CCE loss function.
 
- 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.

This class implements the cross-entropy loss function.

Constructor & Destructor Documentation

◆ CCE()

NNFS::CCE::CCE ( )
inline

Construct a new CCE object.

Member Function Documentation

◆ backward()

void NNFS::CCE::backward ( Eigen::MatrixXd &  out,
const Eigen::MatrixXd &  predictions,
const Eigen::MatrixXd &  labels 
) const
inlinevirtual

Backward pass of the CCE loss function.

Parameters
[out]outOutput gradient
[in]predictionsPredictions
[in]labelsLabels

Implements NNFS::Loss.

◆ forward()

void NNFS::CCE::forward ( Eigen::MatrixXd &  sample_losses,
const Eigen::MatrixXd &  predictions,
const Eigen::MatrixXd &  labels 
) const
inlinevirtual

Forward pass of the CCE loss function.

Parameters
[out]sample_lossesSample losses
[in]predictionsPredictions
[in]labelsLabels

Implements NNFS::Loss.


The documentation for this class was generated from the following file: