Support Library

Run Inference on the Desktop

Neuton Inference Runner Executable

Neuton Inference Runner is an executable containing a user-specific Neuton ML solution. With its help, the user can validate the results of the inference of the model even without implementation in the Edge device!

Neuton Inference Runner сompiled for the following OS:

  • neuton_inference_runner_linux - Linux based system, e.g. ubuntu:20.04;
  • neuton_inference_runner_win - 64-bit Windows based system;
  • neuton_inference_runner_mac - will be added soon!
How to use

Neuton Inference Runner has user CLI interface for executing various commands.

To see help you can run neuton_inference_runner without any arguments:

.\artifacts\inference_runner>neuton_inference_runner_linux

      DESCRIPTION
        Neuton Inference Runner Executable

      SYNOPSIS
        neuton_inference_runner_Os info
        neuton_inference_runner_Os inference dataset [-s filename]
        neuton_inference_runner_Os metrics dataset

      OPTIONS
        info -  print Neuton solution info

        inference
          dataset - filename of the user dataset
          -s, --save - save the inference result to the filename

        metrics
          dataset - filename of the user dataset with target

      LICENSE
        NEUTON
Get Neuton solution information

Use info command to see Neuton solution information that compiled in Neuton Inference Runner:

.\artifacts\inference_runner>neuton_inference_runner_linux info
      Solution name: My_Neuton_Project
      Model bit depth: 16 bits
      Float support: 1
      Task type: Binary classification
      Input type: float
      Unique inputs count: 10
      Window size: 1
      Input scaling type: unified
      Outputs count: 2
      Neurons count: 11
      Model flash usage: 241 bytes
Run inference

Use inference command to run inference on the provided CSV dataset.

Supported two kinds of datasets: CSV text file format and Neuton dataset binary file format (with corresponding filename extensions '.csv' and '.bin'). The CSV dataset should have a header and contains only number fields separated by comma.

Inference result will be printed to the screen. Additional params -s filename (or --save filename ) stores the inference results to the CSV file.

usage examples:

.\artifacts\inference_runner>neuton_inference_runner_linux inference test.csv
.\artifacts\inference_runner>neuton_inference_runner_linux inference test.csv -s result.csv
Get metrics

Use metrics command to calculate validation metrics. It is only possible if the provided dataset contains target values. Dataset should have a header with a target column named target .

usage examples:

.\artifacts\inference_runner>neuton_inference_runner_linux metrics test.csv




Read more

Neuton TinyML Tutorial

Neuton TinyML is a no-code development platform that streamlines the creation of machine learning models for edge devices. Watch a comprehensive tutorial that gives an overview of our unique framework and covers a step-by-step pipeline of the TinyML model creation on the example of a handwritten digit recognition task.


Read more

Preloaded Datasets

The Neuton platform offers a collection of preloaded datasets for various domains. You can use preloaded datasets to explore the capabilities of the platform without collecting data yourself. All settings are set by default, without the possibility of changing them.
To train a model with preloaded datasets, you need to create a new solution and select the “Preload Datasets” tab when choosing a training dataset.
Descriptions for the preloaded datasets can be found by clicking on the question mark or in the “Use Cases” section on the platform.
Platform. Use Cases Tab.



Read more

Analytics Tools

The Analytics Tools is a set of Neuton’s explainability features:
Data Analysis
This tool automates processed data (training dataset) analysis and relation to the target variable. The report is generated during model training for each solution. Given the potentially wide feature space, up to 20 of the most important features with the highest statistical significance are selected for data analysis based on machine learning modeling. The data analysis tool is available on the “My Solution” page and the “Results” tab, found via the “Data Analysis” button.
The final model might indicate a slightly different set of features having the highest importance due to a comprehensive number of iterations during training. This could result in discrepancies between the features selected for data analysis and the final Feature Importance Matrix.
My Solutions. Data Analysis
Results. Data Analysis
In the “Data Analysis” tool you can find the specified information on graphics in each of the following sections:
Dataset overview
This section displays brief data statistics of your training dataset and provides the following information: problem type, dataset dimension, missing values, and record number.
Continuous data distribution and relation to the target variable.
Visualization of each continuous variable yields two plots:
Variable density distribution chart
A Density plot visualizes the distribution of data across all rows in the dataset. This chart is a variation of a histogram that uses kernel smoothing to plot values, allowing smoother distributions by smoothing out the noise. The peaks of a Density plot help to display where values are concentrated over the interval.
Feature relation to the target variable (different for regression and classification task types)
This chart is presented in one of the following two formats: line chart, indicating the continuous variable changes with the changes in the continuous target variable (regression task type), or histogram, showing the mean continuous variable value for each of the classes of the target variable (classification task type).
Feature correlations
Visualization of the correlations in the data yields two plots:
Heatmap displaying the binary correlation of the 10 most important variables between each other and with the target variable (the 10 most important features are selected based on the binary correlation of the features with the target variable);
Histogram (horizontal) displaying the level of high mutual correlation between independent variable pairs.
Pairs are selected if the value of their mutual correlation exceeds 0.7.
Target variable distribution
Visualization of the target variable statistics is presented in one of the two formats:
Violin plot displaying the distribution, median, and outliers in the target variable (regression task type);
Histogram/count plot displaying the number and percentage of each of the target classes throughout the whole dataset (classification task type)
Outliers
Visualization of the outliers in the data is presented in one of the two plots:
Scatter plot displaying the variable distribution in relation to the target variable (regression task type);
Results. Data Analysis
Model Quality Diagram
The Model Quality Diagram simplifies the process of evaluating the model quality. The values of all metrics are evaluated on a scale from 0 to 1, where 1 is the most accurate model.
Model Quality Diagram
It also allows users to understand metric balance for the selected model. When the figure displayed is close to the shape of a regular polygon, that conveys a perfect balance between all metric indicator values.
Feature Importance Matrix (FIM)
After the model has been trained, the platform displays a chart with the 10 features that had the most significant impact on the model prediction of the target variable (for the selected model). The chart can be found in the Results tab.
The Feature Importance Matrix helps to evaluate the impact of features on the model.

If the feature does not affect the model at all (normalized value = 0), then you can exclude this variable from building the model.
Feature Importance Matrix
FIM has the following control options:
Top 10/Bottom 10
This control option allows you to show the 10 most important or least important features.
Select features
The “Select Features” button allows you to select/remove features of interest.
Classes (for binary and multiclass classification task types only)
These check boxes allow you to control what classes to display on a bar chart.
Feature Importance Matrix. Feature List
Confusion Matrix (for classification tasks only)
The Confusion Matrix shows the number of correct and incorrect predictions based on the validation data for the selected model.
Confusion Matrix
You can find it in the Results tab in each solution with a classification problem.



Read more

Run Inference on the MCU

Neuton, our unique neural network framework, natively creates incredibly compact and accurate models that can easily be deployed into your firmware project using an automatically generated archive with a C library.

The library is written in accordance with the C99 standard, so it is universal and does not have strict requirements for the hardware. The ability to use the library depends mainly on the amount of memory available for its operation.

How to integrate Neuton into your firmware project
Neuton folder structure

There are only two folders that should be added to your project for integrating Neuton:

  • neuton - main framework folder in which all Neuton algorithms, utilities, are located;

    for Non-enterprise users, only precompiled libraries are available in the ./neuton/lib folder.
    for Enterprise users, Neuton source code is available in the ./neuton/source folder.
  • neuton_generated - folder containing all user solution-specific files (neural network model, data preprocessing configuration, etc).

Also, you should add folder where ./neuton_generated is located and ./neuton/include folder to your project INCLUDE paths.

Use Neuton in your project

First of all, you need to include the main header file of Neuton:

#include <neuton/neuton.h>

For making an inference with Neuton, there are only 3 functions that you should use:

  • neuton_nn_setup - Set up the internal components of Neuton, should be called first and once;
  • neuton_nn_feed_inputs - Feed and prepare live input features for model inference;
  • neuton_nn_run_inference - Run live input features into a Neuton machine learning algorithm (or “ML model”) to calculate an output;
Feed input values

Make an array with model raw input features(signal data). Inputs count and order should be the same as in the training dataset.

neuton_input_t raw_inputs[] = {
    raw_input_0,
    raw_input_1,
    // ...
    raw_input_N
};

Pass this input array to the neuton_nn_feed_inputs function.

neuton_nn_setup();

neuton_inference_input_t* p_input = neuton_nn_feed_inputs(raw_inputs, neuton_nn_uniq_inputs_num());

if (p_input != NULL)
{
    //make inference
}

In case the Neuton solution needs to collect a data window, you can use the following sample-by-sample feed algorithm:

neuton_nn_setup();

for (size_t i = 0; i < neuton_nn_input_window_size(); i++)
{
    neuton_inference_input_t* p_input = neuton_nn_feed_inputs(raw_inputs, neuton_nn_uniq_inputs_num());
    if (p_input != NULL)
    {
        //make inference
        break;
    }
    raw_inputs += neuton_nn_uniq_inputs_num();
}

Or feed all input samples at once:

neuton_nn_setup();

neuton_inference_input_t* p_input;
p_input = neuton_nn_feed_inputs(raw_inputs, neuton_nn_uniq_inputs_num() * neuton_nn_input_window_size());

if (p_input != NULL)
{
    //make inference
}
Run Inference

When input buffer is ready for running inference, you should call neuton_nn_run_inference with three arguments:

  • p_input - Input features for model inference, obtained from @ref neuton_nn_feed_inputs() API call
  • p_index - Index of predicted target(class) with highest probability;
  • pp_outputs - Pointer to pointer to the internal buffer with all predicted outputs, contains predicted target variable (for regression task) or probabilities of each class (binary/multi classification tasks).
Wrapping everything together
/** Setup Neuton */
neuton_nn_setup();

/** Feed and prepare raw inputs for the model inference */
neuton_inference_input_t* p_input;
p_input = neuton_nn_feed_inputs(raw_inputs, neuton_nn_uniq_inputs_num() * neuton_nn_input_window_size());

/** Run inference */
if (p_input)
{
    neuton_u16_t predicted_target;
    neuton_output_t* probabilities;
    neuton_i16_t outputs_num = neuton_nn_run_inference(p_input, &predicted_target, &probabilities);

    if (outputs_num > 0)
    {
        printf("Predicted target %d with probability %f\r\n", predicted_target, probabilities[predicted_target]);

        printf("All probabilities:\r\n");
        for (size_t i = 0; i < outputs_num; i++)
            printf("%f," probabilities[i]);
    }
}
Map predicted results on the required values (for Classification task type)

Inference results are encoded (0…n). For mapping on your classes, use dictionaries binary_target_dict_csv.csv / multi_target_dict_csv.csv.

Additional solution information API

You can use the following API to get solution information:

  • neuton_nn_solution_id_str - Get solution ID in string format;
  • neuton_nn_uniq_inputs_num - Get number of unique input features on which the model was trained;
  • neuton_nn_input_window_size - Get input features window size in feature samples(vectors);
  • neuton_nn_model_neurons_num - Get number of model neurons;
  • neuton_nn_model_weights_num - Get number of model weights;
  • neuton_nn_model_outputs_num - Get number of model outputs (predicted targets);
  • neuton_nn_model_task - Get model task : NEUTON_NN_TASK_MULT_CLASS, NEUTON_NN_TASK_BIN_CLASS, NEUTON_NN_TASK_REGRESSION
  • neuton_nn_model_size - Get model size in bytes (flash usage)
  • neuton_nn_model_bitdepth - Get model bit depth (8/16/32 bit)
  • neuton_nn_input_scaling - Get solution input scaling type: NEUTON_NN_INPUT_SCALING_UNIFIED, NEUTON_NN_INPUT_SCALING_UNIQUE

Neuton, our unique neural network framework, natively creates incredibly compact and accurate models that can easily be deployed into your firmware project using an automatically generated archive with a C library.

The library is written in accordance with the C99 standard, so it is universal and does not have strict requirements for the hardware. The ability to use the library depends mainly on the amount of memory available for its operation.

How to integrate Neuton into your firmware project
Neuton folder structure

There are only two folders that should be added to your project for integrating Neuton:

  • neuton - main framework folder in which all Neuton algorithms, utilities, are located;

    for Non-enterprise users, only precompiled libraries are available in the ./neuton/lib folder.
    for Enterprise users, Neuton source code is available in the ./neuton/source folder.
  • neuton_generated - folder containing all user solution-specific files (neural network model, data preprocessing configuration, etc).

Also, you should add folder where ./neuton_generated is located and ./neuton/include folder to your project INCLUDE paths.

Use Neuton in your project

First of all, you need to include the main header file of Neuton:

#include <neuton/neuton.h>

For making an inference with Neuton, there are only 3 functions that you should use:

  • neuton_nn_setup - Set up the internal components of Neuton, should be called first and once;
  • neuton_nn_feed_inputs - Feed and prepare live input features for model inference;
  • neuton_nn_run_inference - Run live input features into a Neuton machine learning algorithm (or “ML model”) to calculate an output;
Feed input values

Make an array with model raw input features(signal data). Inputs count and order should be the same as in the training dataset.

neuton_input_t raw_inputs[] = {
    raw_input_0,
    raw_input_1,
    // ...
    raw_input_N
};

Pass this input array to the neuton_nn_feed_inputs function.

neuton_nn_setup();

neuton_inference_input_t* p_input = neuton_nn_feed_inputs(raw_inputs, neuton_nn_uniq_inputs_num());

if (p_input != NULL)
{
    //make inference
}

In case the Neuton solution needs to collect a data window, you can use the following sample-by-sample feed algorithm:

neuton_nn_setup();

for (size_t i = 0; i < neuton_nn_input_window_size(); i++)
{
    neuton_inference_input_t* p_input = neuton_nn_feed_inputs(raw_inputs, neuton_nn_uniq_inputs_num());
    if (p_input != NULL)
    {
        //make inference
        break;
    }
    raw_inputs += neuton_nn_uniq_inputs_num();
}

Or feed all input samples at once:

neuton_nn_setup();

neuton_inference_input_t* p_input;
p_input = neuton_nn_feed_inputs(raw_inputs, neuton_nn_uniq_inputs_num() * neuton_nn_input_window_size());

if (p_input != NULL)
{
    //make inference
}
Run Inference

When input buffer is ready for running inference, you should call neuton_nn_run_inference with three arguments:

  • p_input - Input features for model inference, obtained from @ref neuton_nn_feed_inputs() API call
  • p_index - Index of predicted target(class) with highest probability;
  • pp_outputs - Pointer to pointer to the internal buffer with all predicted outputs, contains predicted target variable (for regression task) or probabilities of each class (binary/multi classification tasks).
Wrapping everything together
/** Setup Neuton */
neuton_nn_setup();

/** Feed and prepare raw inputs for the model inference */
neuton_inference_input_t* p_input;
p_input = neuton_nn_feed_inputs(raw_inputs, neuton_nn_uniq_inputs_num() * neuton_nn_input_window_size());

/** Run inference */
if (p_input)
{
    neuton_u16_t predicted_target;
    neuton_output_t* probabilities;
    neuton_i16_t outputs_num = neuton_nn_run_inference(p_input, &predicted_target, &probabilities);

    if (outputs_num > 0)
    {
        printf("Predicted target %d with probability %f\r\n", predicted_target, probabilities[predicted_target]);

        printf("All probabilities:\r\n");
        for (size_t i = 0; i < outputs_num; i++)
            printf("%f," probabilities[i]);
    }
}
Map predicted results on the required values (for Classification task type)

Inference results are encoded (0…n). For mapping on your classes, use dictionaries binary_target_dict_csv.csv / multi_target_dict_csv.csv.

Additional solution information API

You can use the following API to get solution information:

  • neuton_nn_solution_id_str - Get solution ID in string format;
  • neuton_nn_uniq_inputs_num - Get number of unique input features on which the model was trained;
  • neuton_nn_input_window_size - Get input features window size in feature samples(vectors);
  • neuton_nn_model_neurons_num - Get number of model neurons;
  • neuton_nn_model_weights_num - Get number of model weights;
  • neuton_nn_model_outputs_num - Get number of model outputs (predicted targets);
  • neuton_nn_model_task - Get model task : NEUTON_NN_TASK_MULT_CLASS, NEUTON_NN_TASK_BIN_CLASS, NEUTON_NN_TASK_REGRESSION
  • neuton_nn_model_size - Get model size in bytes (flash usage)
  • neuton_nn_model_bitdepth - Get model bit depth (8/16/32 bit)
  • neuton_nn_input_scaling - Get solution input scaling type: NEUTON_NN_INPUT_SCALING_UNIFIED, NEUTON_NN_INPUT_SCALING_UNIQUE
Audio preprocessing and prediction

Audio preprocessing is not integrated into the common Neuton pipeline, but we provide a set of algorithms and an external audio frontend for possible integration. You can find audio Keyword Spotting frontend in the pipeline/kws/neuton_kws_frontend.h.
Here is a code example of audio preprocessing with Neuton:


#include <neuton/neuton.h>
#include <neuton_generated/neuton_user_data_prep_config.h>
#include <pipeline/kws/neuton_kws_frontend.h>
#include <string.h>

static neuton_kws_frontend_ctx_t* kws_frontend = NULL;

static void on_spectrum_ready(void* p_ctx, neuton_f32_t* p_spectrum)
{
    neuton_kws_frontend_ctx_t* p_kws = (neuton_kws_frontend_ctx_t*)p_ctx;
    neuton_inference_input_t* p_input;

    p_input = neuton_nn_feed_inputs(p_spectrum, p_kws->melspectr.freq_bands * p_kws->melspectr.time_bands);

    if (p_input != NULL)
    {
        neuton_u16_t predicted_target;
        neuton_output_t* probabilities;
        neuton_i16_t outputs_num = neuton_nn_run_inference(p_input, &predicted_target, &probabilities);

        if (outputs_num > 0)
        {
            printf("Predicted class %d with probability %f\r\n", predicted_target, probabilities[predicted_target]);
        }
    }
}

bool init_audio_frontend(void)
{
    kws_frontend = malloc(sizeof(neuton_kws_frontend_ctx_t));

    neuton_status_t res = neuton_kws_frontend_init(kws_frontend, NEUTON_DSP_AUDIO_WINDOW_LENGTH,
                                                NEUTON_DSP_AUDIO_WINDOW_HOP,
                                                NEUTON_DSP_AUDIO_SAMPLING_RATE_HZ,
                                                NEUTON_DSP_MELSPECTROGRAM_TIME_BANDS,
                                                NEUTON_DSP_MELSPECTROGRAM_FREQ_BANDS,
                                                0, NULL, on_spectrum_ready, kws_frontend);
    return (res == NEUTON_STATUS_SUCCESS);
}

void feed_audio_samples(const float* p_audio_samples, size_t samples_num)
{
    neuton_kws_frontend_process(kws_frontend, p_audio_samples, samples_num);
}



Read more
Stay updated, join the community
slack