Click here to Skip to main content
Click here to Skip to main content

Artificial Neural Networks made easy with the FANN library

By , 16 Feb 2006
 
fann-1_2_0.zip
fann-1.2.0
aclocal.m4
AUTHORS
benchmarks
.cvsignore
benchmark.sh
benchmarks.pdf
datasets
building.test
building.train
diabetes.test
diabetes.train
gene.test
gene.train
mushroom.test
mushroom.train
parity13.test
parity13.train
parity8.test
parity8.train
pumadyn-32fm.test
pumadyn-32fm.train
robot.test
robot.train
soybean.test
soybean.train
thyroid.test
thyroid.train
two-spiral.test
two-spiral.train
gnuplot
Makefile
performance.cc
quality.cc
README
ChangeLog
config.guess
config.in
config.sub
configure
configure.in
COPYING
debian
changelog
compat
control
copyright
docs
libfann1.dirs
libfann1.files
libfann1.install
libfann1-dev.dirs
libfann1-dev.examples
libfann1-dev.files
libfann1-dev.install
rules
depcomp
doc
fann_doc_complete_1.0.pdf
html
Makefile
examples
Makefile
xor.data
fann.pc.in
fann.spec.in
INSTALL
install-sh
ltmain.sh
Makefile.am
Makefile.in
missing
mkinstalldirs
MSVC++
all.dsw
libfann.dsp
simple_test.dsp
simple_train.dsp
steepness_train.dsp
xor_test.dsp
xor_train.dsp
NEWS
python
examples
libfann.i
libfann.pyc
makefile.gnu
makefile.msvc
README
README
src
COPYING
include
Makefile.am
Makefile.in
Makefile.am
Makefile.in
TODO
win32_dll
examples
makefile
fann_win32_dll-1_2_0.zip
aclocal.m4
AUTHORS
.cvsignore
benchmark.sh
benchmarks.pdf
building.test
building.train
diabetes.test
diabetes.train
gene.test
gene.train
mushroom.test
mushroom.train
parity13.test
parity13.train
parity8.test
parity8.train
pumadyn-32fm.test
pumadyn-32fm.train
robot.test
robot.train
soybean.test
soybean.train
thyroid.test
thyroid.train
two-spiral.test
two-spiral.train
gnuplot
Makefile
performance.cc
quality.cc
README
ChangeLog
config.guess
config.in
config.sub
configure
configure.in
COPYING
changelog
compat
control
copyright
docs
libfann1.dirs
libfann1.files
libfann1.install
libfann1-dev.dirs
libfann1-dev.examples
libfann1-dev.files
libfann1-dev.install
rules
depcomp
fann_doc_complete_1.0.pdf
Makefile
Makefile
xor.data
fann.pc.in
fann.spec.in
INSTALL
install-sh
ltmain.sh
Makefile.am
Makefile.in
missing
mkinstalldirs
all.dsw
libfann.dsp
simple_test.dsp
simple_train.dsp
steepness_train.dsp
xor_test.dsp
xor_train.dsp
NEWS
libfann.i
libfann.pyc
makefile.gnu
makefile.msvc
README
README
COPYING
Makefile.am
Makefile.in
Makefile.am
Makefile.in
TODO
bin
fanndouble.dll
fanndouble.lib
fanndoubled.dll
fanndoubled.lib
fanndoubleMT.dll
fanndoubleMT.lib
fanndoubleMTd.dll
fanndoubleMTd.lib
fannfixed.dll
fannfixed.lib
fannfixedd.dll
fannfixedd.lib
fannfixedMT.dll
fannfixedMT.lib
fannfixedMTd.dll
fannfixedMTd.lib
fannfloat.dll
fannfloat.lib
fannfloatd.dll
fannfloatd.lib
fannfloatMT.dll
fannfloatMT.lib
fannfloatMTd.dll
fannfloatMTd.lib
makefile
vs_net2003.zip
VS.NET2003
/*
Fast Artificial Neural Network Library (fann)
Copyright (C) 2003 Steffen Nissen (lukesky@diku.dk)

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/

#include <stdio.h>

#include "fann.h"

int main()
{
	fann_type *calc_out;
	unsigned int i;
	int ret = 0;

	struct fann *ann;
	struct fann_train_data *data;

	printf("Creating network.\n");

#ifdef FIXEDFANN
	ann = fann_create_from_file("xor_fixed.net");
#else
	ann = fann_create_from_file("xor_float.net");
#endif
	
	if(!ann){
		printf("Error creating ann --- ABORTING.\n");
		return 0;
	}

	printf("Testing network.\n");

#ifdef FIXEDFANN
	data = fann_read_train_from_file("xor_fixed.data");
#else
	data = fann_read_train_from_file("xor.data");
#endif

	for(i = 0; i < data->num_data; i++){
		fann_reset_MSE(ann);
		calc_out = fann_test(ann, data->input[i], data->output[i]);
#ifdef FIXEDFANN
		printf("XOR test (%d, %d) -> %d, should be %d, difference=%f\n",
		data->input[i][0], data->input[i][1], *calc_out, data->output[i][0], (float)fann_abs(*calc_out - data->output[i][0])/fann_get_multiplier(ann));

		if((float)fann_abs(*calc_out - data->output[i][0])/fann_get_multiplier(ann) > 0.2){
			printf("Test failed\n");
			ret = -1;
		}
#else
		printf("XOR test (%f, %f) -> %f, should be %f, difference=%f\n",
		data->input[i][0], data->input[i][1], *calc_out, data->output[i][0], (float)fann_abs(*calc_out - data->output[i][0]));
#endif
	}

	printf("Cleaning up.\n");
	fann_destroy_train(data);
	fann_destroy(ann);

	return ret;
}

By viewing downloads associated with this article you agree to the Terms of use 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 has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Software Developer's Journal
Publisher
Poland Poland
Member
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

Permalink | Advertise | Privacy | Mobile
Web02 | 2.6.130516.1 | Last Updated 16 Feb 2006
Article Copyright 2006 by Software Developer's Journal
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid