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

An abstract class to represent metrics. More...

#include <metric.h>

Inheritance diagram for Metric:
BinaryAccuracy CategoricalAccuracy Loss BinaryCrossEntropy CategoricalCrossEntropy MeanSquaredError

Public Member Functions

 Metric ()
 Constructor for the Metric class. More...
 
void reset ()
 Reset the metric, i.e.: set numSamples and currentTotalMetric to 0.
 
virtual float calculateMetric (const sTensor &targets, const sTensor &predictions)=0
 Calcualate the current value of the metric given the new batches of targets and predictions. More...
 
virtual std::string getShortName () const =0
 Short string identifier of the metric. More...
 

Protected Attributes

size_t numSamples
 The number of samples processed so far.
 
float currentTotalMetric
 The current total value of the metric.
 

Detailed Description

An abstract class to represent metrics.

The metric function is called after every batch is processed and reset at the end of each epoch. The metric keeps track of the current metric in an epoch by maintaining the number of datapoints processed and the total metric.

Constructor & Destructor Documentation

◆ Metric()

Metric::Metric ( )

Constructor for the Metric class.

All it does is initialize numSamples and currentTotalMetric to 0.

Member Function Documentation

◆ calculateMetric()

virtual float Metric::calculateMetric ( const sTensor &  targets,
const sTensor &  predictions 
)
pure virtual

Calcualate the current value of the metric given the new batches of targets and predictions.

Parameters
targetsThe desired outputs of the network.
predictionsThe actual outputs of the network.
Returns
The value of the metric.

Implemented in BinaryAccuracy, CategoricalAccuracy, and Loss.

◆ getShortName()

virtual std::string Metric::getShortName ( ) const
pure virtual

Short string identifier of the metric.

Used when printing the value of the metric to the terminal.

Returns
A string identifier of the metric.

Implemented in BinaryAccuracy, CategoricalAccuracy, CategoricalCrossEntropy, BinaryCrossEntropy, and MeanSquaredError.


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