[libfann] 194/242: code cleanup and comments

Christian Kastner chrisk-guest at moszumanska.debian.org
Sat Oct 4 21:10:43 UTC 2014


This is an automated email from the git hooks/post-receive script.

chrisk-guest pushed a commit to tag Version2_0_0
in repository libfann.

commit b0f2942aebf4eee3a9ee2fd73f3862b61012b165
Author: Steffen Nissen <lukesky at diku.dk>
Date:   Thu Sep 22 22:48:08 2005 +0000

    code cleanup and comments
---
 doc/fixedpointusage.txt       | 156 ++++++++++
 examples/cascade_train.c      |   3 +-
 examples/mushroom.c           |   4 +-
 examples/robot.c              |   4 +-
 examples/simple_train.c       |   5 +-
 examples/steepness_train.c    |   5 +-
 examples/xor_train.c          |   5 +-
 fann.prj                      |   2 -
 src/Makefile.am               |   2 +-
 src/Makefile.in               |   7 +-
 src/doublefann.c              |   1 +
 src/fann.c                    | 111 ++++---
 src/fann_cascade.c            |   6 +-
 src/fann_error.c              |   2 -
 src/fann_io.c                 |   7 +-
 src/fann_train.c              |   2 +-
 src/fann_train_data.c         |   1 -
 src/fixedfann.c               |   1 +
 src/floatfann.c               |   1 +
 src/include/Makefile.am       |   2 +-
 src/include/Makefile.in       |   2 +-
 src/include/fann.h            | 670 ++++++++++++++++++++++++++----------------
 src/include/fann_activation.h | 122 --------
 src/include/fann_cascade.h    |   4 +-
 src/include/fann_data.h       | 256 ++++++++++++++--
 src/include/fann_errno.h      |  86 ------
 src/include/fann_error.h      |  52 +++-
 src/include/fann_internal.h   |   3 +-
 src/include/fann_io.h         |   4 +-
 src/include/fann_train.h      | 207 ++++++++++++-
 30 files changed, 1145 insertions(+), 588 deletions(-)

diff --git a/doc/fixedpointusage.txt b/doc/fixedpointusage.txt
new file mode 100644
index 0000000..d31b91f
--- /dev/null
+++ b/doc/fixedpointusage.txt
@@ -0,0 +1,156 @@
+Section: Fixed Point Usage
+
+It is possible to run the ANN with fixed point numbers (internally represented as integers). This option is only intended for use on computers with no floating point processor, for example, the iPAQ or other embedded devices.
+
+Topic: Training a Fixed Point ANN
+
+The ANN cannot be trained in fixed point, which is why the training part is basically the same as for floating point numbers. The only difference is that you should save the ANN as fixed point. This is done by the <fann_save_to_fixed> function. This function saves a fixed point version of the ANN, but it also does some analysis, in order to find out where the decimal point should be. The result of this analysis is returned from the function.
+
+The decimal point returned from the function is an indicator of, how many bits is used for the fractional part of the fixed point numbers. If this number is negative, there will most likely be integer overflow when running the library with fixed point numbers and this should be avoided. Furthermore, if the decimal point is too low (e.g. lower than 5), it is probably not a good idea to use the fixed point version.
+
+Please note, that the inputs to networks that should be used in fixed point should be between -1 and 1.
+
+An example of a program written to support training in both fixed point and floating point numbers:
+
+(code)
+#include <time.h>
+#include <sys/time.h>
+#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[0], data->output[i][0],
+			   (float) fann_abs(calc_out[0] - data->output[i][0]) / fann_get_multiplier(ann));
+
+		if((float) fann_abs(*calc_out - data->output[i][0]) / fann_get_multiplier(ann) > 0.1)
+		{
+			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;
+}
+(end)
+	
+
+Topic: Running a Fixed Point ANN
+
+Running a fixed point ANN is done much like running an ordinary ANN. The difference is that the inputs and outputs should be in fixed point representation. Furthermore the inputs should be restricted to be between -multiplier and multiplier to avoid integer overflow, where the multiplier is the value returned from <fann_get_multiplier>. This multiplier is the value that a floating point number should be multiplied with, in order to be a fixed point number, likewise the output of the ANN  [...]
+
+To help using fixed point numbers, another function is provided. <fann_get_decimal_point> which returns the decimal point. The decimal point is the position dividing the integer and fractional part of the fixed point number and is useful for doing operations on the fixed point inputs and outputs.
+
+An example of a program written to support both fixed point and floating point numbers:
+
+(code)
+#include <time.h>
+#include <sys/time.h>
+#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.1){
+			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;
+}
+(end)
+	
+
+Topic: Precision of a Fixed Point ANN
+
+The fixed point ANN is not as precise as a floating point ANN, furthermore it approximates the sigmoid function by a stepwise linear function. Therefore, it is always a good idea to test the fixed point ANN after loading it from a file. This can be done by calculating the mean square error as described earlier. There is, however, one problem with this approach: The training data stored in the file is in floating point format. Therefore, it is possible to save this data in a fixed point f [...]
diff --git a/examples/cascade_train.c b/examples/cascade_train.c
index 0e38b41..6353620 100644
--- a/examples/cascade_train.c
+++ b/examples/cascade_train.c
@@ -42,7 +42,6 @@ int print_callback(unsigned int epochs, float error)
 
 int main()
 {
-	const float learning_rate = (const float) 0.7;
 	const float desired_error = (const float) 0.00001;
 	unsigned int max_neurons = 40;
 	unsigned int neurons_between_reports = 1;
@@ -96,7 +95,7 @@ int main()
 
 	printf("Creating network.\n");
 
-	ann = fann_create_shortcut(learning_rate, 2, train_data->num_input, train_data->num_output);
+	ann = fann_create_shortcut(2, train_data->num_input, train_data->num_output);
 
 	fann_set_training_algorithm(ann, FANN_TRAIN_BATCH);
 	fann_set_training_algorithm(ann, FANN_TRAIN_QUICKPROP);
diff --git a/examples/mushroom.c b/examples/mushroom.c
index 4962f7c..8bc6324 100644
--- a/examples/mushroom.c
+++ b/examples/mushroom.c
@@ -29,8 +29,6 @@ int print_callback(unsigned int epochs, float error)
 
 int main()
 {
-	const float connection_rate = 1;
-	const float learning_rate = (const float) 0.7;
 	const unsigned int num_layers = 3;
 	const unsigned int num_neurons_hidden = 32;
 	const float desired_error = (const float) 0.0001;
@@ -45,7 +43,7 @@ int main()
 
 	train_data = fann_read_train_from_file("../benchmarks/datasets/mushroom.train");
 
-	ann = fann_create(connection_rate, learning_rate, num_layers,
+	ann = fann_create_standard(num_layers,
 					  train_data->num_input, num_neurons_hidden, train_data->num_output);
 
 	printf("Training network.\n");
diff --git a/examples/robot.c b/examples/robot.c
index 76db8a8..17e743c 100644
--- a/examples/robot.c
+++ b/examples/robot.c
@@ -29,8 +29,6 @@ int print_callback(unsigned int epochs, float error)
 
 int main()
 {
-	const float connection_rate = 1;
-	const float learning_rate = (const float) 0.7;
 	const unsigned int num_layers = 3;
 	const unsigned int num_neurons_hidden = 96;
 	const float desired_error = (const float) 0.001;
@@ -43,7 +41,7 @@ int main()
 
 	train_data = fann_read_train_from_file("../benchmarks/datasets/robot.train");
 
-	ann = fann_create(connection_rate, learning_rate, num_layers,
+	ann = fann_create_standard(num_layers,
 					  train_data->num_input, num_neurons_hidden, train_data->num_output);
 
 	printf("Training network.\n");
diff --git a/examples/simple_train.c b/examples/simple_train.c
index bdd8321..910c4d9 100644
--- a/examples/simple_train.c
+++ b/examples/simple_train.c
@@ -21,8 +21,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
 int main()
 {
-	const float connection_rate = 1;
-	const float learning_rate = (const float) 0.7;
 	const unsigned int num_input = 2;
 	const unsigned int num_output = 1;
 	const unsigned int num_layers = 3;
@@ -31,8 +29,7 @@ int main()
 	const unsigned int max_iterations = 500000;
 	const unsigned int iterations_between_reports = 1000;
 
-	struct fann *ann = fann_create(connection_rate, learning_rate, num_layers,
-								   num_input, num_neurons_hidden, num_output);
+	struct fann *ann = fann_create_standard(num_layers, num_input, num_neurons_hidden, num_output);
 
 	fann_set_activation_function_hidden(ann, FANN_SIGMOID_SYMMETRIC);
 	fann_set_activation_function_output(ann, FANN_SIGMOID_SYMMETRIC);
diff --git a/examples/steepness_train.c b/examples/steepness_train.c
index 2ebc04b..50a1890 100644
--- a/examples/steepness_train.c
+++ b/examples/steepness_train.c
@@ -69,8 +69,6 @@ void train_on_steepness_file(struct fann *ann, char *filename,
 
 int main()
 {
-	const float connection_rate = 1;
-	const float learning_rate = (const float) 0.7;
 	const unsigned int num_input = 2;
 	const unsigned int num_output = 1;
 	const unsigned int num_layers = 3;
@@ -83,8 +81,7 @@ int main()
 
 	struct fann_train_data *data;
 
-	struct fann *ann = fann_create(connection_rate,
-								   learning_rate, num_layers,
+	struct fann *ann = fann_create_standard(num_layers,
 								   num_input, num_neurons_hidden, num_output);
 
 	data = fann_read_train_from_file("xor.data");
diff --git a/examples/xor_train.c b/examples/xor_train.c
index bd204d7..7f84b2d 100644
--- a/examples/xor_train.c
+++ b/examples/xor_train.c
@@ -30,8 +30,6 @@ int print_callback(unsigned int epochs, float error)
 int main()
 {
 	fann_type *calc_out;
-	const float connection_rate = 1;
-	const float learning_rate = (const float) 0.7;
 	const unsigned int num_input = 2;
 	const unsigned int num_output = 1;
 	const unsigned int num_layers = 3;
@@ -47,8 +45,7 @@ int main()
 
 	printf("Creating network.\n");
 
-	ann = fann_create(connection_rate, learning_rate, num_layers,
-					  num_input, num_neurons_hidden, num_output);
+	ann = fann_create_standard(num_layers, num_input, num_neurons_hidden, num_output);
 
 	printf("Training network.\n");
 
diff --git a/fann.prj b/fann.prj
index 41dd998..00585eb 100644
--- a/fann.prj
+++ b/fann.prj
@@ -82,7 +82,6 @@ module.include.files=\
 	src/include/fann_cascade.h\
 	src/include/fann_error.h\
 	src/include/fann_io.h\
-	src/include/fann_options.h\
 	src/include/fann_train.h\
 	src/include/fann_train_data.h
 
@@ -108,7 +107,6 @@ module.source.files=\
 	src/fann.c\
 	src/fann_error.c\
 	src/fann_io.c\
-	src/fann_options.c\
 	src/fann_train.c\
 	src/fann_train_data.c\
 	src/fixedfann.c\
diff --git a/src/Makefile.am b/src/Makefile.am
index ab7dc28..b893aaf 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -8,4 +8,4 @@ AM_CFLAGS = -D_REENTRANT
 libfloatfann_la_SOURCES = floatfann.c
 libdoublefann_la_SOURCES = doublefann.c
 libfixedfann_la_SOURCES = fixedfann.c
-libfann_la_SOURCES = fann.c fann_io.c fann_train.c fann_train_data.c fann_options.c fann_error.c fann_cascade.c
+libfann_la_SOURCES = fann.c fann_io.c fann_train.c fann_train_data.c fann_error.c fann_cascade.c
diff --git a/src/Makefile.in b/src/Makefile.in
index 8ae8dde..d163b0c 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -139,7 +139,7 @@ AM_CFLAGS = -D_REENTRANT
 libfloatfann_la_SOURCES = floatfann.c
 libdoublefann_la_SOURCES = doublefann.c
 libfixedfann_la_SOURCES = fixedfann.c
-libfann_la_SOURCES = fann.c fann_io.c fann_train.c fann_train_data.c fann_options.c fann_error.c fann_cascade.c
+libfann_la_SOURCES = fann.c fann_io.c fann_train.c fann_train_data.c fann_error.c fann_cascade.c
 subdir = src
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
@@ -154,8 +154,7 @@ libdoublefann_la_OBJECTS = $(am_libdoublefann_la_OBJECTS)
 libfann_la_LDFLAGS =
 libfann_la_LIBADD =
 am_libfann_la_OBJECTS = fann.lo fann_io.lo fann_train.lo \
-	fann_train_data.lo fann_options.lo fann_error.lo \
-	fann_cascade.lo
+	fann_train_data.lo fann_error.lo fann_cascade.lo
 libfann_la_OBJECTS = $(am_libfann_la_OBJECTS)
 libfixedfann_la_LDFLAGS =
 libfixedfann_la_LIBADD =
@@ -172,7 +171,6 @@ am__depfiles_maybe = depfiles
 @AMDEP_TRUE at DEP_FILES = ./$(DEPDIR)/doublefann.Plo ./$(DEPDIR)/fann.Plo \
 @AMDEP_TRUE@	./$(DEPDIR)/fann_cascade.Plo \
 @AMDEP_TRUE@	./$(DEPDIR)/fann_error.Plo ./$(DEPDIR)/fann_io.Plo \
- at AMDEP_TRUE@	./$(DEPDIR)/fann_options.Plo \
 @AMDEP_TRUE@	./$(DEPDIR)/fann_train.Plo \
 @AMDEP_TRUE@	./$(DEPDIR)/fann_train_data.Plo \
 @AMDEP_TRUE@	./$(DEPDIR)/fixedfann.Plo ./$(DEPDIR)/floatfann.Plo
@@ -252,7 +250,6 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/fann_cascade.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/fann_error.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/fann_io.Plo at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/fann_options.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/fann_train.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/fann_train_data.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/fixedfann.Plo at am__quote@
diff --git a/src/doublefann.c b/src/doublefann.c
index e7f9e77..af011cd 100644
--- a/src/doublefann.c
+++ b/src/doublefann.c
@@ -19,6 +19,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
 /* Easy way to allow for build of multiple binaries */
 
+#include "config.h"
 #include "doublefann.h"
 
 #include "fann.c"
diff --git a/src/fann.c b/src/fann.c
index d7823a3..ac2f6b3 100644
--- a/src/fann.c
+++ b/src/fann.c
@@ -26,12 +26,8 @@
 
 #include "config.h"
 #include "fann.h"
-#include "fann_errno.h"
 
-/* create a neural network.
- */
-FANN_EXTERNAL struct fann *FANN_API fann_create(float connection_rate, float learning_rate, unsigned int num_layers,	/* the number of layers, including the input and output layer */
-												...)	/* the number of neurons in each of the layers, starting with the input layer and ending with the output layer */
+FANN_EXTERNAL struct fann *FANN_API fann_create_standard(unsigned int num_layers, ...)
 {
 	struct fann *ann;
 	va_list layer_sizes;
@@ -51,17 +47,50 @@ FANN_EXTERNAL struct fann *FANN_API fann_create(float connection_rate, float lea
 	}
 	va_end(layer_sizes);
 
-	ann = fann_create_array(connection_rate, learning_rate, num_layers, layers);
+	ann = fann_create_standard_array(num_layers, layers);
 
 	free(layers);
 
 	return ann;
 }
 
-/* create a neural network.
- */
-FANN_EXTERNAL struct fann *FANN_API fann_create_array(float connection_rate, float learning_rate,
-													  unsigned int num_layers, unsigned int *layers)
+FANN_EXTERNAL struct fann *FANN_API fann_create_standard_array(unsigned int num_layers, 
+															   unsigned int *layers)
+{
+	return fann_create_sparse_array(1, num_layers, layers);	
+}
+
+FANN_EXTERNAL struct fann *FANN_API fann_create_sparse(float connection_rate, 
+													   unsigned int num_layers, ...)
+{
+	struct fann *ann;
+	va_list layer_sizes;
+	int i;
+	unsigned int *layers = (unsigned int *) calloc(num_layers, sizeof(unsigned int));
+
+	if(layers == NULL)
+	{
+		fann_error(NULL, FANN_E_CANT_ALLOCATE_MEM);
+		return NULL;
+	}
+
+	va_start(layer_sizes, num_layers);
+	for(i = 0; i < (int) num_layers; i++)
+	{
+		layers[i] = va_arg(layer_sizes, unsigned int);
+	}
+	va_end(layer_sizes);
+
+	ann = fann_create_sparse_array(connection_rate, num_layers, layers);
+
+	free(layers);
+
+	return ann;
+}
+
+FANN_EXTERNAL struct fann *FANN_API fann_create_sparse_array(float connection_rate,
+														     unsigned int num_layers, 
+															 unsigned int *layers)
 {
 	struct fann_layer *layer_it, *last_layer, *prev_layer;
 	struct fann *ann;
@@ -87,7 +116,7 @@ FANN_EXTERNAL struct fann *FANN_API fann_create_array(float connection_rate, flo
 #endif
 
 	/* allocate the general structure */
-	ann = fann_allocate_structure(learning_rate, num_layers);
+	ann = fann_allocate_structure(num_layers);
 	if(ann == NULL)
 	{
 		fann_error(NULL, FANN_E_CANT_ALLOCATE_MEM);
@@ -124,8 +153,7 @@ FANN_EXTERNAL struct fann *FANN_API fann_create_array(float connection_rate, flo
 	}
 
 #ifdef DEBUG
-	printf("creating network with learning rate %f and connection rate %f\n", learning_rate,
-		   connection_rate);
+	printf("creating network with connection rate %f\n", connection_rate);
 	printf("input\n");
 	printf("  layer       : %d neurons, 1 bias\n",
 		   ann->first_layer->last_neuron - ann->first_layer->first_neuron - 1);
@@ -326,10 +354,7 @@ FANN_EXTERNAL struct fann *FANN_API fann_create_array(float connection_rate, flo
 }
 
 
-/* create a neural network with shortcut connections.
- */
-FANN_EXTERNAL struct fann *FANN_API fann_create_shortcut(float learning_rate, unsigned int num_layers,	/* the number of layers, including the input and output layer */
-														 ...)	/* the number of neurons in each of the layers, starting with the input layer and ending with the output layer */
+FANN_EXTERNAL struct fann *FANN_API fann_create_shortcut(unsigned int num_layers, ...)
 {
 	struct fann *ann;
 	int i;
@@ -350,17 +375,14 @@ FANN_EXTERNAL struct fann *FANN_API fann_create_shortcut(float learning_rate, un
 	}
 	va_end(layer_sizes);
 
-	ann = fann_create_shortcut_array(learning_rate, num_layers, layers);
+	ann = fann_create_shortcut_array(num_layers, layers);
 
 	free(layers);
 
 	return ann;
 }
 
-/* create a neural network with shortcut connections.
- */
-FANN_EXTERNAL struct fann *FANN_API fann_create_shortcut_array(float learning_rate,
-															   unsigned int num_layers,
+FANN_EXTERNAL struct fann *FANN_API fann_create_shortcut_array(unsigned int num_layers,
 															   unsigned int *layers)
 {
 	struct fann_layer *layer_it, *layer_it2, *last_layer;
@@ -379,7 +401,7 @@ FANN_EXTERNAL struct fann *FANN_API fann_create_shortcut_array(float learning_ra
 #endif
 
 	/* allocate the general structure */
-	ann = fann_allocate_structure(learning_rate, num_layers);
+	ann = fann_allocate_structure(num_layers);
 	if(ann == NULL)
 	{
 		fann_error(NULL, FANN_E_CANT_ALLOCATE_MEM);
@@ -423,7 +445,7 @@ FANN_EXTERNAL struct fann *FANN_API fann_create_shortcut_array(float learning_ra
 	}
 
 #ifdef DEBUG
-	printf("creating fully shortcut connected network with learning rate %f.\n", learning_rate);
+	printf("creating fully shortcut connected network.\n");
 	printf("input\n");
 	printf("  layer       : %d neurons, 1 bias\n",
 		   ann->first_layer->last_neuron - ann->first_layer->first_neuron - 1);
@@ -495,8 +517,6 @@ FANN_EXTERNAL struct fann *FANN_API fann_create_shortcut_array(float learning_ra
 	return ann;
 }
 
-/* runs the network.
- */
 FANN_EXTERNAL fann_type *FANN_API fann_run(struct fann * ann, fann_type * input)
 {
 	struct fann_neuron *neuron_it, *last_neuron, *neurons, **neuron_pointers;
@@ -733,8 +753,6 @@ FANN_EXTERNAL fann_type *FANN_API fann_run(struct fann * ann, fann_type * input)
 	return ann->output;
 }
 
-/* deallocate the network.
- */
 FANN_EXTERNAL void FANN_API fann_destroy(struct fann *ann)
 {
 	if(ann == NULL)
@@ -921,6 +939,7 @@ FANN_EXTERNAL void FANN_API fann_init_weights(struct fann *ann, struct fann_trai
 FANN_EXTERNAL void FANN_API fann_print_parameters(struct fann *ann)
 {
 	struct fann_layer *layer_it;
+	unsigned int i;
 
 	printf("Input layer                :%4d neurons, 1 bias\n", ann->num_input);
 	for(layer_it = ann->first_layer + 1; layer_it != ann->last_layer - 1; layer_it++)
@@ -941,25 +960,15 @@ FANN_EXTERNAL void FANN_API fann_print_parameters(struct fann *ann)
 	printf("Total connections          :%4d\n", ann->total_connections);
 	printf("Connection rate            :  %5.2f\n", ann->connection_rate);
 	printf("Shortcut connections       :%4d\n", ann->shortcut_connections);
-	printf("Training algorithm         :   %s\n", FANN_TRAIN_NAMES[ann->training_algorithm]);
-	printf("Learning rate              :  %5.2f\n", ann->learning_rate);
-/*	printf("Activation function hidden :   %s\n", FANN_ACTIVATION_NAMES[ann->activation_function_hidden]);
-	printf("Activation function output :   %s\n", FANN_ACTIVATION_NAMES[ann->activation_function_output]);
-*/
-#ifndef FIXEDFANN
-/*
-	printf("Activation steepness hidden:  %5.2f\n", ann->activation_steepness_hidden);
-	printf("Activation steepness output:  %5.2f\n", ann->activation_steepness_output);
-*/
-#else
-/*
-	printf("Activation steepness hidden:  %d\n", ann->activation_steepness_hidden);
-	printf("Activation steepness output:  %d\n", ann->activation_steepness_output);
-*/
+#ifdef FIXEDFANN
 	printf("Decimal point              :%4d\n", ann->decimal_point);
 	printf("Multiplier                 :%4d\n", ann->multiplier);
 #endif
+	printf("Training algorithm         :   %s\n", FANN_TRAIN_NAMES[ann->training_algorithm]);
 	printf("Training error function    :   %s\n", FANN_ERRORFUNC_NAMES[ann->train_error_function]);
+	printf("Training stop function     :   %s\n", FANN_STOPFUNC_NAMES[ann->train_stop_function]);
+	printf("Bit fail limit             :  %5.2f\n", ann->bit_fail_limit);
+	printf("Learning rate              :  %5.2f\n", ann->learning_rate);
 	printf("Quickprop decay            :  %9.6f\n", ann->quickprop_decay);
 	printf("Quickprop mu               :  %5.2f\n", ann->quickprop_mu);
 	printf("RPROP increase factor      :  %5.2f\n", ann->rprop_increase_factor);
@@ -967,7 +976,19 @@ FANN_EXTERNAL void FANN_API fann_print_parameters(struct fann *ann)
 	printf("RPROP delta min            :  %5.2f\n", ann->rprop_delta_min);
 	printf("RPROP delta max            :  %5.2f\n", ann->rprop_delta_max);
 	printf("Cascade change fraction    :  %9.6f\n", ann->cascade_change_fraction);
+	printf("Cascade weight multiplier  :  %9.6f\n", ann->cascade_weight_multiplier);
+	printf("Cascade candidate limit    :  %9.6f\n", ann->cascade_candidate_limit);
 	printf("Cascade stagnation epochs  :%4d\n", ann->cascade_stagnation_epochs);
+	printf("Cascade max output epochs  :%4d\n", ann->cascade_max_out_epochs);
+	printf("Cascade max cand epochs    :%4d\n", ann->cascade_max_cand_epochs);
+	for(i = 0; i < ann->cascade_activation_functions_count; i++)
+		printf("Cascade activation func[%d] :   %s\n", i,
+			FANN_ACTIVATIONFUNC_NAMES[ann->cascade_activation_functions[i]]);
+	for(i = 0; i < ann->cascade_activation_steepnesses_count; i++)
+		printf("Cascade activation steep[%d]:  %5.2f\n", i,
+			ann->cascade_activation_steepnesses[i]);
+		
+	printf("Cascade candidate groups   :%4d\n", ann->cascade_num_candidate_groups);
 	printf("Cascade no. of candidates  :%4d\n", fann_get_cascade_num_candidates(ann));
 }
 
@@ -1049,7 +1070,7 @@ void fann_update_stepwise(struct fann *ann)
 /* INTERNAL FUNCTION
    Allocates the main structure and sets some default values.
  */
-struct fann *fann_allocate_structure(float learning_rate, unsigned int num_layers)
+struct fann *fann_allocate_structure(unsigned int num_layers)
 {
 	struct fann *ann;
 
@@ -1072,7 +1093,7 @@ struct fann *fann_allocate_structure(float learning_rate, unsigned int num_layer
 	ann->errno_f = FANN_E_NO_ERROR;
 	ann->error_log = NULL;
 	ann->errstr = NULL;
-	ann->learning_rate = learning_rate;
+	ann->learning_rate = 0.7;
 	ann->total_neurons = 0;
 	ann->total_connections = 0;
 	ann->num_input = 0;
diff --git a/src/fann_cascade.c b/src/fann_cascade.c
index 79971b9..bc367a1 100644
--- a/src/fann_cascade.c
+++ b/src/fann_cascade.c
@@ -17,8 +17,8 @@
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
 
+#include "config.h"
 #include "fann.h"
-#include "fann_errno.h"
 
 #ifndef FIXEDFANN
 
@@ -740,7 +740,7 @@ float fann_train_candidates_epoch(struct fann *ann, struct fann_train_data *data
 	{
 		/*struct fann_neuron *cand = ann->first_layer->first_neuron + ann->total_neurons + 1 + i;
 		 * printf("candidate[%d] = activation: %s, steepness: %f, score: %f\n", 
-		 * i, FANN_ACTIVATION_NAMES[cand->activation_function], 
+		 * i, FANN_ACTIVATIONFUNC_NAMES[cand->activation_function], 
 		 * cand->activation_steepness, ann->cascade_candidate_scores[i]); */
 
 		if(ann->cascade_candidate_scores[i] > best_score)
@@ -913,7 +913,7 @@ void fann_add_candidate_neuron(struct fann *ann, struct fann_layer *layer)
 	neuron_place->first_con = neuron_place->last_con - num_connections_in;
 	printf("neuron[%d] = weights[%d ... %d] activation: %s, steepness: %f\n",
 		   neuron_place - ann->first_layer->first_neuron, neuron_place->first_con,
-		   neuron_place->last_con - 1, FANN_ACTIVATION_NAMES[neuron_place->activation_function],
+		   neuron_place->last_con - 1, FANN_ACTIVATIONFUNC_NAMES[neuron_place->activation_function],
 		   neuron_place->activation_steepness);
 #ifdef CASCADE_DEBUG_FULL
 	printf("neuron[%d] = weights[%d ... %d]\n", neuron_place - ann->first_layer->first_neuron,
diff --git a/src/fann_error.c b/src/fann_error.c
index bd51c0a..451c7fe 100644
--- a/src/fann_error.c
+++ b/src/fann_error.c
@@ -24,8 +24,6 @@
 
 #include "config.h"
 #include "fann.h"
-#include "fann_internal.h"
-#include "fann_errno.h"
 
 #ifdef _MSC_VER
 #define vsnprintf _vsnprintf
diff --git a/src/fann_io.c b/src/fann_io.c
index 89c4c01..5487434 100644
--- a/src/fann_io.c
+++ b/src/fann_io.c
@@ -24,7 +24,6 @@
 
 #include "config.h"
 #include "fann.h"
-#include "fann_errno.h"
 
 /* Create a network from a configuration file.
  */
@@ -393,13 +392,14 @@ struct fann *fann_create_from_fd_1_1(FILE * conf, const char *configuration_file
 		return NULL;
 	}
 
-	ann = fann_allocate_structure(learning_rate, num_layers);
+	ann = fann_allocate_structure(num_layers);
 	if(ann == NULL)
 	{
 		return NULL;
 	}
 	ann->connection_rate = connection_rate;
 	ann->shortcut_connections = shortcut_connections;
+	ann->learning_rate = learning_rate;
 
 #ifdef FIXEDFANN
 	ann->decimal_point = decimal_point;
@@ -570,13 +570,14 @@ struct fann *fann_create_from_fd(FILE * conf, const char *configuration_file)
 		return NULL;
 	}
 
-	ann = fann_allocate_structure(learning_rate, num_layers);
+	ann = fann_allocate_structure(num_layers);
 	if(ann == NULL)
 	{
 		return NULL;
 	}
 	ann->connection_rate = connection_rate;
 	ann->shortcut_connections = shortcut_connections;
+	ann->learning_rate = learning_rate;
 
 #ifdef FIXEDFANN
 	ann->decimal_point = decimal_point;
diff --git a/src/fann_train.c b/src/fann_train.c
index 7cef28b..4b1b428 100644
--- a/src/fann_train.c
+++ b/src/fann_train.c
@@ -24,7 +24,6 @@
 
 #include "config.h"
 #include "fann.h"
-#include "fann_errno.h"
 
 /*#define DEBUGTRAIN*/
 
@@ -842,3 +841,4 @@ FANN_GET_SET(float, rprop_decrease_factor)
 FANN_GET_SET(float, rprop_delta_min)
 FANN_GET_SET(float, rprop_delta_max)
 FANN_GET_SET(enum fann_stopfunc_enum, train_stop_function)
+FANN_GET_SET(fann_type, bit_fail_limit)
diff --git a/src/fann_train_data.c b/src/fann_train_data.c
index 75159c4..eee526b 100644
--- a/src/fann_train_data.c
+++ b/src/fann_train_data.c
@@ -24,7 +24,6 @@
 
 #include "config.h"
 #include "fann.h"
-#include "fann_errno.h"
 
 /*
  * Reads training data from a file. 
diff --git a/src/fixedfann.c b/src/fixedfann.c
index b6536c2..a19bd6e 100644
--- a/src/fixedfann.c
+++ b/src/fixedfann.c
@@ -19,6 +19,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
 /* Easy way to allow for build of multiple binaries */
 
+#include "config.h"
 #include "fixedfann.h"
 
 #include "fann.c"
diff --git a/src/floatfann.c b/src/floatfann.c
index bd74136..4f73791 100644
--- a/src/floatfann.c
+++ b/src/floatfann.c
@@ -19,6 +19,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
 /* Easy way to allow for build of multiple binaries */
 
+#include "config.h"
 #include "floatfann.h"
 
 #include "fann.c"
diff --git a/src/include/Makefile.am b/src/include/Makefile.am
index f070f7b..ea9c1a7 100644
--- a/src/include/Makefile.am
+++ b/src/include/Makefile.am
@@ -1 +1 @@
-include_HEADERS = fann.h doublefann.h fann_internal.h floatfann.h doublefann.h fann_data.h fixedfann.h compat_time.h fann_errno.h fann_activation.h
+include_HEADERS = fann.h doublefann.h fann_internal.h floatfann.h doublefann.h fann_data.h fixedfann.h compat_time.h fann_activation.h fann_cascade.h fann_error.h fann_train.h fann_io.h
diff --git a/src/include/Makefile.in b/src/include/Makefile.in
index 10a64df..754e977 100644
--- a/src/include/Makefile.in
+++ b/src/include/Makefile.in
@@ -129,7 +129,7 @@ sbindir = @sbindir@
 sharedstatedir = @sharedstatedir@
 sysconfdir = @sysconfdir@
 target_alias = @target_alias@
-include_HEADERS = fann.h doublefann.h fann_internal.h floatfann.h doublefann.h fann_data.h fixedfann.h compat_time.h fann_errno.h fann_activation.h
+include_HEADERS = fann.h doublefann.h fann_internal.h floatfann.h doublefann.h fann_data.h fixedfann.h compat_time.h fann_activation.h fann_cascade.h fann_error.h fann_train.h fann_io.h
 subdir = src/include
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
diff --git a/src/include/fann.h b/src/include/fann.h
index ee522fc..74c4896 100644
--- a/src/include/fann.h
+++ b/src/include/fann.h
@@ -1,272 +1,426 @@
-/*
-Fast Artificial Neural Network Library (fann)
-Copyright (C) 2003 Steffen Nissen (lukesky at 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
-*/  
-	
-/* This file defines the user interface to the fann library.
-   It is included from fixedfann.h, floatfann.h and doublefann.h and should
-   NOT be included directly. If included directly it will react as if
-   floatfann.h was included.
-*/ 
-
-/* Package: FANN Create/Destroy */
-	
-#ifndef FANN_INCLUDE
-/* just to allow for inclusion of fann.h in normal stuations where only floats are needed */ 
-#ifdef FIXEDFANN
-#include "fixedfann.h"
+/*
+Fast Artificial Neural Network Library (fann)
+Copyright (C) 2003 Steffen Nissen (lukesky at 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
+*/  
+	
+/* This file defines the user interface to the fann library.
+   It is included from fixedfann.h, floatfann.h and doublefann.h and should
+   NOT be included directly. If included directly it will react as if
+   floatfann.h was included.
+*/ 
+
+/* Section: FANN Creation/Execution */
+/* Group: Creation, Destruction & Execution */
+	
+#ifndef FANN_INCLUDE
+/* just to allow for inclusion of fann.h in normal stuations where only floats are needed */ 
+#ifdef FIXEDFANN
+#include "fixedfann.h"
 #else
-#include "floatfann.h"
-#endif	/* FIXEDFANN  */
-	
+#include "floatfann.h"
+#endif	/* FIXEDFANN  */
+	
 #else
-	
-/* COMPAT_TIME REPLACEMENT */ 
-#ifndef _WIN32
-#include <sys/time.h>
-#else	/* _WIN32 */
-#if !defined(_MSC_EXTENSIONS) &&
-	 !defined(_INC_WINDOWS) 
 extern unsigned long __stdcall GetTickCount(void);
-
-
-#else	/* _MSC_EXTENSIONS */
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h>
-#endif	/* _MSC_EXTENSIONS */
-#endif	/* _WIN32 */
-	
-#include "fann_data.h"
-#include "fann_internal.h"
-#include "fann_activation.h"
-#include "fann_errno.h"
-	
-#ifndef __fann_h__
-#define __fann_h__
-	
-#ifdef __cplusplus
+	
+/* COMPAT_TIME REPLACEMENT */ 
+#ifndef _WIN32
+#include <sys/time.h>
+#else	/* _WIN32 */
+#if !defined(_MSC_EXTENSIONS) &&
+	 !defined(_INC_WINDOWS)  extern unsigned long __stdcall GetTickCount(void);
+
+
+#else	/* _MSC_EXTENSIONS */
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+#endif	/* _MSC_EXTENSIONS */
+#endif	/* _WIN32 */
+		
+#ifndef __fann_h__
+#define __fann_h__
+	
+#ifdef __cplusplus
 extern "C"
 {
-	
-#ifndef __cplusplus
-} /* to fool automatic indention engines */ 
+	
+#ifndef __cplusplus
+} /* to fool automatic indention engines */ 
 #endif
-#endif	/* __cplusplus */
- 
-#ifndef NULL
-#define NULL 0
-#endif	/* NULL */
- 
-/* ----- Macros used to define DLL external entrypoints ----- */ 
-/*
- DLL Export, import and calling convention for Windows.
- Only defined for Microsoft VC++ FANN_EXTERNAL indicates
- that a function will be exported/imported from a dll
- FANN_API ensures that the DLL calling convention
- will be used for  a function regardless of the calling convention
- used when compiling.
-
- For a function to be exported from a DLL its prototype and
- declaration must be like this:
-    FANN_EXTERNAL void FANN_API function(char *argument)
-
- The following ifdef block is a way of creating macros which
- make exporting from a DLL simple. All files within a DLL are
- compiled with the FANN_DLL_EXPORTS symbol defined on the
- command line. This symbol should not be defined on any project
- that uses this DLL. This way any other project whose source
- files include this file see FANN_EXTERNAL functions as being imported
- from a DLL, whereas a DLL sees symbols defined with this
- macro as being exported which makes calls more efficient.
- The __stdcall calling convention is used for functions in a
- windows DLL.
-
- The callback functions for fann_train_on_data_callback and
- fann_train_on_file_callback must be declared as FANN_API
- so the DLL and the application program both use the same
- calling convention. The callback functions must of this form:
-     int FANN_API user_callback(unsigned int epochs, float error)
-*/ 
- 
-/*
- The following sets the default for MSVC++ 2003 or later to use
- the fann dll's. To use a lib or fixedfann.c, floatfann.c or doublefann.c
- with those compilers FANN_NO_DLL has to be defined before
- including the fann headers.
- The default for previous MSVC compilers such as VC++ 6 is not
- to use dll's. To use dll's FANN_USE_DLL has to be defined before
- including the fann headers.
-*/ 
-#if (_MSC_VER > 1300)
-#ifndef FANN_NO_DLL
-#define FANN_USE_DLL
-#endif	/* FANN_USE_LIB */
-#endif	/* _MSC_VER */
-#if defined(_MSC_VER) && (defined(FANN_USE_DLL) || defined(FANN_DLL_EXPORTS))
-#ifdef FANN_DLL_EXPORTS
-#define FANN_EXTERNAL __declspec(dllexport)
-#else							/* 
 */
-#define FANN_EXTERNAL __declspec(dllimport)
-#endif	/* FANN_DLL_EXPORTS*/
-#define FANN_API __stdcall
-#else							/* 
 */
-#define FANN_EXTERNAL
-#define FANN_API
-#endif	/* _MSC_VER */
-/* ----- End of macros used to define DLL external entrypoints ----- */ 
-
-#include "fann_train.h"
-#include "fann_train_data.h"
-#include "fann_cascade.h"
-#include "fann_error.h"
-#include "fann_io.h"
-
-/* ----- Implemented in fann.c Creation, running and destruction of ANNs ----- */ 
- 
-/* Function: fann_create
-   Constructs a backpropagation neural network, from an connection rate,
-   a learning rate, the number of layers and the number of neurons in each
-   of the layers.
-
-   The connection rate controls how many connections there will be in the
-   network. If the connection rate is set to 1, the network will be fully
-   connected, but if it is set to 0.5 only half of the connections will be set.
-
-   There will be a bias neuron in each layer (except the output layer),
-   and this bias neuron will be connected to all neurons in the next layer.
-   When running the network, the bias nodes always emits 1
-*/ 
-FANN_EXTERNAL struct fann *FANN_API fann_create(float connection_rate, float learning_rate, 
-												  /* the number of layers, including the input and output layer */ 
-												  unsigned int num_layers, 
-												  /* the number of neurons in each of the layers, starting with
-												   * the input layer and ending with the output layer */ 
-												  ...);
-

-/* Function: fann_create_array
-   Just like fann_create, but with an array of layer sizes
-   instead of individual parameters.
-*/ 
-FANN_EXTERNAL struct fann *FANN_API fann_create_array(float connection_rate, float learning_rate,
-													  unsigned int num_layers,
-													  unsigned int *layers);
-

-/* Function: fann_create_shortcut
-
-   create a fully connected neural network with shortcut connections.
- */ 
-FANN_EXTERNAL struct fann *FANN_API fann_create_shortcut(float learning_rate,
-														 unsigned int num_layers, 
-														 ...);
-
-/* the number of neurons in each of the layers, starting with the input layer and ending with the output layer */
-	

-/* Function: fann_create_shortcut_array
-   create a neural network with shortcut connections.
- */ 
-FANN_EXTERNAL struct fann *FANN_API fann_create_shortcut_array(float learning_rate,
-															   unsigned int num_layers,
+#endif	/* __cplusplus */
+ 
+#ifndef NULL
+#define NULL 0
+#endif	/* NULL */
+ 
+/* ----- Macros used to define DLL external entrypoints ----- */ 
+/*
+ DLL Export, import and calling convention for Windows.
+ Only defined for Microsoft VC++ FANN_EXTERNAL indicates
+ that a function will be exported/imported from a dll
+ FANN_API ensures that the DLL calling convention
+ will be used for  a function regardless of the calling convention
+ used when compiling.
+
+ For a function to be exported from a DLL its prototype and
+ declaration must be like this:
+    FANN_EXTERNAL void FANN_API function(char *argument)
+
+ The following ifdef block is a way of creating macros which
+ make exporting from a DLL simple. All files within a DLL are
+ compiled with the FANN_DLL_EXPORTS symbol defined on the
+ command line. This symbol should not be defined on any project
+ that uses this DLL. This way any other project whose source
+ files include this file see FANN_EXTERNAL functions as being imported
+ from a DLL, whereas a DLL sees symbols defined with this
+ macro as being exported which makes calls more efficient.
+ The __stdcall calling convention is used for functions in a
+ windows DLL.
+
+ The callback functions for fann_train_on_data_callback and
+ fann_train_on_file_callback must be declared as FANN_API
+ so the DLL and the application program both use the same
+ calling convention. The callback functions must of this form:
+     int FANN_API user_callback(unsigned int epochs, float error)
+*/ 
+ 
+/*
+ The following sets the default for MSVC++ 2003 or later to use
+ the fann dll's. To use a lib or fixedfann.c, floatfann.c or doublefann.c
+ with those compilers FANN_NO_DLL has to be defined before
+ including the fann headers.
+ The default for previous MSVC compilers such as VC++ 6 is not
+ to use dll's. To use dll's FANN_USE_DLL has to be defined before
+ including the fann headers.
+*/ 
+#if (_MSC_VER > 1300)
+#ifndef FANN_NO_DLL
+#define FANN_USE_DLL
+#endif	/* FANN_USE_LIB */
+#endif	/* _MSC_VER */
+#if defined(_MSC_VER) && (defined(FANN_USE_DLL) || defined(FANN_DLL_EXPORTS))
+#ifdef FANN_DLL_EXPORTS
+#define FANN_EXTERNAL __declspec(dllexport)
+#else							/*  */
+#define FANN_EXTERNAL __declspec(dllimport)
+#endif	/* FANN_DLL_EXPORTS*/
+#define FANN_API __stdcall
+#else							/*  */
+#define FANN_EXTERNAL
+#define FANN_API
+#endif	/* _MSC_VER */
+/* ----- End of macros used to define DLL external entrypoints ----- */ 
+
+#include "fann_error.h"
+#include "fann_activation.h"
+#include "fann_data.h"
+#include "fann_internal.h"
+#include "fann_train.h"
+#include "fann_cascade.h"
+#include "fann_io.h"
+
+/* Function: fann_create_standard
+	
+	Creates a standard fully connected backpropagation neural network.
+
+	There will be a bias neuron in each layer (except the output layer),
+	and this bias neuron will be connected to all neurons in the next layer.
+	When running the network, the bias nodes always emits 1.
+	
+	To destroy a <struct fann> use the <fann_destroy> function.
+
+	Parameters:
+		num_layers - The total number of layers including the input and the output layer.
+		... - Integer values determining the number of neurons in each layer starting with the 
+			input layer and ending with the output layer.
+			
+	Returns:
+		A pointer to the newly created <struct fann>.
+			
+	Example:
+		> // Creating an ANN with 2 input neurons, 1 output neuron, 
+		> // and two hidden neurons with 8 and 9 neurons
+		> struct fann *ann = fann_create_standard(4, 2, 8, 9, 1);
+		
+	See also:
+		<fann_create_standard_array>, <fann_create_sparse>, <fann_create_shortcut>		
+		
+	This function appears in FANN >= 2.0.0.
+*/ 
+FANN_EXTERNAL struct fann *FANN_API fann_create_standard(unsigned int num_layers, ...);
+
+/* Function: fann_create_standard_array
+   Just like <fann_create_standard>, but with an array of layer sizes
+   instead of individual parameters.
+
+	Example:
+		> // Creating an ANN with 2 input neurons, 1 output neuron, 
+		> // and two hidden neurons with 8 and 9 neurons
+		> unsigned int layers[4] = {2, 8, 9, 1};
+		> struct fann *ann = fann_create_standard_array(4, layers);
+
+	See also:
+		<fann_create_standard>, <fann_create_sparse>, <fann_create_shortcut>
+
+	This function appears in FANN >= 2.0.0.
+*/ 
+FANN_EXTERNAL struct fann *FANN_API fann_create_standard_array(unsigned int num_layers,
+													           unsigned int *layers);
+
+/* Function: fann_create_sparse
+
+	Creates a standard backpropagation neural network, which is not fully connected.
+
+	Parameters:
+		connection_rate - The connection rate controls how many connections there will be in the
+   			network. If the connection rate is set to 1, the network will be fully
+   			connected, but if it is set to 0.5 only half of the connections will be set.
+			A connection rate of 1 will yield the same result as <fann_create_standard>
+		num_layers - The total number of layers including the input and the output layer.
+		... - Integer values determining the number of neurons in each layer starting with the 
+			input layer and ending with the output layer.
+			
+	Returns:
+		A pointer to the newly created <struct fann>.
+
+	See also:
+		<fann_create_sparse_array>, <fann_create_standard>, <fann_create_shortcut>
+
+	This function appears in FANN >= 2.0.0.
+*/
+FANN_EXTERNAL struct fann *FANN_API fann_create_sparse(float connection_rate, 
+	                                                   unsigned int num_layers, ...);
+
+
+/* Function: fann_create_sparse_array
+   Just like <fann_create_sparse>, but with an array of layer sizes
+   instead of individual parameters.
+
+	See <fann_create_standard_array> for a description of the parameters.
+
+	See also:
+		<fann_create_sparse>, <fann_create_standard>, <fann_create_shortcut>
+
+	This function appears in FANN >= 2.0.0.
+*/
+FANN_EXTERNAL struct fann *FANN_API fann_create_sparse_array(float connection_rate, 
+	                                                         unsigned int num_layers, 
+															 unsigned int *layers);
+
+/* Function: fann_create_shortcut
+
+	Creates a standard backpropagation neural network, which is not fully connected and which
+	also has shortcut connections.
+
+ 	Shortcut connections are connections that skip layers. A fully connected network with shortcut 
+	connections, is a network where all neurons are connected to all neurons in later layers. 
+	Including direct connections from the input layer to the output layer.
+
+	See <fann_create_standard> for a description of the parameters.
+
+	See also:
+		<fann_create_shortcut_array>, <fann_create_standard>, <fann_create_sparse>, 
+
+	This function appears in FANN >= 2.0.0.
+*/ 
+FANN_EXTERNAL struct fann *FANN_API fann_create_shortcut(unsigned int num_layers, ...);
+
+/* Function: fann_create_shortcut_array
+   Just like <fann_create_shortcut>, but with an array of layer sizes
+   instead of individual parameters.
+
+	See <fann_create_standard_array> for a description of the parameters.
+
+	See also:
+		<fann_create_shortcut>, <fann_create_standard>, <fann_create_sparse>
+
+	This function appears in FANN >= 2.0.0.
+*/
+FANN_EXTERNAL struct fann *FANN_API fann_create_shortcut_array(unsigned int num_layers,
 															   unsigned int *layers);
-

-/* Function: fann_run
-   Runs a input through the network, and returns the output.
- */ 
-FANN_EXTERNAL fann_type * FANN_API fann_run(struct fann *ann, fann_type * input);
-

-/* Function: fann_destroy
-   Destructs the entire network.
-   Be sure to call this function after finished using the network.
- */ 
+/* Function: fann_destroy
+   Destroys the entire network and properly freeing all the associated memmory.
+
+	This function appears in FANN >= 1.0.0.
+*/ 
 FANN_EXTERNAL void FANN_API fann_destroy(struct fann *ann);
-

-/* Function: fann_randomize_weights
-   Randomize weights (from the beginning the weights are random between -0.1 and 0.1)
- */ 
+
+
+/* Function: fann_run
+	Will run input through the neural network, returning an array of outputs, the number of which being 
+	equal to the number of neurons in the output layer.
+
+	See also:
+		<fann_test>
+
+	This function appears in FANN >= 1.0.0.
+*/ 
+FANN_EXTERNAL fann_type * FANN_API fann_run(struct fann *ann, fann_type * input);
+
+/* Function: fann_randomize_weights
+	Give each connection a random weight between *min_weight* and *max_weight*
+   
+	From the beginning the weights are random between -0.1 and 0.1.
+
+	See also:
+		<fann_init_weights>
+
+	This function appears in FANN >= 1.0.0.
+*/ 
 FANN_EXTERNAL void FANN_API fann_randomize_weights(struct fann *ann, fann_type min_weight,
 												   fann_type max_weight);
-

-/* Function: fann_init_weights
-   Initialize the weights using Widrow + Nguyen's algorithm.
-*/ 
+
+/* Function: fann_init_weights
+  	Initialize the weights using Widrow + Nguyen's algorithm.
+	
+ 	This function behaves similarly to fann_randomize_weights. It will use the algorithm developed 
+	by Derrick Nguyen and Bernard Widrow to set the weights in such a way 
+	as to speed up training. This technique is not always successful, and in some cases can be less 
+	efficient than a purely random initialization.
+
+	The algorithm requires access to the range of the input data (ie, largest and smallest input), 
+	and therefore accepts a second argument, data, which is the training data that will be used to 
+	train the network.
+
+	See also:
+		<fann_randomize_weights>, <fann_read_train_from_file>
+
+	This function appears in FANN >= 1.1.0.
+*/ 
 FANN_EXTERNAL void FANN_API fann_init_weights(struct fann *ann, struct fann_train_data *train_data);
-

-/* Function: fann_print_connections
-   print out which connections there are in the ann */ 
+
+/* Function: fann_print_connections
+	Will print the connections of the ann in a compact matrix, for easy viewing of the internals 
+	of the ann.
+
+	The output from fann_print_connections on a small (2 2 1) network trained on the xor problem
+	> Layer / Neuron 012345
+	> L   1 / N    3 ddb...
+	> L   1 / N    4 bbb...
+	> L   2 / N    6 ...cda
+		  
+	This network have five real neurons and two bias neurons. This gives a total of seven neurons 
+	named from 0 to 6. The connections between these neurons can be seen in the matrix. "." is a 
+	place where there is no connection, while a character tells how strong the connection is on a 
+	scale from a-z. The two real neurons in the hidden layer (neuron 3 and 4 in layer 1) has 
+	connection from the three neurons in the previous layer as is visible in the first two lines. 
+	The output neuron (6) has connections form the three neurons in the hidden layer 3 - 5 as is 
+	visible in the last line.
+
+	To simplify the matrix output neurons is not visible as neurons that connections can come from, 
+	and input and bias neurons are not visible as neurons that connections can go to.
+
+	This function appears in FANN >= 1.2.0.
+*/ 
 FANN_EXTERNAL void FANN_API fann_print_connections(struct fann *ann);
-
-/* Group: Parameters */

-/* Function: fann_print_parameters
-
-   Prints all of the parameters and options of the ANN */ 
-FANN_EXTERNAL void FANN_API fann_print_parameters(struct fann *ann);
-
-
-/* Function: fann_get_num_input
-
-   Get the number of input neurons.
- */ 
-FANN_EXTERNAL unsigned int FANN_API fann_get_num_input(struct fann *ann);
-
-
-/* Function: fann_get_num_output
-
-   Get the number of output neurons.
- */ 
-FANN_EXTERNAL unsigned int FANN_API fann_get_num_output(struct fann *ann);
-
-
-/* Function: fann_get_total_neurons
-
-   Get the total number of neurons in the entire network.
- */ 
-FANN_EXTERNAL unsigned int FANN_API fann_get_total_neurons(struct fann *ann);
-
-
-/* Function: fann_get_total_connections
-
-   Get the total number of connections in the entire network.
- */ 
-FANN_EXTERNAL unsigned int FANN_API fann_get_total_connections(struct fann *ann);
-
-#ifdef FIXEDFANN
-	
-/* Function: fann_get_decimal_point
-
-   returns the position of the decimal point.
- */ 
-FANN_EXTERNAL unsigned int FANN_API fann_get_decimal_point(struct fann *ann);
-
-
-/* Function: fann_get_multiplier
-
-   returns the multiplier that fix point data is multiplied with.
- */ 
-FANN_EXTERNAL unsigned int FANN_API fann_get_multiplier(struct fann *ann);
-
-#endif	/* FIXEDFANN */
-
-#ifdef __cplusplus
-#ifndef __cplusplus
-/* to fool automatic indention engines */ 
+
+/* Group: Parameters */
+/* Function: fann_print_parameters
+
+  	Prints all of the parameters and options of the ANN 
+
+	This function appears in FANN >= 1.2.0.
+*/ 
+FANN_EXTERNAL void FANN_API fann_print_parameters(struct fann *ann);
+
+
+/* Function: fann_get_num_input
+
+   Get the number of input neurons.
+
+	This function appears in FANN >= 1.0.0.
+*/ 
+FANN_EXTERNAL unsigned int FANN_API fann_get_num_input(struct fann *ann);
+
+
+/* Function: fann_get_num_output
+
+   Get the number of output neurons.
+
+	This function appears in FANN >= 1.0.0.
+*/ 
+FANN_EXTERNAL unsigned int FANN_API fann_get_num_output(struct fann *ann);
+
+
+/* Function: fann_get_total_neurons
+
+   Get the total number of neurons in the entire network. This number does also include the 
+	bias neurons, so a 2-4-2 network has 2+4+2 +2(bias) = 10 neurons.
+
+	This function appears in FANN >= 1.0.0.
+*/ 
+FANN_EXTERNAL unsigned int FANN_API fann_get_total_neurons(struct fann *ann);
+
+
+/* Function: fann_get_total_connections
+
+   Get the total number of connections in the entire network.
+
+	This function appears in FANN >= 1.0.0.
+*/ 
+FANN_EXTERNAL unsigned int FANN_API fann_get_total_connections(struct fann *ann);
+
+#ifdef FIXEDFANN
+	
+/* Function: fann_get_decimal_point
+
+	Returns the position of the decimal point in the ann.
+
+	This function is only available when the ANN is in fixed point mode.
+
+	The decimal point is described in greater detail in the tutorial <Fixed Point Usage>.
+
+	See also:
+		<Fixed Point Usage>, <fann_get_multiplier>, <fann_save_to_fixed>, <fann_save_train_to_fixed>
+
+	This function appears in FANN >= 1.0.0.
+*/ 
+FANN_EXTERNAL unsigned int FANN_API fann_get_decimal_point(struct fann *ann);
+
+
+/* Function: fann_get_multiplier
+
+    returns the multiplier that fix point data is multiplied with.
+
+	This function is only available when the ANN is in fixed point mode.
+
+	The multiplier is the used to convert between floating point and fixed point notation. 
+	A floating point number is multiplied with the multiplier in order to get the fixed point
+	number and visa versa.
+
+	The multiplier is described in greater detail in the tutorial <Fixed Point Usage>.
+
+	See also:
+		<Fixed Point Usage>, <fann_get_decimal_point>, <fann_save_to_fixed>, <fann_save_train_to_fixed>
+
+	This function appears in FANN >= 1.0.0.
+*/ 
+FANN_EXTERNAL unsigned int FANN_API fann_get_multiplier(struct fann *ann);
+
+#endif	/* FIXEDFANN */
+
+#ifdef __cplusplus
+#ifndef __cplusplus
+/* to fool automatic indention engines */ 
 {
-	
+	
 #endif
-} 
-#endif	/* __cplusplus */
-	
-#endif	/* __fann_h__ */
-	
+} 
+#endif	/* __cplusplus */
+	
+#endif	/* __fann_h__ */
+	
 #endif /* NOT FANN_INCLUDE */
diff --git a/src/include/fann_activation.h b/src/include/fann_activation.h
index a55781a..e8a2c4c 100644
--- a/src/include/fann_activation.h
+++ b/src/include/fann_activation.h
@@ -22,128 +22,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 /* internal include file, not to be included directly
  */
 
-/* The possible activation functions.
-   They are described with functions,
-   where x is the input to the activation function,
-   y is the output,
-   s is the steepness and
-   d is the derivation.
- */
-
-enum fann_activationfunc_enum
-{
-	/* Linear activation function.
-	 * span: -inf < y < inf
-	 * y = x*s, d = 1*s
-	 * Can NOT be used in fixed point.
-	 */
-	FANN_LINEAR = 0,
-
-	/* Threshold activation function.
-	 * x < 0 -> y = 0, x >= 0 -> y = 1
-	 * Can NOT be used during training.
-	 */
-	FANN_THRESHOLD,
-
-	/* Threshold activation function.
-	 * x < 0 -> y = 0, x >= 0 -> y = 1
-	 * Can NOT be used during training.
-	 */
-	FANN_THRESHOLD_SYMMETRIC,
-
-	/* Sigmoid activation function.
-	 * One of the most used activation functions.
-	 * span: 0 < y < 1
-	 * y = 1/(1 + exp(-2*s*x))
-	 * d = 2*s*y*(1 - y)
-	 */
-	FANN_SIGMOID,
-
-	/* Stepwise linear approximation to sigmoid.
-	 * Faster than sigmoid but a bit less precise.
-	 */
-	FANN_SIGMOID_STEPWISE,		/* (default) */
-
-
-	/* Symmetric sigmoid activation function, aka. tanh.
-	 * One of the most used activation functions.
-	 * span: -1 < y < 1
-	 * y = tanh(s*x) = 2/(1 + exp(-2*s*x)) - 1
-	 * d = s*(1-(y*y))
-	 */
-	FANN_SIGMOID_SYMMETRIC,
-
-	/* Stepwise linear approximation to symmetric sigmoid.
-	 * Faster than symmetric sigmoid but a bit less precise.
-	 */
-	FANN_SIGMOID_SYMMETRIC_STEPWISE,
-
-	/* Gaussian activation function.
-	 * 0 when x = -inf, 1 when x = 0 and 0 when x = inf
-	 * span: 0 < y < 1
-	 * y = exp(-x*s*x*s)
-	 * d = -2*x*s*y*s
-	 */
-	FANN_GAUSSIAN,
-
-	/* Symmetric gaussian activation function.
-	 * -1 when x = -inf, 1 when x = 0 and 0 when x = inf
-	 * span: -1 < y < 1
-	 * y = exp(-x*s*x*s)*2-1
-	 * d = -2*x*s*(y+1)*s
-	 */
-	FANN_GAUSSIAN_SYMMETRIC,
-
-	/* Stepwise linear approximation to gaussian.
-	 * Faster than gaussian but a bit less precise.
-	 * NOT implemented yet.
-	 */
-	FANN_GAUSSIAN_STEPWISE,
-
-	/* Fast (sigmoid like) activation function defined by David Elliott
-	 * span: 0 < y < 1
-	 * y = ((x*s) / 2) / (1 + |x*s|) + 0.5
-	 * d = s*1/(2*(1+|x*s|)*(1+|x*s|))
-	 */
-	FANN_ELLIOT,
-
-	/* Fast (symmetric sigmoid like) activation function defined by David Elliott
-	 * span: -1 < y < 1   
-	 * y = (x*s) / (1 + |x*s|)
-	 * d = s*1/((1+|x*s|)*(1+|x*s|))
-	 */
-	FANN_ELLIOT_SYMMETRIC,
-
-	/* Linear activation function.
-	 * span: 0 < y < 1
-	 * y = x*s, d = 1*s
-	 */
-	FANN_LINEAR_PIECE,
-
-	/* Linear activation function.
-	 * span: -1 < y < 1
-	 * y = x*s, d = 1*s
-	 */
-	FANN_LINEAR_PIECE_SYMMETRIC
-};
-
-static char const *const FANN_ACTIVATION_NAMES[] = {
-	"FANN_LINEAR",
-	"FANN_THRESHOLD",
-	"FANN_THRESHOLD_SYMMETRIC",
-	"FANN_SIGMOID",
-	"FANN_SIGMOID_STEPWISE",
-	"FANN_SIGMOID_SYMMETRIC",
-	"FANN_SIGMOID_SYMMETRIC_STEPWISE",
-	"FANN_GAUSSIAN",
-	"FANN_GAUSSIAN_SYMMETRIC",
-	"FANN_GAUSSIAN_STEPWISE",
-	"FANN_ELLIOT",
-	"FANN_ELLIOT_SYMMETRIC",
-	"FANN_LINEAR_PIECE",
-	"FANN_LINEAR_PIECE_SYMMETRIC"
-};
-
 /* Implementation of the activation functions
  */
 
diff --git a/src/include/fann_cascade.h b/src/include/fann_cascade.h
index 29e2437..f0f8cf9 100644
--- a/src/include/fann_cascade.h
+++ b/src/include/fann_cascade.h
@@ -20,11 +20,11 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 #ifndef __fann_cascade_h__
 #define __fann_cascade_h__
 
-/* Package: FANN Cascade Training
+/* Section: FANN Cascade Training
    test info about cascade training
 */
 
-/* Group: Functions */
+/* Group: Cascade Training */
 
 /* Function: fann_cascadetrain_on_data_callback
 */
diff --git a/src/include/fann_data.h b/src/include/fann_data.h
index d2282b4..888efc1 100644
--- a/src/include/fann_data.h
+++ b/src/include/fann_data.h
@@ -21,21 +21,49 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 #define __fann_data_h__
 
 #include <stdio.h>
-#include "fann_activation.h"
-#include "fann_errno.h"
 
+/* Section: FANN Datatypes */
+
+
+/* Type: fann_type
+	fann_type is defined as a:
+	float - if you include fann.h or floatfann.h
+	double - if you include doublefann.h
+	int - if you include fixedfann.h (please be aware that fixed point usage is 
+			only to be used during execution, and not during training).
+*/
+
+/* Enum: fann_train_enum
+	The Training algorithms used when training on <struct fann_train_data> with functions like
+	<fann_train_on_data> or <fann_train_on_file>.
+
+	FANN_TRAIN_INCREMENTAL - Standard backpropagation incremental or online training
+	FANN_TRAIN_BATCH - Standard backpropagation batch training
+	FANN_TRAIN_RPROP - The iRprop- training algorithm 
+	FANN_TRAIN_QUICKPROP - The Quickprop training algorithm
+	
+	See also:
+		<fann_set_training_algorithm>, <fann_get_training_algorithm>
+*/
 enum fann_train_enum
 {
-	/* Standard backpropagation incremental or online training */
 	FANN_TRAIN_INCREMENTAL = 0,
-	/* Standard backpropagation batch training */
 	FANN_TRAIN_BATCH,
-	/* The iRprop- training algorithm */
 	FANN_TRAIN_RPROP,
-	/* The quickprop training algorithm */
 	FANN_TRAIN_QUICKPROP
 };
 
+/* Constant: FANN_TRAIN_NAMES
+   
+   Constant array consisting of the names for the training algorithms, so that the name of an
+   training function can be received by:
+   (code)
+   char *name = FANN_TRAIN_NAMES[train_function];
+   (end)
+
+   See Also:
+      <fann_train_enum>
+*/
 static char const *const FANN_TRAIN_NAMES[] = {
 	"FANN_TRAIN_INCREMENTAL",
 	"FANN_TRAIN_BATCH",
@@ -43,30 +71,200 @@ static char const *const FANN_TRAIN_NAMES[] = {
 	"FANN_TRAIN_QUICKPROP"
 };
 
-/* Error function used during training */
+/* Enums: fann_activationfunc_enum
+   
+	The activation functions used for the neurons during training. The activation functions
+	can either be defined for a group of neurons by <fann_set_activation_function_hidden> and
+	<fann_set_activation_function_output> or it can be defined for a single neuron by <TODO>.
+
+	The steepness of an activation function is defined in the same way by 
+	<fann_set_activation_steepness_hidden>, <fann_set_activation_steepness_output>
+   
+   The functions are described with functions where:
+   * x is the input to the activation function,
+   * y is the output,
+   * s is the steepness and
+   * d is the derivation.
+
+   FANN_LINEAR - Linear activation function. 
+     * span: -inf < y < inf
+	 * y = x*s, d = 1*s
+	 * Can NOT be used in fixed point.
+
+   FANN_THRESHOLD - Threshold activation function.
+	 * x < 0 -> y = 0, x >= 0 -> y = 1
+	 * Can NOT be used during training.
+
+   FANN_THRESHOLD_SYMMETRIC - Threshold activation function.
+	 * x < 0 -> y = 0, x >= 0 -> y = 1
+	 * Can NOT be used during training.
+
+   FANN_SIGMOID - Sigmoid activation function.
+	 * One of the most used activation functions.
+	 * span: 0 < y < 1
+	 * y = 1/(1 + exp(-2*s*x))
+	 * d = 2*s*y*(1 - y)
+
+   FANN_SIGMOID_STEPWISE - Stepwise linear approximation to sigmoid.
+	 * Faster than sigmoid but a bit less precise.
+
+   FANN_SIGMOID_SYMMETRIC - Symmetric sigmoid activation function, aka. tanh.
+	 * One of the most used activation functions.
+	 * span: -1 < y < 1
+	 * y = tanh(s*x) = 2/(1 + exp(-2*s*x)) - 1
+	 * d = s*(1-(y*y))
+
+   FANN_SIGMOID_SYMMETRIC - Stepwise linear approximation to symmetric sigmoid.
+	 * Faster than symmetric sigmoid but a bit less precise.
+
+   FANN_GAUSSIAN - Gaussian activation function.
+	 * 0 when x = -inf, 1 when x = 0 and 0 when x = inf
+	 * span: 0 < y < 1
+	 * y = exp(-x*s*x*s)
+	 * d = -2*x*s*y*s
+
+   FANN_GAUSSIAN_SYMMETRIC - Symmetric gaussian activation function.
+	 * -1 when x = -inf, 1 when x = 0 and 0 when x = inf
+	 * span: -1 < y < 1
+	 * y = exp(-x*s*x*s)*2-1
+	 * d = -2*x*s*(y+1)*s
+	 
+   FANN_ELLIOT - Fast (sigmoid like) activation function defined by David Elliott
+	 * span: 0 < y < 1
+	 * y = ((x*s) / 2) / (1 + |x*s|) + 0.5
+	 * d = s*1/(2*(1+|x*s|)*(1+|x*s|))
+	 
+   FANN_ELLIOT_SYMMETRIC - Fast (symmetric sigmoid like) activation function defined by David Elliott
+	 * span: -1 < y < 1   
+	 * y = (x*s) / (1 + |x*s|)
+	 * d = s*1/((1+|x*s|)*(1+|x*s|))
+
+	FANN_LINEAR_PIECE - Bounded linear activation function.
+	 * span: 0 < y < 1
+	 * y = x*s, d = 1*s
+	 
+	FANN_LINEAR_PIECE_SYMMETRIC - Bounded Linear activation function.
+	 * span: -1 < y < 1
+	 * y = x*s, d = 1*s
+	 
+	See also:
+		<fann_set_activation_function_hidden>,
+		<fann_set_activation_function_output>
+*/
+enum fann_activationfunc_enum
+{
+	FANN_LINEAR = 0,
+	FANN_THRESHOLD,
+	FANN_THRESHOLD_SYMMETRIC,
+	FANN_SIGMOID,
+	FANN_SIGMOID_STEPWISE,
+	FANN_SIGMOID_SYMMETRIC,
+	FANN_SIGMOID_SYMMETRIC_STEPWISE,
+	FANN_GAUSSIAN,
+	FANN_GAUSSIAN_SYMMETRIC,
+	/* Stepwise linear approximation to gaussian.
+	 * Faster than gaussian but a bit less precise.
+	 * NOT implemented yet.
+	 */
+	FANN_GAUSSIAN_STEPWISE,
+	FANN_ELLIOT,
+	FANN_ELLIOT_SYMMETRIC,
+	FANN_LINEAR_PIECE,
+	FANN_LINEAR_PIECE_SYMMETRIC
+};
+
+/* Constant: FANN_ACTIVATIONFUNC_NAMES
+   
+   Constant array consisting of the names for the activation function, so that the name of an
+   activation function can be received by:
+   (code)
+   char *name = FANN_ACTIVATIONFUNC_NAMES[activation_function];
+   (end)
+
+   See Also:
+      <fann_activationfunc_enum>
+*/
+static char const *const FANN_ACTIVATIONFUNC_NAMES[] = {
+	"FANN_LINEAR",
+	"FANN_THRESHOLD",
+	"FANN_THRESHOLD_SYMMETRIC",
+	"FANN_SIGMOID",
+	"FANN_SIGMOID_STEPWISE",
+	"FANN_SIGMOID_SYMMETRIC",
+	"FANN_SIGMOID_SYMMETRIC_STEPWISE",
+	"FANN_GAUSSIAN",
+	"FANN_GAUSSIAN_SYMMETRIC",
+	"FANN_GAUSSIAN_STEPWISE",
+	"FANN_ELLIOT",
+	"FANN_ELLIOT_SYMMETRIC",
+	"FANN_LINEAR_PIECE",
+	"FANN_LINEAR_PIECE_SYMMETRIC"
+};
+
+/* Enum: fann_errorfunc_enum
+	Error function used during training.
+	
+	FANN_ERRORFUNC_LINEAR - Standard linear error function.
+	FANN_ERRORFUNC_TANH - Tanh error function, usually better 
+		but can require a lower learning rate. This error function agressively targets outputs that
+		differ much from the desired, while not targetting outputs that only differ a little that much.
+		This activation function is not recommended for cascade training and incremental training.
+
+	See also:
+		<fann_set_train_error_function>, <fann_get_train_error_function>
+*/
 enum fann_errorfunc_enum
 {
-	/* Standard linear error function */
 	FANN_ERRORFUNC_LINEAR = 0,
-	/* Tanh error function, usually better but can require
-	 * a lower learning rate */
 	FANN_ERRORFUNC_TANH
 };
 
+/* Constant: FANN_ERRORFUNC_NAMES
+   
+   Constant array consisting of the names for the training error functions, so that the name of an
+   error function can be received by:
+   (code)
+   char *name = FANN_ERRORFUNC_NAMES[error_function];
+   (end)
+
+   See Also:
+      <fann_errorfunc_enum>
+*/
 static char const *const FANN_ERRORFUNC_NAMES[] = {
 	"FANN_ERRORFUNC_LINEAR",
 	"FANN_ERRORFUNC_TANH"
 };
 
-/* Stop function used during training */
+/* Enum: fann_stopfunc_enum
+	Stop criteria used during training.
+
+	FANN_STOPFUNC_MSE - Stop criteria is Mean Square Error (MSE) value.
+	FANN_STOPFUNC_BIT - Stop criteria is number of bits that fail. The number of bits mean the
+		number of output neurons which differ more than the bit fail limit 
+		(see <fann_get_bit_fail_limit>, <fann_set_bit_fail_limit>). 
+		The bits are counted in all of the training data, so this number can be higher than
+		the number of training data.
+
+	See also:
+		<fann_set_train_stop_function>, <fann_get_train_stop_function>
+*/
 enum fann_stopfunc_enum
 {
-	/* Stop criteria is MSE value */
 	FANN_STOPFUNC_MSE = 0,
-	/* Stop criteria is number of bits that fail */
 	FANN_STOPFUNC_BIT
 };
 
+/* Constant: FANN_STOPFUNC_NAMES
+   
+   Constant array consisting of the names for the training stop functions, so that the name of a
+   stop function can be received by:
+   (code)
+   char *name = FANN_STOPFUNC_NAMES[stop_function];
+   (end)
+
+   See Also:
+      <fann_stopfunc_enum>
+*/
 static char const *const FANN_STOPFUNC_NAMES[] = {
 	"FANN_STOPFUNC_MSE",
 	"FANN_STOPFUNC_BIT"
@@ -113,7 +311,11 @@ struct fann_layer
 	struct fann_neuron *last_neuron;
 };
 
-/* Structure used to store error-related information */
+/* Struct: struct fann_error
+   
+	Structure used to store error-related information, both
+	<struct fann> and <struct fann_train_data> can be casted to this type so 
+*/
 struct fann_error
 {
 	enum fann_errno_enum errno_f;
@@ -122,7 +324,17 @@ struct fann_error
 };
 
 
-/* The fast artificial neural network(fann) structure
+/* 	Struct: struct fann
+	The fast artificial neural network(fann) structure.
+
+	Data within this structure should never be accessed directly, but only by using the
+	*fann_get_...* and *fann_set_...* functions.
+
+	The fann structure is created using one of the *fann_create_...* functions and each of
+	the functions which operates on the structure takes *struct fann * ann* as the first parameter.
+
+	See also:
+		<fann_create_standard>, <fann_destroy>
  */
 struct fann
 {
@@ -364,18 +576,4 @@ struct fann
 	fann_type *prev_train_slopes;
 };
 
-/* Structure used to store data, for use with training. */
-struct fann_train_data
-{
-	enum fann_errno_enum errno_f;
-	FILE *error_log;
-	char *errstr;
-
-	unsigned int num_data;
-	unsigned int num_input;
-	unsigned int num_output;
-	fann_type **input;
-	fann_type **output;
-};
-
 #endif
diff --git a/src/include/fann_errno.h b/src/include/fann_errno.h
deleted file mode 100644
index d65df18..0000000
--- a/src/include/fann_errno.h
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
-Fast Artificial Neural Network Library (fann)
-Copyright (C) 2003 Steffen Nissen (lukesky at 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
-*/
-
-#ifndef __fann_errno_h__
-#define __fann_errno_h__
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif							/* __cplusplus */
-
-/* Maximum length (in bytes) of an error message */
-#define FANN_ERRSTR_MAX 128
-
-	enum fann_errno_enum
-	{
-		/* No error */
-		FANN_E_NO_ERROR = 0,
-
-		/* Unable to open configuration file for reading */
-		FANN_E_CANT_OPEN_CONFIG_R,
-
-		/* Unable to open configuration file for writing */
-		FANN_E_CANT_OPEN_CONFIG_W,
-
-		/* Wrong version of configuration file */
-		FANN_E_WRONG_CONFIG_VERSION,
-
-		/* Error reading info from configuration file */
-		FANN_E_CANT_READ_CONFIG,
-
-		/* Error reading neuron info from configuration file */
-		FANN_E_CANT_READ_NEURON,
-
-		/* Error reading connections from configuration file */
-		FANN_E_CANT_READ_CONNECTIONS,
-
-		/* Number of connections not equal to the number expected. */
-		FANN_E_WRONG_NUM_CONNECTIONS,
-
-		/* Unable to open train data file for writing */
-		FANN_E_CANT_OPEN_TD_W,
-
-		/* Unable to open train data file for reading. */
-		FANN_E_CANT_OPEN_TD_R,
-
-		/* Error reading training data from file. */
-		FANN_E_CANT_READ_TD,
-
-		/* Unable to allocate memory. */
-		FANN_E_CANT_ALLOCATE_MEM,
-
-		/* Unable to train with the selected activation function */
-		FANN_E_CANT_TRAIN_ACTIVATION,
-
-		/* Unable to use the selected activation function */
-		FANN_E_CANT_USE_ACTIVATION,
-
-		/* Irreconcilable differences between two fann_train_data structures */
-		FANN_E_TRAIN_DATA_MISMATCH,
-
-		/* Unable to use the selected training algorithm */
-		FANN_E_CANT_USE_TRAIN_ALG
-	};
-
-#ifdef __cplusplus
-}
-#endif							/* __cplusplus */
-
-#endif							/* __fann_errno_h__ */
diff --git a/src/include/fann_error.h b/src/include/fann_error.h
index e1463fd..dbb82c1 100644
--- a/src/include/fann_error.h
+++ b/src/include/fann_error.h
@@ -20,7 +20,57 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 #ifndef __fann_error_h__
 #define __fann_error_h__
 
-/* Package: FANN Error Handling */
+#include <stdio.h>
+
+#define FANN_ERRSTR_MAX 128
+struct fann_error;
+
+/* Section: FANN Error Handling */
+
+/* Enum: fann_errno_enum
+	Used to define error events on <struct fann> and <struct fann_train_data>. 
+
+	See also:
+		<fann_get_errno>, <fann_reset_errno>, <fann_get_errstr>
+
+	FANN_E_NO_ERROR - No error 
+	FANN_E_CANT_OPEN_CONFIG_R - Unable to open configuration file for reading 
+	FANN_E_CANT_OPEN_CONFIG_W - Unable to open configuration file for writing
+	FANN_E_WRONG_CONFIG_VERSION - Wrong version of configuration file 
+	FANN_E_CANT_READ_CONFIG - Error reading info from configuration file
+	FANN_E_CANT_READ_NEURON - Error reading neuron info from configuration file
+	FANN_E_CANT_READ_CONNECTIONS - Error reading connections from configuration file
+	FANN_E_WRONG_NUM_CONNECTIONS - Number of connections not equal to the number expected
+	FANN_E_CANT_OPEN_TD_W - Unable to open train data file for writing
+	FANN_E_CANT_OPEN_TD_R - Unable to open train data file for reading
+	FANN_E_CANT_READ_TD - Error reading training data from file
+	FANN_E_CANT_ALLOCATE_MEM - Unable to allocate memory
+	FANN_E_CANT_TRAIN_ACTIVATION - Unable to train with the selected activation function
+	FANN_E_CANT_USE_ACTIVATION - Unable to use the selected activation function
+	FANN_E_TRAIN_DATA_MISMATCH - Irreconcilable differences between two <struct fann_train_data> structures
+	FANN_E_CANT_USE_TRAIN_ALG - Unable to use the selected training algorithm
+*/
+enum fann_errno_enum
+{
+	FANN_E_NO_ERROR = 0,
+	FANN_E_CANT_OPEN_CONFIG_R,
+	FANN_E_CANT_OPEN_CONFIG_W,
+	FANN_E_WRONG_CONFIG_VERSION,
+	FANN_E_CANT_READ_CONFIG,
+	FANN_E_CANT_READ_NEURON,
+	FANN_E_CANT_READ_CONNECTIONS,
+	FANN_E_WRONG_NUM_CONNECTIONS,
+	FANN_E_CANT_OPEN_TD_W,
+	FANN_E_CANT_OPEN_TD_R,
+	FANN_E_CANT_READ_TD,
+	FANN_E_CANT_ALLOCATE_MEM,
+	FANN_E_CANT_TRAIN_ACTIVATION,
+	FANN_E_CANT_USE_ACTIVATION,
+	FANN_E_TRAIN_DATA_MISMATCH,
+	FANN_E_CANT_USE_TRAIN_ALG
+};
+
+/* Group: Error Handling */
 	
 /* Function: fann_set_error_log
 
diff --git a/src/include/fann_internal.h b/src/include/fann_internal.h
index 677aeb9..1d900f6 100644
--- a/src/include/fann_internal.h
+++ b/src/include/fann_internal.h
@@ -52,8 +52,9 @@ FANN_EXTERNAL void FANN_API fann_set_ ## name(struct fann *ann, type value) \
 FANN_GET(type, name) \
 FANN_SET(type, name)
 
+struct fann_train_data;
 
-struct fann *fann_allocate_structure(float learning_rate, unsigned int num_layers);
+struct fann *fann_allocate_structure(unsigned int num_layers);
 void fann_allocate_neurons(struct fann *ann);
 
 void fann_allocate_connections(struct fann *ann);
diff --git a/src/include/fann_io.h b/src/include/fann_io.h
index 5306d41..fc8544a 100644
--- a/src/include/fann_io.h
+++ b/src/include/fann_io.h
@@ -20,7 +20,9 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 #ifndef __fann_io_h__
 #define __fann_io_h__
 	
-/* Package: FANN Input/Output */	
+/* Section: FANN File Input/Output */	
+
+/* Group: File Input and Output */	
 	
 /* Function: fann_create_from_file
    Constructs a backpropagation neural network from a configuration file.
diff --git a/src/include/fann_train.h b/src/include/fann_train.h
index e37d7c0..a30524e 100644
--- a/src/include/fann_train.h
+++ b/src/include/fann_train.h
@@ -20,7 +20,33 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 #ifndef __fann_train_h__
 #define __fann_train_h__
 
-/* Package: FANN Training */
+/* Section: FANN Training */
+
+/* Struct: struct fann_train_data
+	Structure used to store data, for use with training.
+	
+	The data inside this structure should never be manipulated directly, but should use some 
+	of the supplied functions in <Training Data>.
+	
+	See also:
+	<fann_read_train_from_file>, <fann_train_on_data>, <fann_destroy_train>
+*/
+struct fann_train_data
+{
+	enum fann_errno_enum errno_f;
+	FILE *error_log;
+	char *errstr;
+
+	unsigned int num_data;
+	unsigned int num_input;
+	unsigned int num_output;
+	fann_type **input;
+	fann_type **output;
+};
+
+/* Section: FANN Training */
+
+/* Group: Training */
 
 #ifndef FIXEDFANN
 /* Function: fann_train
@@ -49,8 +75,167 @@ FANN_EXTERNAL float FANN_API fann_get_MSE(struct fann *ann);
    Resets the mean square error from the network.
  */ 
 FANN_EXTERNAL void FANN_API fann_reset_MSE(struct fann *ann);
+
+/* Group: Training Data */
+
+/* Function: fann_read_train_from_file
+   Reads a file that stores training data, in the format:
+   num_train_data num_input num_output\n
+   inputdata seperated by space\n
+   outputdata seperated by space\n
+
+   .
+   .
+   .
+   
+   inputdata seperated by space\n
+   outputdata seperated by space\n
+*/ 
+FANN_EXTERNAL struct fann_train_data *FANN_API fann_read_train_from_file(char *filename);
+
+
+/* Function: fann_destroy_train
+   Destructs the training data
+   Be sure to call this function after finished using the training data.
+ */ 
+FANN_EXTERNAL void FANN_API fann_destroy_train(struct fann_train_data *train_data);
+
+
+#ifndef FIXEDFANN
+	
+/* Function: fann_train_epoch
+   Train one epoch with a set of training data.
+ */ 
+FANN_EXTERNAL float FANN_API fann_train_epoch(struct fann *ann, struct fann_train_data *data);
+
+
+/* Function: fann_test_data
+   Test a set of training data and calculate the MSE
+ */ 
+FANN_EXTERNAL float FANN_API fann_test_data(struct fann *ann, struct fann_train_data *data);
+
+
+/* Function: fann_train_on_data
+
+   Trains on an entire dataset, for a maximum of max_epochs
+   epochs or until mean square error is lower than desired_error.
+   Reports about the progress is given every
+   epochs_between_reports epochs.
+   If epochs_between_reports is zero, no reports are given.
+*/ 
+FANN_EXTERNAL void FANN_API fann_train_on_data(struct fann *ann, struct fann_train_data *data,
+											   unsigned int max_epochs,
+											   unsigned int epochs_between_reports,
+											   float desired_error);
+
+
+/* Function: fann_train_on_data_callback
+   
+   Same as fann_train_on_data, but a callback function is given,
+   which can be used to print out reports. (effective for gui programming).
+   If the callback returns -1, then the training is terminated, otherwise
+   it continues until the normal stop criteria.
+*/ 
+FANN_EXTERNAL void FANN_API fann_train_on_data_callback(struct fann *ann,
+														struct fann_train_data *data,
+														unsigned int max_epochs,
+														unsigned int epochs_between_reports,
+														float desired_error,
+														int (FANN_API *
+															 callback) (unsigned int epochs,
+																		float error));
+
+
+/* Function: fann_train_on_file
+   
+   Does the same as train_on_data, but reads the data directly from a file.
+ */ 
+FANN_EXTERNAL void FANN_API fann_train_on_file(struct fann *ann, char *filename,
+											   unsigned int max_epochs,
+											   unsigned int epochs_between_reports,
+											   float desired_error);
+
+
+/* Function: fann_train_on_file_callback
+   
+   Does the same as train_on_data_callback, but
+   reads the data directly from a file.
+ */ 
+FANN_EXTERNAL void FANN_API fann_train_on_file_callback(struct fann *ann, char *filename,
+														unsigned int max_epochs,
+														unsigned int epochs_between_reports,
+														float desired_error,
+														int (FANN_API *
+															 callback) (unsigned int epochs,
+																		float error));
+
+
+/* Function: fann_shuffle_train_data
+   
+   shuffles training data, randomizing the order
+ */ 
+FANN_EXTERNAL void FANN_API fann_shuffle_train_data(struct fann_train_data *train_data);
+
+
+/* Function: fann_scale_input_train_data
+   
+   Scales the inputs in the training data to the specified range
+ */ 
+FANN_EXTERNAL void FANN_API fann_scale_input_train_data(struct fann_train_data *train_data,
+														fann_type new_min, fann_type new_max);
+
+
+/* Function: fann_scale_output_train_data
+   
+   Scales the inputs in the training data to the specified range
+ */ 
+FANN_EXTERNAL void FANN_API fann_scale_output_train_data(struct fann_train_data *train_data,
+														 fann_type new_min, fann_type new_max);
+
+
+/* Function: fann_scale_train_data
+   
+   Scales the inputs in the training data to the specified range
+ */ 
+FANN_EXTERNAL void FANN_API fann_scale_train_data(struct fann_train_data *train_data,
+												  fann_type new_min, fann_type new_max);
+
+
+/* Function: fann_merge_train_data
+   
+   merges training data into a single struct.
+ */ 
+FANN_EXTERNAL struct fann_train_data *FANN_API fann_merge_train_data(struct fann_train_data *data1,
+																	 struct fann_train_data *data2);
+
+
+/* Function: fann_duplicate_train_data
+   
+   return a copy of a fann_train_data struct
+ */ 
+FANN_EXTERNAL struct fann_train_data *FANN_API fann_duplicate_train_data(struct fann_train_data
+																		 *data);
+
+
+#endif	/* NOT FIXEDFANN */
 	
-/* Package: Parameters */
+/* Function: fann_save_train
+   
+   Save the training structure to a file.
+ */ 
+FANN_EXTERNAL void FANN_API fann_save_train(struct fann_train_data *data, char *filename);
+
+
+/* Function: fann_save_train_to_fixed
+   
+   Saves the training structure to a fixed point data file.
+ *  (Very usefull for testing the quality of a fixed point network).
+ */ 
+FANN_EXTERNAL void FANN_API fann_save_train_to_fixed(struct fann_train_data *data, char *filename,
+													 unsigned int decimal_point);
+
+
+/* Group: Parameters */
 
 /* Function: fann_get_training_algorithm
 
@@ -132,7 +317,7 @@ FANN_EXTERNAL void FANN_API fann_set_train_error_function(struct fann *ann,
 FANN_EXTERNAL enum fann_errorfunc_enum FANN_API fann_get_train_error_function(struct fann *ann);
 
 
-/* Function: fann_get_train_stop_function
+/* Function: fann_set_train_stop_function
 
    Set the stop function used during training. (default FANN_STOPFUNC_MSE)
  */ 
@@ -146,6 +331,22 @@ FANN_EXTERNAL void FANN_API fann_set_train_stop_function(struct fann *ann,
  */ 
 FANN_EXTERNAL enum fann_stopfunc_enum FANN_API fann_get_train_stop_function(struct fann *ann);
 
+/* Function: fann_get_bit_fail_limit
+
+   Get the bit fail limit used during training.
+ */ 
+FANN_EXTERNAL fann_type FANN_API fann_get_bit_fail_limit(struct fann *ann);
+
+/* Function: fann_set_bit_fail_limit
+
+   Set the bit fail limit used during training. (default 0.35)
+  
+   The bit fail limit is the maximum difference between the actual output and the desired output 
+   which is accepted when counting the bit fails.
+   This difference is multiplied by two when dealing with symmetric activation functions,
+   so that symmetric and not symmetric activation functions can use the same limit.
+ */ 
+FANN_EXTERNAL void FANN_API fann_set_bit_fail_limit(struct fann *ann, fann_type bit_fail_limit);
 
 /* Function: fann_get_quickprop_decay
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/libfann.git



More information about the debian-science-commits mailing list