ONE - On-device Neural Engine
Loading...
Searching...
No Matches
onert_micro::train::losses_functions::SparseCrossEntropy Struct Reference

#include <SparseCrossEntropy.h>

Static Public Member Functions

static void calculateErrorBackpropagation (const uint32_t flat_size, const float *calculated_data, const float *target_data, float *output_grad)
 

Detailed Description

Definition at line 32 of file SparseCrossEntropy.h.

Member Function Documentation

◆ calculateErrorBackpropagation()

void SparseCrossEntropy::calculateErrorBackpropagation ( const uint32_t  flat_size,
const float *  calculated_data,
const float *  target_data,
float *  output_grad 
)
static

Definition at line 33 of file SparseCrossEntropy.cpp.

36{
37 uint32_t label = static_cast<uint32_t>(target_data[0]);
38
39 for (uint32_t i = 0; i < flat_size; ++i)
40 {
41 if (i == label)
42 {
43 output_grad[i] = -1.0 / (calculated_data[i] + float(10.0e-20));
44 }
45 else
46 {
47 output_grad[i] = 0.0;
48 }
49 }
50}

Referenced by onert_micro::core::train::OMTrainingHandler::handleError().


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