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

The implementation of binary accuracy. More...

#include <metric.h>

Inheritance diagram for BinaryAccuracy:
Metric

Public Member Functions

 BinaryAccuracy ()
 Constructor of BinaryAccuracy.
 
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 binary accuracy.

This metric assumes the targets to be of shape Nx1 with N being the batch size. The targets can only consist of 0s and 1s corresponding to the two classes. The predictions can be any real value from the range [0, 1]. Predictions larger than 0.5 are assigned to class 1 while predictions smaller than 0.5 are assigned to class 0.

Examples
Titanic.

Member Function Documentation

◆ calculateMetric()

float BinaryAccuracy::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 BinaryAccuracy::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: