nnlib
GPU-accelerated, C/C++ neural network library.
|
An abstract class to represent metrics. More...
#include <metric.h>
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. | |
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.
Metric::Metric | ( | ) |
Constructor for the Metric class.
All it does is initialize numSamples
and currentTotalMetric
to 0.
|
pure virtual |
Calcualate the current value of the metric given the new batches of targets and predictions.
targets | The desired outputs of the network. |
predictions | The actual outputs of the network. |
Implemented in BinaryAccuracy, CategoricalAccuracy, and Loss.
|
pure virtual |
Short string identifier of the metric.
Used when printing the value of the metric to the terminal.
Implemented in BinaryAccuracy, CategoricalAccuracy, CategoricalCrossEntropy, BinaryCrossEntropy, and MeanSquaredError.