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

#include <SparseCrossEntropyAccuracy.h>

Static Public Member Functions

static float calculateValue (const uint32_t flat_size, const float *calculated_data, const float *target_data)
 

Detailed Description

Definition at line 32 of file SparseCrossEntropyAccuracy.h.

Member Function Documentation

◆ calculateValue()

float SparseCrossEntropyAccuracy::calculateValue ( const uint32_t  flat_size,
const float *  calculated_data,
const float *  target_data 
)
static

Definition at line 27 of file SparseCrossEntropyAccuracy.cpp.

30{
31 // Find target class
32 uint32_t target_class = static_cast<uint32_t>(target_data[0]);
33
34 // Find predicted class
35 float pred_class = 0.f;
36 float pred_max_val = calculated_data[0];
37 for (uint32_t i = 0; i < flat_size; ++i)
38 {
39 if (pred_max_val < calculated_data[i])
40 {
41 pred_max_val = calculated_data[i];
42 pred_class = static_cast<float>(i);
43 }
44 }
45
46 return pred_class == target_class ? 1.0f : 0.0f;
47}

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


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