Code Monkey home page Code Monkey logo

intel-pattern-matching-technology's Introduction

DISCONTINUATION OF PROJECT.

This project will no longer be maintained by Intel.

Intel has ceased development and contributions including, but not limited to, maintenance, bug fixes, new releases, or updates, to this project.

Intel no longer accepts patches to this project.

If you have an ongoing need to use this project, are interested in independently developing it, or would like to maintain patches for the open source software community, please create your own fork of this project. Table of Contents

Intel® Pattern Matching Technology

This repository contains the CuriePME library, which provides access to the Pattern Matching Engine (PME) within the Intel® Curie™ Compute Module.

Supported Curie™ hardware platforms:

Development Environments

This library can be used in the following development environments:

  • On Ubuntu 14.04 LTS or 16.04 LTS, using the latest version of the Curie Open Developer Kit

  • In the Arduino IDE ("Download as a ZIP", unzip, place inside your libraries folder)

About the Library

the PME is a hardware engine capable of learning and recognizing patterns in arbitrary sets of data. The CuriePME library provides access to the PME, making it possible to implement machine-learning pattern matching or classification algorithms which are accelerated by the pattern-matching capabilities of the PME.

  • Basic Functions Supported:
    • Learning Patterns
    • Recognizing Patterns
    • Storing Pattern Memory (Knowledge) [Requires SerialFlash Library]
    • Retrieving Pattern Memory (Knowledge) [Requires SerialFlash Library]

About the Intel® Curie™ Pattern Matching Engine

The Pattern Matching Engine (PME) is a parallel data recognition engine with the following features:

  • 128 parallel Processing Elements (PE) each with"

    • 128 byte input vector

    • 128 byte model memory.

    • 8-Bit Arithmetic Units

    • Two distance evaluation norms with 16-bit resolution:

      • L1 norm (Manhattan Distance)
      • Lsup (Supremum) norm (Chebyshev Distance)
    • Support for up to 32,768 Categories

    • Classification states:

       * ID  - Identified
       * UNC - Uncertain
       * UNK - Unknown
      
  • Two Classification Functions:

    • k-nearest neighbors (KNN)
    • Radial Basis Function (RBF)
  • Support for up to 127 Contexts

CuriePME API reference

Constants

  • CuriePME.noMatch (uint32_t): The value returned by classify() to indicate a pattern could not be classified
  • CuriePME.minContext (uint16_t): Minimum context value
  • CuriePME.maxContext (uint16_t): Maximum context value
  • CuriePME.maxVectorSize (int32_t): Maximum pattern size (in bytes) that can be accepted by learn() and classify()
  • CuriePME.firstNeuronID (int32_t): ID of first neuron in network
  • CuriePME.lastNeuronID (int32_t): ID of last neuron in network
  • CuriePME.maxNeurons (int32_t): Number of neurons in the network

Initialization Functions

CuriePME.begin()

void CuriePME.begin(void)

Initialize the PME so it is ready for operation

Parameters

none

Return value

none

CuriePME.forget()

void CuriePME.forget(void)

Clear any data committed to the network, making the network ready to learn again.

Parameters

none

Return value

none

Basic Functions

CuriePME.learn()

uint16_t CuriePME.learn(uint8_t *pattern_vector, int32_t vector_length, uint8_t category)

Takes a pattern pattern_vector of size vector_length, and commits it to the network as training data. The category parameter indicates to the PME which category this training vector belongs to- that is, if a future input has a sufficiently similar pattern, it will be classified as the same category passed with this pattern.

Parameters

  1. uint8_t *pattern_vector : Pointer to the training data. Training data must be no longer than 128 bytes
  2. int32_t vector_length : The size (in bytes) of your training vector
  3. uint8_t category : The category that should be assigned to this data

Return value

Total number of committed neurons in the network after the learning operation is complete

CuriePME.classify()

uint16_t CuriePME.classify(uint8_t *pattern_vector, int32_t vector_length)

Takes a pattern pattern_vector of size vector_length, and uses the committed neurons in the network to classify the pattern

Parameters

  1. uint8_t *pattern_vector : Pointer to the data to be classified. Pattern data must be no longer than 128 bytes
  2. int32_t vector_length : The size (in bytes) of the data to be classified

Return value

CuriePME.noMatch if the input data did not match any of the trained categories. Otherwise, the trained category assigned by the network will be returned

Saving Knowledge

CuriePME.beginSaveMode()

void CuriePME.beginSaveMode(void)

Puts the network into a state that allows the neuron contents to be read

Parameters

none

Return value

none

CuriePME.iterateNeuronsToSave()

uint16_t CuriePME.iterateNeuronsToSave(neuronData& data_array)

When in save mode, this method can be called to obtain the data for the next committed neuron. Each successive call will increment an internal pointer and return the data for successive committed neurons, until all committed neurons have been read.

Parameters

  1. neuronData& data_array : a neuronData type in which the neuron data will be placed

Return value

0 when all committed neurons have been read. Otherwise, this method returns the trained category of the neuron being read

CuriePME.endSaveMode()

void CuriePME.endSaveMode(void)

Takes the network out of save mode

Parameters

none

Return value

none

Restoring Knowledge

CuriePME.beginRestoreMode()

void CuriePME.beginRestoreMode(void)

Puts the network into a state that allows the neuron contents to be restored from a file

Parameters

none

Return value

none

CuriePME.iterateNeuronsToRestore()

void CuriePME.iterateNeuronsToRestore(neuronData& data_array)

When in restore mode, this method can be called to write data to the next available neuron. Each successive call will increment an internal pointer until all the neurons in the network have been written.

Parameters

  1. neuronData& data_array : a neuronData type containing the neuron data

Return value

none

CuriePME.endRestoreMode()

void CuriePME.endRestoreMode(void)

Takes the network out of restore mode

Parameters

none

Return value

none

Configuraton Functions

CuriePME.setClassifierMode()

void CuriePME.setClassifierMode(PATTERN_MATCHING_CLASSIFICATION_MODE mode)

Sets the classifying function to be used by the network

Parameters

  1. PATTERN_MATCHING_CLASSIFICATION_MODE mode The classifying function to use. Valid values are:
    • RBF_Mode (default)
    • KNN_Mode

Return value

none

CuriePME.getClassifierMode()

PATTERN_MATCHING_CLASSIFICATION_MODE CuriePME.getClassifierMode(void)

Gets the classifying function being used by the network

Parameters

none

Return value

PATTERN_MATCHING_CLASSIFICATION_MODE mode The classifying function being used. Possible values are:

  • RBF_Mode
  • KNN_Mode

CuriePME.setDistanceMode()

void CuriePME.setDistanceMode(PATTERN_MATCHING_DISTANCE_MODE mode)

Sets the distance function to be used by the network

Parameters

  1. PATTERN_MATCHING_DISTANCE_MODE mode The distance function to use. Valid values are:

    • LSUP_Distance (default)
    • L1_Distance

Return value

none

CuriePME.getDistanceMode()

PATTERN_MATCHING_DISTANCE_MODE CuriePME.getDistanceMode(void)

Gets the distance function being used by the network

Parameters

none

Return value

PATTERN_MATCHING_DISTANCE_MODE mode The distance function being used. Possible values are:

  • LSUP_Distance
  • L1_Distance

CuriePME.setGlobalContext()

void CuriePME.setGlobalContext(uint16_t context)

Writes a value to the Global Context Register. Valid context values range between 1-127. A context value of 0 enables all neurons, with no regard to their context

Parameters

  1. uint16_t context : a value between 0-127 representing the desired context. A context value of 0 selects all neurons, regardless of their context value.

Return value

none

CuriePME.getGlobalContext()

uint16_t CuriePME.getGlobalContext(void)

Reads the Global Context Register

Parameters

none

Return value

uint16_t, the contents of the Global Context Register (a value between 0-127)

Other Functions

CuriePME.getCommittedCount()

uint16_t CuriePME.getCommittedCount(void)

Gets the number of committed neurons in the network (NOTE: this method should not be used in save/restore mode, because it will give inaccurate results)

Parameters

none

Return value

uint16_t, the number of comitted neurons in the network

CuriePME.readNeuron()

void CuriePME.readNeuron(int32_t neuronID, neuronData& data_array)

Read a specific neuron by its ID

Parameters

  1. int32_t neuronID : value between 1-128 representing a specific neuron
  2. neuronData& data_array : neuronData type in which to write the neuron data

Return value

none

CuriePME.writeVector() (KNN_Mode only)

uint16_t CuriePME.writeVector(uint8_t *pattern_vector, int32_t vector_length)

(Should only be used in KNN_Mode) Takes a pattern pattern_vector of size vector_length, and uses the committed neurons in the network to classify the pattern

Parameters

  1. uint8_t *pattern_vector : Pointer to the data to be classified. Pattern data must be no longer than 128 bytes
  2. int32_t vector_length : The size (in bytes) of the data to be classified

Return value

CuriePME.noMatch if the input data did not match any of the trained categories. Otherwise, the trained category assigned by the network will be returned

intel-pattern-matching-technology's People

Contributors

calvinatintel avatar eriknyquist avatar intel-larry avatar rdower avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

intel-pattern-matching-technology's Issues

Minor Bug in DrawingInTheAir Example

In function readVectorFromIMU()

Button HIGH and LOW have to be interchanged in the while loops

/* Wait until button is pressed */
while (digitalRead(buttonPin) == HIGH); -----> while (digitalRead(buttonPin) == LOW);

/* While button is being held... */
while (digitalRead(buttonPin) == LOW) --------> while (digitalRead(buttonPin) == HIGH)

This has to be done so that there is a wait until button is pressed

File Versions

Hi,

When doing a pull from one of the repo branches it is not possible to tell from looking at the source files which version one has. For example if I pull now, and a fix goes in, I have to look at my repo settings to ascertain if I have the fix. Is there any way the source files (.h and .cpp) can have a version Number of GUID in them ? At least it will be easy to see what version one has ?

ie

#define VERSION 1.0

Every time a commit is done, up the version. Then at least the docs can cross-reference the source versions ie Fix for Bug 231 is fixed in version 1.01 etc,.

Add constants for valid context range

can we have some either static const for valid context range (so I dont have to change my source if this changes in the firmware), or #defines (no type checking but pre-processor values so smaller program size).

//Should be inside the Intel header files
static const uint16_t MAX_CONTEXT = 127;
static const uint16_t MIN_CONTEXT = 1;

Or better still an inline with a constraint so their is no exception/error - just carry on with the program by forcing it valid

void alignContext()
{
NNContext = constrain(NNContext, MIN_CONTEXT, MAX_CONTEXT);
}

Thanks.

Marcus.

'class CurieIMUClass' has no member named 'accelDataReady'

@eriknyquist
I'm trying to experiment with the Draw I the Air example but after installing the PME library on Arduino IDE, compiling shows the error on

 while (digitalRead(buttonPin) == HIGH) {
        if (CurieIMU.accelDataReady()) {

            CurieIMU.readAccelerometer(raw[0], raw[1], raw[2]);

'class CurieIMUClass' has no member named 'accelDataReady'

Is that improper library installation?

False Positives in example DrawingInTheAir

In the example DrawingInTheAir, even if you don't move the board, there is a detection (at least a very high probability that something is detected even with very slightly similar movement). Hence the rate of false positives is very high.

To reduce the rate of false positives, a check should be done on the distance value from the register IDX_DIST. Hence a threshold can be set on the likelihood of detection, thereby considering any detection with a high IDX_DIST as a no_match.

I'm using a modified classify function like this:

uint16_t Intel_PMT::classify(uint8_t *pattern_vector, int32_t vector_length, uint16_t * dist)
{   
    uint8_t *current_vector = pattern_vector;
    uint8_t index = 0;
    if (vector_length > MaxVectorSize) return -1;    
    for (index = 0; index < (vector_length - 1); index++)
    {
        regWrite16(COMP, current_vector[index]);
    }
    regWrite16( LCOMP , current_vector[vector_length - 1] );
    *dist = regRead16(IDX_DIST);
        
    return  ( regRead16(CAT) & CAT_CATEGORY);    
}

But i guess a CuriePME.getIDX_DIST();
after a call to classify should also work.

Error in example

byte getAverageSample(byte samples[], unsigned int num, unsigned int pos, unsigned int step)
{
unsigned int ret;

/* This is the number of samples that will be used to create each
 * average sample; i.e. all the skipped samples before and after
 * the current sample */
unsigned int size = step * 2;

/* Don't do any averaging, if we are at the beginning or end
 * of the sample window */
if (pos < (step * 3) || pos > (num * 3) - (step * 3)) {
    ret = samples[pos];
} else {
    ret = 0;
    pos -= (step * 3);

    /* Calculate the sum of 'step' samples before, and after,
     * the current sample */
    for (unsigned int i = 0; i < size; ++i) {
        ret += samples[pos - (3 * i)];    **// ERROR: I think this should be pos + (3*i) since you already decremented pos right before this.**   
    }

    ret /= size;
}

return (byte)ret;

}

CurieIMU.accelDataReady() not a function

In Arduino IDE 1.8.1 and Intel Curie Boards 1.0.7, I get the following error in Drawing in the Air:

Arduino: 1.8.1 (Mac OS X), Board: "Arduino/Genuino 101"

/DrawingInTheAir.ino: In function ‘void readVectorFromIMU(byte*)’:
DrawingInTheAir:172: error: ‘class CurieIMUClass’ has no member named ‘accelDataReady’
if (CurieIMU.accelDataReady()) {
^
exit status 1
‘class CurieIMUClass’ has no member named ‘accelDataReady’

Set GCR does not change GCR

Hi,

The global context is always set at 127, you can not change it, even when calling the setGlobalContext function. Doesnt matter if in KNN or RBF mode.

Marcus

Change Distance Mode - No effect

Hi,

I wrote a toggle function to switch distance modes, it has no effect, the model remains in the state it is in when intialised, in my case LSUP 👍

void printDistanceMode()
{
if (CuriePME.getDistanceMode() == Intel_PMT::PATTERN_MATCHING_DISTANCE_MODE::L1_Distance)
{
Serial.println("Current Distance mode is L1");
}
else
{
Serial.println("Current Distance mode is LSUP");
}
}

void toggleDistanceMode()
{
printDistanceMode();

if (CuriePME.getDistanceMode() == Intel_PMT::PATTERN_MATCHING_DISTANCE_MODE::L1_Distance)
{
	CuriePME.setDistanceMode(Intel_PMT::PATTERN_MATCHING_DISTANCE_MODE::LSUP_Distance);
	Serial.println("Set the NN to LSUP Distance");
}
else
{
	CuriePME.setDistanceMode(Intel_PMT::PATTERN_MATCHING_DISTANCE_MODE::L1_Distance);
	Serial.println("Set the NN to L1 Distance");
}

printDistanceMode();

}

static const int serialBAUD = 9600;

void setup()
{
//blah blah
Serial.begin(SerialBAUD);

while (!Serial);

delay(1000);

CuriePME.begin();

}

void loop()
{
toggleDistanceMode()
}

Calling the function setDistanceMode has no effect.

Marcus

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.