Skip to content

Micro Artificial Neural Network is a minimalist ANN library to implement AI in microcontrollers

License

Notifications You must be signed in to change notification settings

josepablo134/microANN

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

microANN

Micro Artificial Neural Network is a minimalist ANN library to implement AI in microcontrollers

This is work in progress.

Requirements

uANN requires dynamic memory, not all the microcontrollers have any heap implemented on its standard library, thats why this project assumes that is not available and uses uHeap (micro heap) as dependency.

Example of use

#include "uANN.h"
#include "uANN_config.h"

#include <stdio.h>
	
void example(){
	struct ann_net*		ann;
	struct ann_layer*	layer;
	const float	input[2] = {1.0, 1.0};
	float	output;

	///	Initialize and clear private pointers
	ann_init();

	ann = ann_net_create();
	layer = ann_layer_create();

	///	Setting layer properties
	layer->inputLen = 2;
	layer->neurons  = 1;
	layer->activation = ann_sigmoid;

	///	Pushing new layer over last layer
	if( ann_net_push( ann , layer ) < 0 ){
		fprintf( stderr , "This layer is not compatible with last layer" );
	}

	///	Allocating memory for each layer
	if( ann_alloc( ann ) < 0 ){
		fprintf( stdout , "This neural netowork requires memory not available" );
	}

	///	Setting weights and bias
	layer->_weightHolder[0] = 0.85;
	layer->_weightHolder[1] = 0.85;

	layer->_biasHolder[0] = 0.0;

	///	Setting input vector
	layer->_inputHolder[0] = input[0];
	layer->_inputHolder[1] = input[1];

	///	Propagate through neural network
	ann_compute( ann );

	///	The output of the neural network is now available
	output = layer->_outputHolder[0];
	fprintf( stdout, "AND Gate example: \n");
	fprintf( stdout, "Input: [%f] [%f]\n", input[0], input[1]);
	fprintf( stdout, "result: %f\n", output );
}

int main( int argc, char* argv[] ){
	example();	
	return 0;
}

About

Micro Artificial Neural Network is a minimalist ANN library to implement AI in microcontrollers

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published