Jump to content

Connect Leeroopedia MCP: Equip your AI agents to search best practices, build plans, verify code, diagnose failures, and look up hyperparameter defaults.

Implementation:Ggml org Ggml Mnist model eval

From Leeroopedia


Template:Implementation

Summary

mnist_model_eval is the primary API for evaluating a trained MNIST model against a test dataset in GGML. It performs a forward-only inference pass over the entire dataset and returns an opaque result object from which loss, accuracy, and per-sample predictions can be extracted.

Primary API

ggml_opt_result_t mnist_model_eval(mnist_model & model, ggml_opt_dataset_t dataset)
Source
examples/mnist/mnist-common.cpp:L385-410
Repository
https://github.com/ggml-org/ggml

Parameters

Parameter Type Description
model mnist_model & The model with a built computation graph, ready for inference.
dataset ggml_opt_dataset_t The test dataset to evaluate against.

Return Value

Returns ggml_opt_result_t -- an opaque handle to the evaluation results.

Result Accessors

The returned ggml_opt_result_t provides the following accessor functions:

ggml_opt_result_loss

void ggml_opt_result_loss(ggml_opt_result_t result, double * loss, double * unc)
Source
src/ggml-opt.cpp:L657-690
Description
Retrieves the cross-entropy loss and its uncertainty estimate.

ggml_opt_result_accuracy

void ggml_opt_result_accuracy(ggml_opt_result_t result, double * accuracy, double * unc)
Source
src/ggml-opt.cpp:L698-707
Description
Retrieves the classification accuracy and its uncertainty estimate.

ggml_opt_result_pred

void ggml_opt_result_pred(ggml_opt_result_t result, int32_t * pred)
Source
src/ggml-opt.cpp:L692-696
Description
Retrieves the per-sample predicted class indices.

Key Implementation Details

  • Uses build_type=FORWARD -- no backward pass is constructed or executed.
  • Uses idata_split=0 -- all data in the dataset is treated as evaluation data.
  • Dependencies: ggml-opt.h

Related

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment