Edge AI Add-on API 3.0.0
Loading...
Searching...
No Matches

◆ nrf_edgeai_obsv_metric_mcd_create()

void nrf_edgeai_obsv_metric_mcd_create ( nrf_edgeai_obsv_metric_t * metric,
void * buf,
uint16_t n_classes )

#include <include/nrf_edgeai_obsv/nrf_edgeai_obsv_metrics.h>

Initialize a model certainty descriptor metric using caller-provided storage.

Consumes the class-probability stream (NRF_EDGEAI_OBSV_SOURCE_PROBS). Per inference it derives, in one pass, prediction uncertainty, decisiveness and temporal stability, accumulating them into a 3 x bin_num matrix:

  • row 0: histogram of the normalized Shannon entropy H(p)/ln(N) over [0, 1] (uncertainty; high = uncertain / out-of-distribution);
  • row 1: histogram of the top-2 margin p_top1-p_top2 over [0, 1] (decisiveness; low = ambiguous near-tie);
  • row 2: stability counters [switches, comparisons, majority_frames, confident_switches], the rest of the row zero-padded. switches / comparisons is the off-device switching rate; majority_frames counts inferences with p_top1 > 0.5; confident_switches counts switches into a p_top1 > 0.5 winner.

One bin count (CONFIG_NRF_EDGEAI_OBSV_MODEL_CERTAINTY_DESC_BIN_NUM) is shared by the entropy and margin histograms and sizes the stability-counter row.

The caller allocates a buffer of at least NRF_EDGEAI_OBSV_MCD_STORAGE_BYTES bytes, passes it here, then registers the metric with nrf_edgeai_obsv_core_register().

Parameters
metricMetric descriptor to fill. Must not be NULL.
bufBuffer of at least NRF_EDGEAI_OBSV_MCD_STORAGE_BYTES(n_classes) bytes, aligned to at least sizeof(uint32_t). Must not be NULL.
n_classesNumber of model output classes (> 0).