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

Class representing the Categorical Cross Entropy. More...

#include <loss.h>

Inheritance diagram for CategoricalCrossEntropy:
Loss Metric

Public Member Functions

sTensor calculateLoss (const sTensor &targets, const sTensor &predictions) override
 
std::string getShortName () const override
 Short string identifier of the metric. More...
 
- Public Member Functions inherited from Loss
 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...
 
- 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

Class representing the Categorical Cross Entropy.

This loss expects the targets to be in shape (batchSize, numClasses), where each row contains only a single 1 and numClasses - 1 0s.

The sum of predictions doesn't have to be 1. The sum will be auto-normalized when calculating the loss and the derivatives.

Examples
MNIST.

Member Function Documentation

◆ getShortName()

std::string CategoricalCrossEntropy::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: