Code Monkey home page Code Monkey logo

epsilon's Introduction

Epsilon

Epsilon is a library with small functions for machine learning and statistics written in plain C. The functions are decoupled and well tested.

tests and examples

Motivation

Most machine learning focuses on training large models on powerful hardware. After training, researchers freeze the models and apply them to new data. These models are too big to run on microcontrollers. One can compress these models to make them fit. The compressed model can make predictions for new data. But the model itself remains static, even if the environment changes.

An alternative approach is to optimise the model on the microcontroller itself. In this case, the model can adapt to new data. This requires particular memory-efficient algorithms. Further, the optimization process should be reliable. Epsilon provides methods to train and apply machine learning methods on microcontrollers.

These algorithms should run on microcontrollers, such as the Raspberry Pi Pico, the BBC micro:bit, the Arduino Nano 33 BLE Sense or even the ATtiny85 8-bit microcontroller.

To allow machine learning to run on microcontrollers, the implementations:

  • do not use dynamic memory allocation if possible,
  • favour online over batch operation,
  • work with fixed-point math when realistic, and
  • are easy to tune.

Building

Epsilon uses CMake for building. Create a build directory, and configure the project. In the repository root, configure and build the project. Then run the unit tests and the examples with CTest:

$ mkdir build && cd build
$ cmake ..
$ cmake --build .
$ ctest

Algorithms

Pseudo-random number generation

  • Xorshift is a fast and simple pseudo-random number generator by George Marsaglia that has good statistical properties. See the xorshift example.

Hashing

Online statistics

Feature extraction

  • Fast Walsh-Hadamard transform (FWHT) implements the Walsh-Hardamard transform in O(n log n) time. The FWHT similar to the fast Fourier transform and the Haar transform. See the FWHT example.
  • Structured random orthogonal features (SORF). An O(d log d) transformation that can be used for a feature map that approximates a specific kernel. Here d is the number of input dimensions. Note that SORF is patented, and that compilation of SORF is disabled by default. Instead one can use a budgeted kernel classification or regression.

Regression

  • Online passive-aggressive (PA) regression solves a regression problem by only updating the model on prediction mistakes. When the target depends non-linearly on the inputs one can use a kernel that projects the input onto a set of support vectors. Kernel methods such as the support vector machine (SVM) work efficiently in high-dimensional feature spaces, but don't easily scale to large datasets. To scale to large datasets one can maintain a budget of support vectors. The example of budgeted kernel passive aggressive (BKPA) regression demonstrates how online, non-linear regression can be performed with a limited memory budget.

Classification

  • Kernel passive-aggressive classification (TODO).

Other solutions for Tiny ML or Edge AI

epsilon's People

Contributors

breuderink avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

epsilon's Issues

Can we efficiently use neural tangent kernel?

Can we use neural tangent kernel [1] to get the benefits of new neural net architectures while using the budgeted kernel machines? See also the paper on the path kernel [2].

The kernel needs to compute the dot product of the gradient of a neural network fed with two different inputs. Perhaps we can efficiently compute this dot product?

[1] Jacot, Arthur, Franck Gabriel, and Clément Hongler. "Neural tangent kernel: Convergence and generalization in neural networks." arXiv preprint arXiv:1806.07572 (2018).
[2] Domingos, Pedro M.. “Every Model Learned by Gradient Descent Is Approximately a Kernel Machine.” ArXiv abs/2012.00152 (2020): n. pag.

Implement BPA-NN variant for kernel budget maintenance.

Implement BPA-NN [1] for enhanced performance with budgeted kernel machines. With smart tracking the nearest neighbour can be found in O(1), leading to a total cost of O(B).

  1. Wang, Zhuang, and Slobodan Vucetic. "Online passive-aggressive algorithms on a budget." Proceedings of the Thirteenth International Conference on Artificial Intelligence and Statistics. JMLR Workshop and Conference Proceedings, 2010.

Implement one-class classification

Implement online passive-aggressive one-class classification. Novelty detection is the most straight-forward application for online learning on microcontrollers.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.