nnlib
GPU-accelerated, C/C++ neural network library.
Public Member Functions | List of all members
Loss Class Referenceabstract

Abstract class representing a loss function. More...

#include <loss.h>

Inheritance diagram for Loss:
Metric BinaryCrossEntropy CategoricalCrossEntropy MeanSquaredError

Public Member Functions

 Loss ()
 Constructor for the Loss class. More...
 
float calculateMetric (const sTensor &targets, const sTensor &predictions) override
 Defines the method inherited from abstract Metric parent. More...
 
virtual sTensor calculateLoss (const sTensor &targets, const sTensor &predictions)=0
 
- Public Member Functions inherited from Metric
 Metric ()
 Constructor for the Metric class. More...
 
void reset ()
 Reset the metric, i.e.: set numSamples and currentTotalMetric to 0.
 
virtual std::string getShortName () const =0
 Short string identifier of the metric. More...
 

Additional Inherited Members

- Protected Attributes inherited from Metric
size_t numSamples
 The number of samples processed so far.
 
float currentTotalMetric
 The current total value of the metric.
 

Detailed Description

Abstract class representing a loss function.

All loss functions are by default also metrics.

The child classes need to define the calculateLoss and calculateDerivatives methods.

Constructor & Destructor Documentation

◆ Loss()

Loss::Loss ( )

Constructor for the Loss class.

Initializes the numSamples and currentTotalLoss variables to 0.

Member Function Documentation

◆ calculateMetric()

float Loss::calculateMetric ( const sTensor &  targets,
const sTensor &  predictions 
)
overridevirtual

Defines the method inherited from abstract Metric parent.

It simply calls the #calculateLoss function, which is implemented by every child loss function.

Parameters
targetsThe desired outputs of the network.
predictionsThe actual outputs of the network.
Returns
The value of the metric. Here, the value of the loss function.

Implements Metric.


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