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

The implementation of categorical accuracy. More...

#include <metric.h>

Inheritance diagram for CategoricalAccuracy:
Metric

Public Member Functions

 CategoricalAccuracy ()
 Constructor of CategoricalAccuracy.
 
float calculateMetric (const sTensor &targets, const sTensor &predictions) override
 Calcualate the current value of the metric given the new batches of targets and predictions. More...
 
std::string getShortName () const override
 Short string identifier of the metric. More...
 
- 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.
 

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

The implementation of categorical accuracy.

This metric requires the targets to consist of only 0s and 1s, with 1s corresponding to the correct class. The rows are the samples, the columns are the classes. The predictions can consist of any real value, the largest value is assumed to be the predicted class.

Examples
MNIST.

Member Function Documentation

◆ calculateMetric()

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

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.

Implements Metric.

◆ getShortName()

std::string CategoricalAccuracy::getShortName ( ) const
overridevirtual

Short string identifier of the metric.

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

Returns
A string identifier of the metric.

Implements Metric.


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