Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

Artificial Neural Networks made easy with the FANN library

, 28 Aug 2013 CPOL
Neural networks are typically associated with specialised applications, developed only by select groups of experts. This misconception has had a highly negative effect on its popularity. Hopefully, the FANN library will help fill this gap.
fann-1_2_0.zip
fann-1.2.0
debian
changelog
compat
control
copyright
docs
libfann1-dev.dirs
libfann1-dev.examples
libfann1-dev.files
libfann1-dev.install
libfann1.dirs
libfann1.files
libfann1.install
rules
doc
fann_doc_complete_1.0.pdf
Makefile
html
src
include
Makefile.in
Makefile.am
Makefile.in
COPYING
Makefile.am
win32_dll
examples
makefile
README
Makefile.in
configure
AUTHORS
COPYING
ChangeLog
INSTALL
Makefile.am
NEWS
TODO
aclocal.m4
config.guess
config.sub
configure.in
depcomp
fann.pc.in
fann.spec.in
install-sh
ltmain.sh
missing
mkinstalldirs
benchmarks
datasets
building.test
building.train
diabetes.test
diabetes.train
gene.test
gene.train
mushroom.test
mushroom.train
robot.test
robot.train
soybean.test
soybean.train
thyroid.test
thyroid.train
two-spiral.train
pumadyn-32fm.test
pumadyn-32fm.train
two-spiral.test
parity8.train
parity8.test
parity13.test
parity13.train
Makefile
README
benchmark.sh
benchmarks.pdf
gnuplot
performance.cc
quality.cc
.cvsignore
examples
Makefile
xor.data
python
README
examples
libfann.i
makefile.gnu
makefile.msvc
libfann.pyc
MSVC++
libfann.dsp
all.dsw
simple_test.dsp
simple_train.dsp
steepness_train.dsp
xor_test.dsp
xor_train.dsp
config.in
fann_win32_dll-1_2_0.zip
changelog
compat
control
copyright
docs
libfann1-dev.dirs
libfann1-dev.examples
libfann1-dev.files
libfann1-dev.install
libfann1.dirs
libfann1.files
libfann1.install
rules
fann_doc_complete_1.0.pdf
Makefile
Makefile.in
Makefile.am
Makefile.in
COPYING
Makefile.am
makefile
README
Makefile.in
configure
AUTHORS
COPYING
ChangeLog
INSTALL
Makefile.am
NEWS
TODO
aclocal.m4
config.guess
config.sub
configure.in
depcomp
fann.pc.in
fann.spec.in
install-sh
ltmain.sh
missing
mkinstalldirs
building.test
building.train
diabetes.test
diabetes.train
gene.test
gene.train
mushroom.test
mushroom.train
robot.test
robot.train
soybean.test
soybean.train
thyroid.test
thyroid.train
two-spiral.train
pumadyn-32fm.test
pumadyn-32fm.train
two-spiral.test
parity8.train
parity8.test
parity13.test
parity13.train
Makefile
README
benchmark.sh
benchmarks.pdf
gnuplot
performance.cc
quality.cc
.cvsignore
Makefile
xor.data
README
libfann.i
makefile.gnu
makefile.msvc
libfann.pyc
libfann.dsp
all.dsw
simple_test.dsp
simple_train.dsp
steepness_train.dsp
xor_test.dsp
xor_train.dsp
config.in
bin
fanndoubled.dll
fanndoubled.lib
fanndoubleMTd.dll
fanndoubleMTd.lib
fannfixedd.dll
fannfixedd.lib
fannfixedMTd.dll
fannfixedMTd.lib
fannfloatd.dll
fannfloatd.lib
fannfloatMTd.dll
fannfloatMTd.lib
fanndouble.dll
fanndouble.lib
fanndoubleMT.dll
fanndoubleMT.lib
fannfixed.dll
fannfixed.lib
fannfixedMT.dll
fannfixedMT.lib
fannfloat.dll
fannfloat.lib
fannfloatMT.dll
fannfloatMT.lib
vs_net2003.zip
VS.NET2003
/*       Parity Benchmark Data Set Generator
	 
	 v1.0
	 Matt White  (mwhite+@cmu.edu)
	 9/19/93

	 QUESTIONS/COMMENTS: neural-bench@cs.cmu.edu

	 Usage: a.out <# of inputs>
           # of inputs defaults to 2, or XOR.
	   Care should be taken not to input a number greater than the number
	   of bits, usually 32, of the machine being used, minus one.  Thus,
           for most computers, the maximum input is 31.
  
	 Description
	 ~~~~~~~~~~~
	   This program generates parity benchmark data in the CMU Neural 
         Network Benchmark format. 
*/ 

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <math.h>


/*      Function Prototypes      */

void getCommandLine ( int *, int, char ** );
void printHeader    ( int );
void printSet       ( int );


int main  ( int argc, char **argv )
{
  int inputs;    /* Number of inputs into the neural network */   

  getCommandLine ( &inputs, argc, argv );
  printHeader    ( inputs );
  printSet       ( inputs );
}


/*      getCommandLine -  This function reads the values from the command line
	and interprets them.  The only argument should be the number of inputs
        to generate, which defaults to 2.  Extra arguments are ignored.
        Invalid arguments are flagged and an error is produced.
*/

void getCommandLine  ( int *inputs, int argc, char **argv )
{
  if  ( argc < 2 )
    *inputs = 2;
  else  
    if  ( ( **(argv+1) >= '0' ) && ( **(argv+1) <= '9' ) )
      *inputs = atoi( *(argv+1) );
    else  {
      fprintf (stderr, "Invalid argument: %s\n",*(argv+1));
      fprintf (stderr, "Value should be an integer.\n");
      exit( 1 );
    }
}


/*      printHeader -  This function prints out the header information for the
	data set.  This includes generation time (local) and number of inputs.
	It also prints the $SETUP segment for the data set.
*/

void printHeader ( int inputs )
{
  unsigned int num_points;

  num_points = pow(2,inputs);
  
  printf("%d %d 1\n", num_points, inputs);
}


/*      printSet -  Generates and prints out a data set having the specified
	number of inputs.
*/

void printSet  ( int inputs )  
{
	unsigned int num_points,  /* Number of points of data to generate */
		num_pos,     /* Number of positive bits in this number */
		this_point,  /* Number being analyzed */
		i,	    /* General indexing variables */
		j;

	num_points = pow(2,inputs);	/* Figure out how many points to generate */

	for  ( i = 0 ; i < num_points ; i++ )  {
		num_pos = 0;
		this_point = i;
		for  ( j = 0 ; j < inputs ; j++ )  {	/* Analyze the number */
			if  ( (this_point & 1) == 1 )  {		/* Get a bit and use it */
				printf ("1 ");
				num_pos++;
			} else
				printf ("-1 ");
			this_point >>= 1;				/* Shift to the next bit */
		}

		if  ( (num_pos % 2) == 1 )			/* Print the expected output */
			printf  ("1\n");
		else
			printf  ("0\n"); 
	}  
}





By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Software Developer's Journal
Publisher
Poland Poland
Software Developer's Journal (formerly Software 2.0) is a magazine for professional programmers and developers publishing news from the software world and practical articles presenting very interesting ready programming solutions. To read more

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.1411023.1 | Last Updated 28 Aug 2013
Article Copyright 2006 by Software Developer's Journal
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid