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

#include <Accuracy.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 Accuracy.h.

Member Function Documentation

◆ calculateValue()

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

Definition at line 27 of file Accuracy.cpp.

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

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


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