[libfann] 193/242: *** empty log message ***
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 ae4759b9e8855d6292fb5e911633f8568f7abbcc
Author: Steffen Nissen <lukesky at diku.dk>
Date: Tue Sep 20 16:12:20 2005 +0000
*** empty log message ***
---
fann.prj | 8 +-
src/doublefann.c | 1 -
src/fann.c | 128 ++++++++++++
src/fann_cascade.c | 71 +++++++
src/fann_options.c | 312 -----------------------------
src/fann_train.c | 72 +++++++
src/fixedfann.c | 1 -
src/floatfann.c | 1 -
src/include/fann.h | 468 ++++++--------------------------------------
src/include/fann_cascade.h | 162 +++++++++++++++
src/include/fann_error.h | 67 +++++++
src/include/fann_internal.h | 17 ++
src/include/fann_io.h | 65 ++++++
src/include/fann_train.h | 225 +++++++++++++++++++++
14 files changed, 875 insertions(+), 723 deletions(-)
diff --git a/fann.prj b/fann.prj
index 34f0b01..41dd998 100644
--- a/fann.prj
+++ b/fann.prj
@@ -78,7 +78,13 @@ module.include.files=\
src/include/fann_errno.h\
src/include/fann_internal.h\
src/include/fixedfann.h\
- src/include/floatfann.h
+ src/include/floatfann.h\
+ 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
module.source.name=.
module.source.type=
diff --git a/src/doublefann.c b/src/doublefann.c
index 94083bf..e7f9e77 100644
--- a/src/doublefann.c
+++ b/src/doublefann.c
@@ -25,6 +25,5 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#include "fann_io.c"
#include "fann_train.c"
#include "fann_train_data.c"
-#include "fann_options.c"
#include "fann_error.c"
#include "fann_cascade.c"
diff --git a/src/fann.c b/src/fann.c
index b6dd69b..d7823a3 100644
--- a/src/fann.c
+++ b/src/fann.c
@@ -918,6 +918,134 @@ FANN_EXTERNAL void FANN_API fann_init_weights(struct fann *ann, struct fann_trai
#endif
}
+FANN_EXTERNAL void FANN_API fann_print_parameters(struct fann *ann)
+{
+ struct fann_layer *layer_it;
+
+ 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++)
+ {
+ if(ann->shortcut_connections)
+ {
+ printf(" Hidden layer :%4d neurons, 0 bias\n",
+ layer_it->last_neuron - layer_it->first_neuron);
+ }
+ else
+ {
+ printf(" Hidden layer :%4d neurons, 1 bias\n",
+ layer_it->last_neuron - layer_it->first_neuron - 1);
+ }
+ }
+ printf("Output layer :%4d neurons\n", ann->num_output);
+ printf("Total neurons and biases :%4d\n", fann_get_total_neurons(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);
+*/
+ printf("Decimal point :%4d\n", ann->decimal_point);
+ printf("Multiplier :%4d\n", ann->multiplier);
+#endif
+ printf("Training error function : %s\n", FANN_ERRORFUNC_NAMES[ann->train_error_function]);
+ 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);
+ printf("RPROP decrease factor : %5.2f\n", ann->rprop_decrease_factor);
+ 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 stagnation epochs :%4d\n", ann->cascade_stagnation_epochs);
+ printf("Cascade no. of candidates :%4d\n", fann_get_cascade_num_candidates(ann));
+}
+
+FANN_GET(unsigned int, num_input)
+FANN_GET(unsigned int, num_output)
+
+FANN_EXTERNAL unsigned int FANN_API fann_get_total_neurons(struct fann *ann)
+{
+ if(ann->shortcut_connections)
+ {
+ return ann->total_neurons;
+ }
+ else
+ {
+ /* -1, because there is always an unused bias neuron in the last layer */
+ return ann->total_neurons - 1;
+ }
+}
+
+FANN_GET(unsigned int, total_connections)
+
+#ifdef FIXEDFANN
+
+FANN_GET(unsigned int, decimal_point)
+FANN_GET(unsigned int, multiplier)
+
+/* INTERNAL FUNCTION
+ Adjust the steepwise functions (if used)
+*/
+void fann_update_stepwise(struct fann *ann)
+{
+ unsigned int i = 0;
+
+ /* Calculate the parameters for the stepwise linear
+ * sigmoid function fixed point.
+ * Using a rewritten sigmoid function.
+ * results 0.005, 0.05, 0.25, 0.75, 0.95, 0.995
+ */
+ ann->sigmoid_results[0] = fann_max((fann_type) (ann->multiplier / 200.0 + 0.5), 1);
+ ann->sigmoid_results[1] = (fann_type) (ann->multiplier / 20.0 + 0.5);
+ ann->sigmoid_results[2] = (fann_type) (ann->multiplier / 4.0 + 0.5);
+ ann->sigmoid_results[3] = ann->multiplier - (fann_type) (ann->multiplier / 4.0 + 0.5);
+ ann->sigmoid_results[4] = ann->multiplier - (fann_type) (ann->multiplier / 20.0 + 0.5);
+ ann->sigmoid_results[5] =
+ fann_min(ann->multiplier - (fann_type) (ann->multiplier / 200.0 + 0.5),
+ ann->multiplier - 1);
+
+ ann->sigmoid_symmetric_results[0] =
+ fann_max((fann_type) ((ann->multiplier / 100.0) - ann->multiplier - 0.5),
+ (fann_type) (1 - (fann_type) ann->multiplier));
+ ann->sigmoid_symmetric_results[1] =
+ (fann_type) ((ann->multiplier / 10.0) - ann->multiplier - 0.5);
+ ann->sigmoid_symmetric_results[2] =
+ (fann_type) ((ann->multiplier / 2.0) - ann->multiplier - 0.5);
+ ann->sigmoid_symmetric_results[3] = ann->multiplier - (fann_type) (ann->multiplier / 2.0 + 0.5);
+ ann->sigmoid_symmetric_results[4] =
+ ann->multiplier - (fann_type) (ann->multiplier / 10.0 + 0.5);
+ ann->sigmoid_symmetric_results[5] =
+ fann_min(ann->multiplier - (fann_type) (ann->multiplier / 100.0 + 1.0),
+ ann->multiplier - 1);
+
+ for(i = 0; i < 6; i++)
+ {
+ ann->sigmoid_values[i] =
+ (fann_type) (((log(ann->multiplier / (float) ann->sigmoid_results[i] - 1) *
+ (float) ann->multiplier) / -2.0) * (float) ann->multiplier);
+ ann->sigmoid_symmetric_values[i] =
+ (fann_type) (((log
+ ((ann->multiplier -
+ (float) ann->sigmoid_symmetric_results[i]) /
+ ((float) ann->sigmoid_symmetric_results[i] +
+ ann->multiplier)) * (float) ann->multiplier) / -2.0) *
+ (float) ann->multiplier);
+ }
+}
+#endif
+
+
/* INTERNAL FUNCTION
Allocates the main structure and sets some default values.
*/
diff --git a/src/fann_cascade.c b/src/fann_cascade.c
index 8a016cf..79971b9 100644
--- a/src/fann_cascade.c
+++ b/src/fann_cascade.c
@@ -954,3 +954,74 @@ void fann_install_candidate(struct fann *ann)
}
#endif /* FIXEDFANN */
+
+FANN_EXTERNAL unsigned int FANN_API fann_get_cascade_num_candidates(struct fann *ann)
+{
+ return ann->cascade_activation_functions_count *
+ ann->cascade_activation_steepnesses_count *
+ ann->cascade_num_candidate_groups;
+}
+
+FANN_GET_SET(float, cascade_change_fraction)
+FANN_GET_SET(unsigned int, cascade_stagnation_epochs)
+FANN_GET_SET(unsigned int, cascade_num_candidate_groups)
+FANN_GET_SET(fann_type, cascade_weight_multiplier)
+FANN_GET_SET(fann_type, cascade_candidate_limit)
+FANN_GET_SET(unsigned int, cascade_max_out_epochs)
+FANN_GET_SET(unsigned int, cascade_max_cand_epochs)
+
+FANN_GET(unsigned int, cascade_activation_functions_count)
+FANN_GET(enum fann_activationfunc_enum *, cascade_activation_functions)
+
+FANN_EXTERNAL void fann_set_cascade_activation_functions(struct fann *ann,
+ enum fann_activationfunc_enum *
+ cascade_activation_functions,
+ unsigned int
+ cascade_activation_functions_count)
+{
+ if(ann->cascade_activation_functions_count != cascade_activation_functions_count)
+ {
+ ann->cascade_activation_functions_count = cascade_activation_functions_count;
+
+ /* reallocate mem */
+ ann->cascade_activation_functions =
+ (enum fann_activationfunc_enum *)realloc(ann->cascade_activation_functions,
+ ann->cascade_activation_functions_count * sizeof(enum fann_activationfunc_enum));
+ if(ann->cascade_activation_functions == NULL)
+ {
+ fann_error((struct fann_error*)ann, FANN_E_CANT_ALLOCATE_MEM);
+ return;
+ }
+ }
+
+ memmove(ann->cascade_activation_functions, cascade_activation_functions,
+ ann->cascade_activation_functions_count * sizeof(enum fann_activationfunc_enum));
+}
+
+FANN_GET(unsigned int, cascade_activation_steepnesses_count)
+FANN_GET(fann_type *, cascade_activation_steepnesses)
+
+FANN_EXTERNAL void fann_set_cascade_activation_steepnesses(struct fann *ann,
+ fann_type *
+ cascade_activation_steepnesses,
+ unsigned int
+ cascade_activation_steepnesses_count)
+{
+ if(ann->cascade_activation_steepnesses_count != cascade_activation_steepnesses_count)
+ {
+ ann->cascade_activation_steepnesses_count = cascade_activation_steepnesses_count;
+
+ /* reallocate mem */
+ ann->cascade_activation_steepnesses =
+ (fann_type *)realloc(ann->cascade_activation_steepnesses,
+ ann->cascade_activation_steepnesses_count * sizeof(fann_type));
+ if(ann->cascade_activation_steepnesses == NULL)
+ {
+ fann_error((struct fann_error*)ann, FANN_E_CANT_ALLOCATE_MEM);
+ return;
+ }
+ }
+
+ memmove(ann->cascade_activation_steepnesses, cascade_activation_steepnesses,
+ ann->cascade_activation_steepnesses_count * sizeof(fann_type));
+}
diff --git a/src/fann_options.c b/src/fann_options.c
deleted file mode 100644
index 45f5849..0000000
--- a/src/fann_options.c
+++ /dev/null
@@ -1,312 +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
-*/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdarg.h>
-#include <string.h>
-
-#include "config.h"
-#include "fann.h"
-#include "fann_errno.h"
-
-FANN_EXTERNAL void FANN_API fann_print_parameters(struct fann *ann)
-{
- struct fann_layer *layer_it;
-
- 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++)
- {
- if(ann->shortcut_connections)
- {
- printf(" Hidden layer :%4d neurons, 0 bias\n",
- layer_it->last_neuron - layer_it->first_neuron);
- }
- else
- {
- printf(" Hidden layer :%4d neurons, 1 bias\n",
- layer_it->last_neuron - layer_it->first_neuron - 1);
- }
- }
- printf("Output layer :%4d neurons\n", ann->num_output);
- printf("Total neurons and biases :%4d\n", fann_get_total_neurons(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);
-*/
- printf("Decimal point :%4d\n", ann->decimal_point);
- printf("Multiplier :%4d\n", ann->multiplier);
-#endif
- printf("Training error function : %s\n", FANN_ERRORFUNC_NAMES[ann->train_error_function]);
- 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);
- printf("RPROP decrease factor : %5.2f\n", ann->rprop_decrease_factor);
- 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 stagnation epochs :%4d\n", ann->cascade_stagnation_epochs);
- printf("Cascade no. of candidates :%4d\n", fann_get_cascade_num_candidates(ann));
-}
-
-#define FANN_GET(type, name) \
-FANN_EXTERNAL type FANN_API fann_get_ ## name(struct fann *ann) \
-{ \
- return ann->name; \
-}
-
-#define FANN_SET(type, name) \
-FANN_EXTERNAL void FANN_API fann_set_ ## name(struct fann *ann, type value) \
-{ \
- ann->name = value; \
-}
-
-#define FANN_GET_SET(type, name) \
-FANN_GET(type, name) \
-FANN_SET(type, name)
-
-FANN_GET_SET(enum fann_train_enum, training_algorithm)
-FANN_GET_SET(float, learning_rate)
-
-FANN_EXTERNAL void FANN_API fann_set_activation_function_hidden(struct fann *ann,
- enum fann_activationfunc_enum activation_function)
-{
- struct fann_neuron *last_neuron, *neuron_it;
- struct fann_layer *layer_it;
- struct fann_layer *last_layer = ann->last_layer - 1; /* -1 to not update the output layer */
-
- for(layer_it = ann->first_layer + 1; layer_it != last_layer; layer_it++)
- {
- last_neuron = layer_it->last_neuron;
- for(neuron_it = layer_it->first_neuron; neuron_it != last_neuron; neuron_it++)
- {
- neuron_it->activation_function = activation_function;
- }
- }
-}
-
-FANN_EXTERNAL void FANN_API fann_set_activation_function_output(struct fann *ann,
- enum fann_activationfunc_enum activation_function)
-{
- struct fann_neuron *last_neuron, *neuron_it;
- struct fann_layer *last_layer = ann->last_layer - 1;
-
- last_neuron = last_layer->last_neuron;
- for(neuron_it = last_layer->first_neuron; neuron_it != last_neuron; neuron_it++)
- {
- neuron_it->activation_function = activation_function;
- }
-}
-
-FANN_EXTERNAL void FANN_API fann_set_activation_steepness_hidden(struct fann *ann,
- fann_type steepness)
-{
- struct fann_neuron *last_neuron, *neuron_it;
- struct fann_layer *layer_it;
- struct fann_layer *last_layer = ann->last_layer - 1; /* -1 to not update the output layer */
-
- for(layer_it = ann->first_layer + 1; layer_it != last_layer; layer_it++)
- {
- last_neuron = layer_it->last_neuron;
- for(neuron_it = layer_it->first_neuron; neuron_it != last_neuron; neuron_it++)
- {
- neuron_it->activation_steepness = steepness;
- }
- }
-}
-
-FANN_EXTERNAL void FANN_API fann_set_activation_steepness_output(struct fann *ann,
- fann_type steepness)
-{
- struct fann_neuron *last_neuron, *neuron_it;
- struct fann_layer *last_layer = ann->last_layer - 1;
-
- last_neuron = last_layer->last_neuron;
- for(neuron_it = last_layer->first_neuron; neuron_it != last_neuron; neuron_it++)
- {
- neuron_it->activation_steepness = steepness;
- }
-}
-
-FANN_GET(unsigned int, num_input)
-FANN_GET(unsigned int, num_output)
-
-FANN_EXTERNAL unsigned int FANN_API fann_get_total_neurons(struct fann *ann)
-{
- if(ann->shortcut_connections)
- {
- return ann->total_neurons;
- }
- else
- {
- /* -1, because there is always an unused bias neuron in the last layer */
- return ann->total_neurons - 1;
- }
-}
-
-FANN_GET(unsigned int, total_connections)
-FANN_GET_SET(enum fann_errorfunc_enum, train_error_function)
-FANN_GET_SET(float, quickprop_decay)
-FANN_GET_SET(float, quickprop_mu)
-FANN_GET_SET(float, rprop_increase_factor)
-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_EXTERNAL unsigned int FANN_API fann_get_cascade_num_candidates(struct fann *ann)
-{
- return ann->cascade_activation_functions_count *
- ann->cascade_activation_steepnesses_count *
- ann->cascade_num_candidate_groups;
-}
-
-FANN_GET_SET(float, cascade_change_fraction)
-FANN_GET_SET(unsigned int, cascade_stagnation_epochs)
-FANN_GET_SET(unsigned int, cascade_num_candidate_groups)
-FANN_GET_SET(fann_type, cascade_weight_multiplier)
-FANN_GET_SET(fann_type, cascade_candidate_limit)
-FANN_GET_SET(unsigned int, cascade_max_out_epochs)
-FANN_GET_SET(unsigned int, cascade_max_cand_epochs)
-
-FANN_GET(unsigned int, cascade_activation_functions_count)
-FANN_GET(enum fann_activationfunc_enum *, cascade_activation_functions)
-
-FANN_EXTERNAL void fann_set_cascade_activation_functions(struct fann *ann,
- enum fann_activationfunc_enum *
- cascade_activation_functions,
- unsigned int
- cascade_activation_functions_count)
-{
- if(ann->cascade_activation_functions_count != cascade_activation_functions_count)
- {
- ann->cascade_activation_functions_count = cascade_activation_functions_count;
-
- /* reallocate mem */
- ann->cascade_activation_functions =
- (enum fann_activationfunc_enum *)realloc(ann->cascade_activation_functions,
- ann->cascade_activation_functions_count * sizeof(enum fann_activationfunc_enum));
- if(ann->cascade_activation_functions == NULL)
- {
- fann_error((struct fann_error*)ann, FANN_E_CANT_ALLOCATE_MEM);
- return;
- }
- }
-
- memmove(ann->cascade_activation_functions, cascade_activation_functions,
- ann->cascade_activation_functions_count * sizeof(enum fann_activationfunc_enum));
-}
-
-FANN_GET(unsigned int, cascade_activation_steepnesses_count)
-FANN_GET(fann_type *, cascade_activation_steepnesses)
-
-FANN_EXTERNAL void fann_set_cascade_activation_steepnesses(struct fann *ann,
- fann_type *
- cascade_activation_steepnesses,
- unsigned int
- cascade_activation_steepnesses_count)
-{
- if(ann->cascade_activation_steepnesses_count != cascade_activation_steepnesses_count)
- {
- ann->cascade_activation_steepnesses_count = cascade_activation_steepnesses_count;
-
- /* reallocate mem */
- ann->cascade_activation_steepnesses =
- (fann_type *)realloc(ann->cascade_activation_steepnesses,
- ann->cascade_activation_steepnesses_count * sizeof(fann_type));
- if(ann->cascade_activation_steepnesses == NULL)
- {
- fann_error((struct fann_error*)ann, FANN_E_CANT_ALLOCATE_MEM);
- return;
- }
- }
-
- memmove(ann->cascade_activation_steepnesses, cascade_activation_steepnesses,
- ann->cascade_activation_steepnesses_count * sizeof(fann_type));
-}
-
-#ifdef FIXEDFANN
-
-FANN_GET(unsigned int, decimal_point)
-FANN_GET(unsigned int, multiplier)
-
-/* INTERNAL FUNCTION
- Adjust the steepwise functions (if used)
-*/
-void fann_update_stepwise(struct fann *ann)
-{
- unsigned int i = 0;
-
- /* Calculate the parameters for the stepwise linear
- * sigmoid function fixed point.
- * Using a rewritten sigmoid function.
- * results 0.005, 0.05, 0.25, 0.75, 0.95, 0.995
- */
- ann->sigmoid_results[0] = fann_max((fann_type) (ann->multiplier / 200.0 + 0.5), 1);
- ann->sigmoid_results[1] = (fann_type) (ann->multiplier / 20.0 + 0.5);
- ann->sigmoid_results[2] = (fann_type) (ann->multiplier / 4.0 + 0.5);
- ann->sigmoid_results[3] = ann->multiplier - (fann_type) (ann->multiplier / 4.0 + 0.5);
- ann->sigmoid_results[4] = ann->multiplier - (fann_type) (ann->multiplier / 20.0 + 0.5);
- ann->sigmoid_results[5] =
- fann_min(ann->multiplier - (fann_type) (ann->multiplier / 200.0 + 0.5),
- ann->multiplier - 1);
-
- ann->sigmoid_symmetric_results[0] =
- fann_max((fann_type) ((ann->multiplier / 100.0) - ann->multiplier - 0.5),
- (fann_type) (1 - (fann_type) ann->multiplier));
- ann->sigmoid_symmetric_results[1] =
- (fann_type) ((ann->multiplier / 10.0) - ann->multiplier - 0.5);
- ann->sigmoid_symmetric_results[2] =
- (fann_type) ((ann->multiplier / 2.0) - ann->multiplier - 0.5);
- ann->sigmoid_symmetric_results[3] = ann->multiplier - (fann_type) (ann->multiplier / 2.0 + 0.5);
- ann->sigmoid_symmetric_results[4] =
- ann->multiplier - (fann_type) (ann->multiplier / 10.0 + 0.5);
- ann->sigmoid_symmetric_results[5] =
- fann_min(ann->multiplier - (fann_type) (ann->multiplier / 100.0 + 1.0),
- ann->multiplier - 1);
-
- for(i = 0; i < 6; i++)
- {
- ann->sigmoid_values[i] =
- (fann_type) (((log(ann->multiplier / (float) ann->sigmoid_results[i] - 1) *
- (float) ann->multiplier) / -2.0) * (float) ann->multiplier);
- ann->sigmoid_symmetric_values[i] =
- (fann_type) (((log
- ((ann->multiplier -
- (float) ann->sigmoid_symmetric_results[i]) /
- ((float) ann->sigmoid_symmetric_results[i] +
- ann->multiplier)) * (float) ann->multiplier) / -2.0) *
- (float) ann->multiplier);
- }
-}
-#endif
diff --git a/src/fann_train.c b/src/fann_train.c
index d3d9728..7cef28b 100644
--- a/src/fann_train.c
+++ b/src/fann_train.c
@@ -770,3 +770,75 @@ void fann_update_weights_irpropm(struct fann *ann, unsigned int first_weight, un
}
#endif
+
+FANN_GET_SET(enum fann_train_enum, training_algorithm)
+FANN_GET_SET(float, learning_rate)
+
+FANN_EXTERNAL void FANN_API fann_set_activation_function_hidden(struct fann *ann,
+ enum fann_activationfunc_enum activation_function)
+{
+ struct fann_neuron *last_neuron, *neuron_it;
+ struct fann_layer *layer_it;
+ struct fann_layer *last_layer = ann->last_layer - 1; /* -1 to not update the output layer */
+
+ for(layer_it = ann->first_layer + 1; layer_it != last_layer; layer_it++)
+ {
+ last_neuron = layer_it->last_neuron;
+ for(neuron_it = layer_it->first_neuron; neuron_it != last_neuron; neuron_it++)
+ {
+ neuron_it->activation_function = activation_function;
+ }
+ }
+}
+
+FANN_EXTERNAL void FANN_API fann_set_activation_function_output(struct fann *ann,
+ enum fann_activationfunc_enum activation_function)
+{
+ struct fann_neuron *last_neuron, *neuron_it;
+ struct fann_layer *last_layer = ann->last_layer - 1;
+
+ last_neuron = last_layer->last_neuron;
+ for(neuron_it = last_layer->first_neuron; neuron_it != last_neuron; neuron_it++)
+ {
+ neuron_it->activation_function = activation_function;
+ }
+}
+
+FANN_EXTERNAL void FANN_API fann_set_activation_steepness_hidden(struct fann *ann,
+ fann_type steepness)
+{
+ struct fann_neuron *last_neuron, *neuron_it;
+ struct fann_layer *layer_it;
+ struct fann_layer *last_layer = ann->last_layer - 1; /* -1 to not update the output layer */
+
+ for(layer_it = ann->first_layer + 1; layer_it != last_layer; layer_it++)
+ {
+ last_neuron = layer_it->last_neuron;
+ for(neuron_it = layer_it->first_neuron; neuron_it != last_neuron; neuron_it++)
+ {
+ neuron_it->activation_steepness = steepness;
+ }
+ }
+}
+
+FANN_EXTERNAL void FANN_API fann_set_activation_steepness_output(struct fann *ann,
+ fann_type steepness)
+{
+ struct fann_neuron *last_neuron, *neuron_it;
+ struct fann_layer *last_layer = ann->last_layer - 1;
+
+ last_neuron = last_layer->last_neuron;
+ for(neuron_it = last_layer->first_neuron; neuron_it != last_neuron; neuron_it++)
+ {
+ neuron_it->activation_steepness = steepness;
+ }
+}
+
+FANN_GET_SET(enum fann_errorfunc_enum, train_error_function)
+FANN_GET_SET(float, quickprop_decay)
+FANN_GET_SET(float, quickprop_mu)
+FANN_GET_SET(float, rprop_increase_factor)
+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)
diff --git a/src/fixedfann.c b/src/fixedfann.c
index 9878803..b6536c2 100644
--- a/src/fixedfann.c
+++ b/src/fixedfann.c
@@ -25,6 +25,5 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#include "fann_io.c"
#include "fann_train.c"
#include "fann_train_data.c"
-#include "fann_options.c"
#include "fann_error.c"
#include "fann_cascade.c"
diff --git a/src/floatfann.c b/src/floatfann.c
index baa4cc5..bd74136 100644
--- a/src/floatfann.c
+++ b/src/floatfann.c
@@ -25,6 +25,5 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#include "fann_io.c"
#include "fann_train.c"
#include "fann_train_data.c"
-#include "fann_options.c"
#include "fann_error.c"
#include "fann_cascade.c"
diff --git a/src/include/fann.h b/src/include/fann.h
index 2d18762..ee522fc 100644
--- a/src/include/fann.h
+++ b/src/include/fann.h
@@ -22,6 +22,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
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 */
@@ -125,10 +127,17 @@ extern "C"
#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 ----- */
-/* Constructs a backpropagation neural network, from an connection rate,
+/* 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.
@@ -140,470 +149,115 @@ extern "C"
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,
+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 */
...);
-/* Just like fann_create, but with an array of layer sizes
+/* 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);
-/* create a fully connected neural network with shortcut connections.
+/* 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 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 */
-/* create a neural network with shortcut connections.
+/* 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,
unsigned int *layers);
-/* Runs a input through the network, and returns the output.
+/* 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);
-/* Destructs the entire network.
+/* Function: fann_destroy
+ Destructs the entire network.
Be sure to call this function after finished using the network.
*/
FANN_EXTERNAL void FANN_API fann_destroy(struct fann *ann);
-/* Randomize weights (from the beginning the weights are random between -0.1 and 0.1)
+/* Function: fann_randomize_weights
+ Randomize weights (from the beginning the weights are random between -0.1 and 0.1)
*/
FANN_EXTERNAL void FANN_API fann_randomize_weights(struct fann *ann, fann_type min_weight,
fann_type max_weight);
-/* Initialize the weights using Widrow + Nguyen's algorithm.
+/* Function: fann_init_weights
+ Initialize the weights using Widrow + Nguyen's algorithm.
*/
FANN_EXTERNAL void FANN_API fann_init_weights(struct fann *ann, struct fann_train_data *train_data);
-/* print out which connections there are in the ann */
+/* Function: fann_print_connections
+ print out which connections there are in the ann */
FANN_EXTERNAL void FANN_API fann_print_connections(struct fann *ann);
-
-/* ----- Implemented in fann_io.c Saving and loading of ANNs ----- */
-
-/* Constructs a backpropagation neural network from a configuration file.
- */
-FANN_EXTERNAL struct fann *FANN_API fann_create_from_file(const char *configuration_file);
-
-/* Save the entire network to a configuration file.
- */
-FANN_EXTERNAL void FANN_API fann_save(struct fann *ann, const char *configuration_file);
-
-/* Saves the entire network to a configuration file.
- But it is saved in fixed point format no matter which
- format it is currently in.
-
- This is usefull for training a network in floating points,
- and then later executing it in fixed point.
-
- The function returns the bit position of the fix point, which
- can be used to find out how accurate the fixed point network will be.
- A high value indicates high precision, and a low value indicates low
- precision.
-
- A negative value indicates very low precision, and a very
- strong possibility for overflow.
- (the actual fix point will be set to 0, since a negative
- fix point does not make sence).
-
- Generally, a fix point lower than 6 is bad, and should be avoided.
- The best way to avoid this, is to have less connections to each neuron,
- or just less neurons in each layer.
-
- The fixed point use of this network is only intended for use on machines that
- have no floating point processor, like an iPAQ. On normal computers the floating
- point version is actually faster.
-*/
-FANN_EXTERNAL int FANN_API fann_save_to_fixed(struct fann *ann, const char *configuration_file);
-
-/* ----- Implemented in fann_train.c Training and testing of ANNs ----- */
-
-#ifndef FIXEDFANN
-/* Train one iteration with a set of inputs, and a set of desired outputs.
- */
-FANN_EXTERNAL void FANN_API fann_train(struct fann *ann, fann_type * input,
- fann_type * desired_output);
-#endif /* NOT FIXEDFANN */
-
-/* Test with a set of inputs, and a set of desired outputs.
- This operation updates the mean square error, but does not
- change the network in any way.
-*/
- FANN_EXTERNAL fann_type * FANN_API fann_test(struct fann *ann, fann_type * input,
- fann_type * desired_output);
-
-/* Reads the mean square error from the network.
- (obsolete will be removed at some point, use fann_get_MSE)
- */
-FANN_EXTERNAL float FANN_API fann_get_error(struct fann *ann);
-
-/* Reads the mean square error from the network.
- */
-FANN_EXTERNAL float FANN_API fann_get_MSE(struct fann *ann);
-
-/* Resets the mean square error from the network.
- (obsolete will be removed at some point, use fann_reset_MSE)
- */
-FANN_EXTERNAL void FANN_API fann_reset_error(struct fann *ann);
-
-/* Resets the mean square error from the network.
- */
-FANN_EXTERNAL void FANN_API fann_reset_MSE(struct fann *ann);
-
-/* ----- Implemented in fann_train_data.c Data for training of ANNs ----- */
-
-/* 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);
-
-/* 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
-
-/* 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);
-
-/* 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
+/* Group: Parameters */
+/* Function: fann_print_parameters
- 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));
-
-/* 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);
-
-/* 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));
-
-/* shuffles training data, randomizing the order
- */
-FANN_EXTERNAL void FANN_API fann_shuffle_train_data(struct fann_train_data *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);
-
-/* 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);
-
-/* 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);
-
-/* 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);
-
-/* 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 */
-
-/* Save the training structure to a file.
- */
-FANN_EXTERNAL void FANN_API fann_save_train(struct fann_train_data *data, char *filename);
-
-/* 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);
-
-/* ----- Implemented in fann_cascade.c Used to train the ANN with cascade correlation ----- */
-FANN_EXTERNAL void fann_cascadetrain_on_data_callback(struct fann *ann,
- struct fann_train_data *data,
- float desired_error,
- int (*callback) (unsigned int epochs,
- float error),
- unsigned int max_out_epochs,
- unsigned int neurons_between_reports);
-
-/* ----- Implemented in fann_options.c Get and set options for the ANNs ----- */
-
-/* Prints all of the parameters and options of the ANN */
-FANN_EXTERNAL void FANN_API fann_print_parameters(struct fann *ann);
-
-/* Get the training algorithm.
- */
-FANN_EXTERNAL enum fann_train_enum FANN_API fann_get_training_algorithm(struct fann *ann);
-
-/* Set the training algorithm.
- */
-FANN_EXTERNAL void FANN_API fann_set_training_algorithm(struct fann *ann,
- enum fann_train_enum training_algorithm);
-
-/* Get the learning rate.
- */
-FANN_EXTERNAL float FANN_API fann_get_learning_rate(struct fann *ann);
-
-/* Set the learning rate.
- */
-FANN_EXTERNAL void FANN_API fann_set_learning_rate(struct fann *ann, float learning_rate);
-
-/* Set the activation function for the hidden layers.
- */
-FANN_EXTERNAL void FANN_API fann_set_activation_function_hidden(struct fann *ann,
- enum fann_activationfunc_enum
- activation_function);
-
-/* Set the activation function for the output layer.
- */
-FANN_EXTERNAL void FANN_API fann_set_activation_function_output(struct fann *ann,
- enum fann_activationfunc_enum
- activation_function);
-
/* Set the steepness of the sigmoid function used in the hidden layers.
- Only usefull if sigmoid function is used in the hidden layers (default 0.5).
- */
-FANN_EXTERNAL void FANN_API fann_set_activation_steepness_hidden(struct fann *ann,
- fann_type steepness);
-
-/* Set the steepness of the sigmoid function used in the output layer.
- Only usefull if sigmoid function is used in the output layer (default 0.5).
- */
-FANN_EXTERNAL void FANN_API fann_set_activation_steepness_output(struct fann *ann,
- fann_type steepness);
+ Prints all of the parameters and options of the ANN */
+FANN_EXTERNAL void FANN_API fann_print_parameters(struct fann *ann);
-/* Set the error function used during training. (default FANN_ERRORFUNC_TANH)
- */
-FANN_EXTERNAL void FANN_API fann_set_train_error_function(struct fann *ann,
- enum fann_errorfunc_enum
- train_error_function);
+/* Function: fann_get_num_input
-
-/* Get the error function used during training.
+ Get the number of input neurons.
*/
-FANN_EXTERNAL enum fann_errorfunc_enum FANN_API fann_get_train_error_function(struct fann *ann);
+FANN_EXTERNAL unsigned int FANN_API fann_get_num_input(struct fann *ann);
+
+/* Function: fann_get_num_output
-/* Set the stop function used during training. (default FANN_STOPFUNC_MSE)
+ Get the number of output neurons.
*/
-FANN_EXTERNAL void FANN_API fann_set_train_stop_function(struct fann *ann,
- enum fann_stopfunc_enum train_stop_function);
+FANN_EXTERNAL unsigned int FANN_API fann_get_num_output(struct fann *ann);
-/* Get the stop function used during training.
- */
-FANN_EXTERNAL enum fann_stopfunc_enum FANN_API fann_get_train_stop_function(struct fann *ann);
-
-/* Decay is used to make the weights do not go so high (default -0.0001). */
-FANN_EXTERNAL float FANN_API fann_get_quickprop_decay(struct fann *ann);
-
-/* Decay is used to make the weights do not go so high (default -0.0001). */
-FANN_EXTERNAL void FANN_API fann_set_quickprop_decay(struct fann *ann, float quickprop_decay);
-
-/* Mu is a factor used to increase and decrease the stepsize (default 1.75). */
-FANN_EXTERNAL float FANN_API fann_get_quickprop_mu(struct fann *ann);
-
-/* Mu is a factor used to increase and decrease the stepsize (default 1.75). */
-FANN_EXTERNAL void FANN_API fann_set_quickprop_mu(struct fann *ann, float quickprop_mu);
-
-/* Tells how much the stepsize should increase during learning (default 1.2). */
-FANN_EXTERNAL float FANN_API fann_get_rprop_increase_factor(struct fann *ann);
-
-/* Tells how much the stepsize should increase during learning (default 1.2). */
-FANN_EXTERNAL void FANN_API fann_set_rprop_increase_factor(struct fann *ann,
- float rprop_increase_factor);
-
-/* Tells how much the stepsize should decrease during learning (default 0.5). */
-FANN_EXTERNAL float FANN_API fann_get_rprop_decrease_factor(struct fann *ann);
-
-/* Tells how much the stepsize should decrease during learning (default 0.5). */
-FANN_EXTERNAL void FANN_API fann_set_rprop_decrease_factor(struct fann *ann,
- float rprop_decrease_factor);
-
-/* The minimum stepsize (default 0.0). */
-FANN_EXTERNAL float FANN_API fann_get_rprop_delta_min(struct fann *ann);
-
-/* The minimum stepsize (default 0.0). */
-FANN_EXTERNAL void FANN_API fann_set_rprop_delta_min(struct fann *ann, float rprop_delta_min);
-
-/* The maximum stepsize (default 50.0). */
-FANN_EXTERNAL float FANN_API fann_get_rprop_delta_max(struct fann *ann);
-
-/* The maximum stepsize (default 50.0). */
-FANN_EXTERNAL void FANN_API fann_set_rprop_delta_max(struct fann *ann, float rprop_delta_max);
-
-/* Get the number of input neurons.
- */
-FANN_EXTERNAL unsigned int FANN_API fann_get_num_input(struct fann *ann);
-
-/* Get the number of output neurons.
- */
-FANN_EXTERNAL unsigned int FANN_API fann_get_num_output(struct fann *ann);
-
-/* Get the total number of neurons in the entire network.
- */
-FANN_EXTERNAL unsigned int FANN_API fann_get_total_neurons(struct fann *ann);
-
-/* Get the total number of connections in the entire network.
+/* Function: fann_get_total_neurons
+
+ Get the total number of neurons in the entire network.
*/
-FANN_EXTERNAL unsigned int FANN_API fann_get_total_connections(struct fann *ann);
+FANN_EXTERNAL unsigned int FANN_API fann_get_total_neurons(struct fann *ann);
-/* Function: fann_get_cascade_num_candidates
- The number of candidates (calculated from cascade_activation_functions_count,
- cascade_activation_steepnesses_count and cascade_num_candidate_groups).
+/* Function: fann_get_total_connections
+
+ Get the total number of connections in the entire network.
*/
-FANN_EXTERNAL unsigned int FANN_API fann_get_cascade_num_candidates(struct fann *ann);
-
-FANN_EXTERNAL float FANN_API fann_get_cascade_change_fraction(struct fann *ann);
-FANN_EXTERNAL void FANN_API fann_set_cascade_change_fraction(struct fann *ann,
- float cascade_change_fraction);
-
-FANN_EXTERNAL unsigned int FANN_API fann_get_cascade_stagnation_epochs(struct fann *ann);
-FANN_EXTERNAL void FANN_API fann_set_cascade_stagnation_epochs(struct fann *ann,
- unsigned int cascade_stagnation_epochs);
-
FANN_EXTERNAL unsigned int FANN_API fann_get_cascade_num_candidate_groups(struct fann *ann);
-FANN_EXTERNAL void FANN_API fann_set_cascade_num_candidate_groups(struct fann *ann,
- unsigned int cascade_num_candidate_groups);
-
-FANN_EXTERNAL fann_type FANN_API fann_get_cascade_weight_multiplier(struct fann *ann);
-FANN_EXTERNAL void FANN_API fann_set_cascade_weight_multiplier(struct fann *ann,
- fann_type cascade_weight_multiplier);
-
-FANN_EXTERNAL fann_type FANN_API fann_get_cascade_candidate_limit(struct fann *ann);
-FANN_EXTERNAL void FANN_API fann_set_cascade_candidate_limit(struct fann *ann,
- fann_type cascade_candidate_limit);
-
-FANN_EXTERNAL unsigned int FANN_API fann_get_cascade_max_out_epochs(struct fann *ann);
-FANN_EXTERNAL void FANN_API fann_set_cascade_max_out_epochs(struct fann *ann,
- unsigned int cascade_max_out_epochs);
-
-FANN_EXTERNAL unsigned int FANN_API fann_get_cascade_max_cand_epochs(struct fann *ann);
-FANN_EXTERNAL void FANN_API fann_set_cascade_max_cand_epochs(struct fann *ann,
- unsigned int cascade_max_cand_epochs);
-
-FANN_EXTERNAL unsigned int FANN_API fann_get_cascade_activation_functions_count(struct fann *ann);
-FANN_EXTERNAL enum fann_activationfunc_enum * FANN_API fann_get_cascade_activation_functions(
- struct fann *ann);
-
-FANN_EXTERNAL void fann_set_cascade_activation_functions(struct fann *ann,
- enum fann_activationfunc_enum *
- cascade_activation_functions,
- unsigned int
- cascade_activation_functions_count);
-
-FANN_EXTERNAL unsigned int FANN_API fann_get_cascade_activation_steepnesses_count(struct fann *ann);
-FANN_EXTERNAL fann_type * FANN_API fann_get_cascade_activation_steepnesses(struct fann *ann);
-
-FANN_EXTERNAL void fann_set_cascade_activation_steepnesses(struct fann *ann,
- fann_type *
- cascade_activation_steepnesses,
- unsigned int
- cascade_activation_steepnesses_count);
-
+FANN_EXTERNAL unsigned int FANN_API fann_get_total_connections(struct fann *ann);
+
#ifdef FIXEDFANN
-/* returns the position of the decimal point.
+/* 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);
-
-/* returns the multiplier that fix point data is multiplied with.
+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);
+FANN_EXTERNAL unsigned int FANN_API fann_get_multiplier(struct fann *ann);
#endif /* FIXEDFANN */
-
-/* ----- Implemented in fann_error.c Access error information about the ANN ----- */
-
-/* change where errors are logged to
- */
-FANN_EXTERNAL void FANN_API fann_set_error_log(struct fann_error *errdat, FILE * log_file);
-
-/* returns the last error number
- */
-FANN_EXTERNAL enum fann_errno_enum FANN_API fann_get_errno(struct fann_error *errdat);
-
-/* resets the last error number
- */
-FANN_EXTERNAL void FANN_API fann_reset_errno(struct fann_error *errdat);
-
-/* resets the last error string
- */
-FANN_EXTERNAL void FANN_API fann_reset_errstr(struct fann_error *errdat);
-
-/* returns the last errstr.
- * This function calls fann_reset_errno and fann_reset_errstr
- */
-FANN_EXTERNAL char *FANN_API fann_get_errstr(struct fann_error *errdat);
-
-/* prints the last error to stderr
- */
-FANN_EXTERNAL void FANN_API fann_print_error(struct fann_error *errdat);
-
+
#ifdef __cplusplus
#ifndef __cplusplus
/* to fool automatic indention engines */
diff --git a/src/include/fann_cascade.h b/src/include/fann_cascade.h
new file mode 100644
index 0000000..29e2437
--- /dev/null
+++ b/src/include/fann_cascade.h
@@ -0,0 +1,162 @@
+/*
+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_cascade_h__
+#define __fann_cascade_h__
+
+/* Package: FANN Cascade Training
+ test info about cascade training
+*/
+
+/* Group: Functions */
+
+/* Function: fann_cascadetrain_on_data_callback
+*/
+FANN_EXTERNAL void fann_cascadetrain_on_data_callback(struct fann *ann,
+ struct fann_train_data *data,
+ float desired_error,
+ int (*callback) (unsigned int epochs,
+ float error),
+ unsigned int max_out_epochs,
+ unsigned int neurons_between_reports);
+
+/* Group: Parameters */
+
+/* Function: fann_get_cascade_num_candidates
+
+ The number of candidates (calculated from cascade_activation_functions_count,
+ cascade_activation_steepnesses_count and cascade_num_candidate_groups).
+ */
+FANN_EXTERNAL unsigned int FANN_API fann_get_cascade_num_candidates(struct fann *ann);
+
+/* Function: fann_get_cascade_change_fraction
+ */
+FANN_EXTERNAL float FANN_API fann_get_cascade_change_fraction(struct fann *ann);
+
+
+/* Function: fann_set_cascade_change_fraction
+ */
+FANN_EXTERNAL void FANN_API fann_set_cascade_change_fraction(struct fann *ann,
+ float cascade_change_fraction);
+
+/* Function: fann_get_cascade_stagnation_epochs
+ */
+FANN_EXTERNAL unsigned int FANN_API fann_get_cascade_stagnation_epochs(struct fann *ann);
+
+
+/* Function: fann_set_cascade_stagnation_epochs
+ */
+FANN_EXTERNAL void FANN_API fann_set_cascade_stagnation_epochs(struct fann *ann,
+ unsigned int cascade_stagnation_epochs);
+
+
+/* Function: fann_get_cascade_num_candidate_groups
+ */
+FANN_EXTERNAL unsigned int FANN_API fann_get_cascade_num_candidate_groups(struct fann *ann);
+
+
+/* Function: fann_set_cascade_num_candidate_groups
+ */
+FANN_EXTERNAL void FANN_API fann_set_cascade_num_candidate_groups(struct fann *ann,
+ unsigned int cascade_num_candidate_groups);
+
+
+/* Function: fann_get_cascade_weight_multiplier
+ */
+FANN_EXTERNAL fann_type FANN_API fann_get_cascade_weight_multiplier(struct fann *ann);
+
+
+/* Function: fann_set_cascade_weight_multiplier
+ */
+FANN_EXTERNAL void FANN_API fann_set_cascade_weight_multiplier(struct fann *ann,
+ fann_type cascade_weight_multiplier);
+
+
+/* Function: fann_get_cascade_candidate_limit
+ */
+FANN_EXTERNAL fann_type FANN_API fann_get_cascade_candidate_limit(struct fann *ann);
+
+
+/* Function: fann_set_cascade_candidate_limit
+ */
+FANN_EXTERNAL void FANN_API fann_set_cascade_candidate_limit(struct fann *ann,
+ fann_type cascade_candidate_limit);
+
+
+/* Function: fann_get_cascade_max_out_epochs
+ */
+FANN_EXTERNAL unsigned int FANN_API fann_get_cascade_max_out_epochs(struct fann *ann);
+
+
+/* Function: fann_set_cascade_max_out_epochs
+ */
+FANN_EXTERNAL void FANN_API fann_set_cascade_max_out_epochs(struct fann *ann,
+ unsigned int cascade_max_out_epochs);
+
+
+/* Function: fann_get_cascade_max_cand_epochs
+ */
+FANN_EXTERNAL unsigned int FANN_API fann_get_cascade_max_cand_epochs(struct fann *ann);
+
+
+/* Function: fann_set_cascade_max_cand_epochs
+ */
+FANN_EXTERNAL void FANN_API fann_set_cascade_max_cand_epochs(struct fann *ann,
+ unsigned int cascade_max_cand_epochs);
+
+
+/* Function: fann_get_cascade_activation_functions_count
+ */
+FANN_EXTERNAL unsigned int FANN_API fann_get_cascade_activation_functions_count(struct fann *ann);
+
+
+/* Function: fann_get_cascade_activation_functions
+ */
+FANN_EXTERNAL enum fann_activationfunc_enum * FANN_API fann_get_cascade_activation_functions(
+ struct fann *ann);
+
+
+/* Function: fann_set_cascade_activation_functions
+ */
+FANN_EXTERNAL void fann_set_cascade_activation_functions(struct fann *ann,
+ enum fann_activationfunc_enum *
+ cascade_activation_functions,
+ unsigned int
+ cascade_activation_functions_count);
+
+
+/* Function: fann_get_cascade_activation_steepnesses_count
+ */
+FANN_EXTERNAL unsigned int FANN_API fann_get_cascade_activation_steepnesses_count(struct fann *ann);
+
+
+/* Function: fann_get_cascade_activation_steepnesses
+ */
+FANN_EXTERNAL fann_type * FANN_API fann_get_cascade_activation_steepnesses(struct fann *ann);
+
+
+/* Function: fann_set_cascade_activation_steepnesses
+ */
+FANN_EXTERNAL void fann_set_cascade_activation_steepnesses(struct fann *ann,
+ fann_type *
+ cascade_activation_steepnesses,
+ unsigned int
+ cascade_activation_steepnesses_count);
+
+#endif
diff --git a/src/include/fann_error.h b/src/include/fann_error.h
new file mode 100644
index 0000000..e1463fd
--- /dev/null
+++ b/src/include/fann_error.h
@@ -0,0 +1,67 @@
+/*
+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_error_h__
+#define __fann_error_h__
+
+/* Package: FANN Error Handling */
+
+/* Function: fann_set_error_log
+
+ change where errors are logged to
+ */
+FANN_EXTERNAL void FANN_API fann_set_error_log(struct fann_error *errdat, FILE * log_file);
+
+
+/* Function: fann_get_errno
+
+ returns the last error number
+ */
+FANN_EXTERNAL enum fann_errno_enum FANN_API fann_get_errno(struct fann_error *errdat);
+
+
+/* Function: fann_reset_errno
+
+ resets the last error number
+ */
+FANN_EXTERNAL void FANN_API fann_reset_errno(struct fann_error *errdat);
+
+
+/* Function: fann_reset_errstr
+
+ resets the last error string
+ */
+FANN_EXTERNAL void FANN_API fann_reset_errstr(struct fann_error *errdat);
+
+
+/* Function: fann_get_errstr
+
+ returns the last errstr.
+ * This function calls fann_reset_errno and fann_reset_errstr
+ */
+FANN_EXTERNAL char *FANN_API fann_get_errstr(struct fann_error *errdat);
+
+
+/* Function: fann_print_error
+
+ prints the last error to stderr
+ */
+FANN_EXTERNAL void FANN_API fann_print_error(struct fann_error *errdat);
+
+#endif
diff --git a/src/include/fann_internal.h b/src/include/fann_internal.h
index 373ce1d..677aeb9 100644
--- a/src/include/fann_internal.h
+++ b/src/include/fann_internal.h
@@ -36,6 +36,23 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#define FANN_CONF_VERSION FANN_FLO_VERSION
#endif
+#define FANN_GET(type, name) \
+FANN_EXTERNAL type FANN_API fann_get_ ## name(struct fann *ann) \
+{ \
+ return ann->name; \
+}
+
+#define FANN_SET(type, name) \
+FANN_EXTERNAL void FANN_API fann_set_ ## name(struct fann *ann, type value) \
+{ \
+ ann->name = value; \
+}
+
+#define FANN_GET_SET(type, name) \
+FANN_GET(type, name) \
+FANN_SET(type, name)
+
+
struct fann *fann_allocate_structure(float learning_rate, unsigned int num_layers);
void fann_allocate_neurons(struct fann *ann);
diff --git a/src/include/fann_io.h b/src/include/fann_io.h
new file mode 100644
index 0000000..5306d41
--- /dev/null
+++ b/src/include/fann_io.h
@@ -0,0 +1,65 @@
+/*
+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_io_h__
+#define __fann_io_h__
+
+/* Package: FANN Input/Output */
+
+/* Function: fann_create_from_file
+ Constructs a backpropagation neural network from a configuration file.
+ */
+FANN_EXTERNAL struct fann *FANN_API fann_create_from_file(const char *configuration_file);
+
+
+/* Function: fann_save
+ Save the entire network to a configuration file.
+ */
+FANN_EXTERNAL void FANN_API fann_save(struct fann *ann, const char *configuration_file);
+
+
+/* Function: fann_save_to_fixed
+ Saves the entire network to a configuration file.
+ But it is saved in fixed point format no matter which
+ format it is currently in.
+
+ This is usefull for training a network in floating points,
+ and then later executing it in fixed point.
+
+ The function returns the bit position of the fix point, which
+ can be used to find out how accurate the fixed point network will be.
+ A high value indicates high precision, and a low value indicates low
+ precision.
+
+ A negative value indicates very low precision, and a very
+ strong possibility for overflow.
+ (the actual fix point will be set to 0, since a negative
+ fix point does not make sence).
+
+ Generally, a fix point lower than 6 is bad, and should be avoided.
+ The best way to avoid this, is to have less connections to each neuron,
+ or just less neurons in each layer.
+
+ The fixed point use of this network is only intended for use on machines that
+ have no floating point processor, like an iPAQ. On normal computers the floating
+ point version is actually faster.
+*/
+FANN_EXTERNAL int FANN_API fann_save_to_fixed(struct fann *ann, const char *configuration_file);
+
+#endif
diff --git a/src/include/fann_train.h b/src/include/fann_train.h
new file mode 100644
index 0000000..e37d7c0
--- /dev/null
+++ b/src/include/fann_train.h
@@ -0,0 +1,225 @@
+/*
+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_train_h__
+#define __fann_train_h__
+
+/* Package: FANN Training */
+
+#ifndef FIXEDFANN
+/* Function: fann_train
+ Train one iteration with a set of inputs, and a set of desired outputs.
+ */
+FANN_EXTERNAL void FANN_API fann_train(struct fann *ann, fann_type * input,
+ fann_type * desired_output);
+
+#endif /* NOT FIXEDFANN */
+
+/* Function: fann_test
+ Test with a set of inputs, and a set of desired outputs.
+ This operation updates the mean square error, but does not
+ change the network in any way.
+*/
+ FANN_EXTERNAL fann_type * FANN_API fann_test(struct fann *ann, fann_type * input,
+ fann_type * desired_output);
+
+/* Function: fann_get_MSE
+ Reads the mean square error from the network.
+ */
+FANN_EXTERNAL float FANN_API fann_get_MSE(struct fann *ann);
+
+
+/* Function: fann_reset_MSE
+ Resets the mean square error from the network.
+ */
+FANN_EXTERNAL void FANN_API fann_reset_MSE(struct fann *ann);
+
+/* Package: Parameters */
+
+/* Function: fann_get_training_algorithm
+
+ Get the training algorithm.
+ */
+FANN_EXTERNAL enum fann_train_enum FANN_API fann_get_training_algorithm(struct fann *ann);
+
+
+/* Function: fann_set_training_algorithm
+
+ Set the training algorithm.
+ */
+FANN_EXTERNAL void FANN_API fann_set_training_algorithm(struct fann *ann,
+ enum fann_train_enum training_algorithm);
+
+
+/* Function: fann_get_learning_rate
+
+ Get the learning rate.
+ */
+FANN_EXTERNAL float FANN_API fann_get_learning_rate(struct fann *ann);
+
+
+/* Function: fann_set_learning_rate
+
+ Set the learning rate.
+ */
+FANN_EXTERNAL void FANN_API fann_set_learning_rate(struct fann *ann, float learning_rate);
+
+
+/* Function: fann_set_activation_function_hidden
+
+ Set the activation function for the hidden layers.
+ */
+FANN_EXTERNAL void FANN_API fann_set_activation_function_hidden(struct fann *ann,
+ enum fann_activationfunc_enum
+ activation_function);
+
+
+/* Function: fann_set_activation_function_output
+
+ Set the activation function for the output layer.
+ */
+FANN_EXTERNAL void FANN_API fann_set_activation_function_output(struct fann *ann,
+ enum fann_activationfunc_enum
+ activation_function);
+
+/* Function: fann_set_activation_steepness_hidden
+
+ Set the steepness of the sigmoid function used in the hidden layers.
+ (default 0.5).
+ */
+FANN_EXTERNAL void FANN_API fann_set_activation_steepness_hidden(struct fann *ann,
+ fann_type steepness);
+
+
+/* Function: fann_set_activation_steepness_output
+
+ Set the steepness of the sigmoid function used in the output layer.
+ Only usefull if sigmoid function is used in the output layer (default 0.5).
+ */
+FANN_EXTERNAL void FANN_API fann_set_activation_steepness_output(struct fann *ann,
+ fann_type steepness);
+
+
+/* Function: fann_set_train_error_function
+
+ Set the error function used during training. (default FANN_ERRORFUNC_TANH)
+ */
+FANN_EXTERNAL void FANN_API fann_set_train_error_function(struct fann *ann,
+ enum fann_errorfunc_enum
+ train_error_function);
+
+
+/* Function: fann_get_train_error_function
+
+ Get the error function used during training.
+ */
+FANN_EXTERNAL enum fann_errorfunc_enum FANN_API fann_get_train_error_function(struct fann *ann);
+
+
+/* Function: fann_get_train_stop_function
+
+ Set the stop function used during training. (default FANN_STOPFUNC_MSE)
+ */
+FANN_EXTERNAL void FANN_API fann_set_train_stop_function(struct fann *ann,
+ enum fann_stopfunc_enum train_stop_function);
+
+
+/* Function: fann_get_train_stop_function
+
+ Get the stop function used during training.
+ */
+FANN_EXTERNAL enum fann_stopfunc_enum FANN_API fann_get_train_stop_function(struct fann *ann);
+
+
+/* Function: fann_get_quickprop_decay
+
+ Decay is used to make the weights do not go so high (default -0.0001).
+ */
+FANN_EXTERNAL float FANN_API fann_get_quickprop_decay(struct fann *ann);
+
+
+/* Function: fann_set_quickprop_decay
+
+ Decay is used to make the weights do not go so high (default -0.0001). */
+FANN_EXTERNAL void FANN_API fann_set_quickprop_decay(struct fann *ann, float quickprop_decay);
+
+
+/* Function: fann_get_quickprop_mu
+
+ Mu is a factor used to increase and decrease the stepsize (default 1.75). */
+FANN_EXTERNAL float FANN_API fann_get_quickprop_mu(struct fann *ann);
+
+
+/* Function: fann_set_quickprop_mu
+
+ Mu is a factor used to increase and decrease the stepsize (default 1.75). */
+FANN_EXTERNAL void FANN_API fann_set_quickprop_mu(struct fann *ann, float quickprop_mu);
+
+
+/* Function: fann_get_rprop_increase_factor
+
+ Tells how much the stepsize should increase during learning (default 1.2). */
+FANN_EXTERNAL float FANN_API fann_get_rprop_increase_factor(struct fann *ann);
+
+
+/* Function: fann_set_rprop_increase_factor
+
+ Tells how much the stepsize should increase during learning (default 1.2). */
+FANN_EXTERNAL void FANN_API fann_set_rprop_increase_factor(struct fann *ann,
+ float rprop_increase_factor);
+
+
+/* Function: fann_get_rprop_decrease_factor
+
+ Tells how much the stepsize should decrease during learning (default 0.5). */
+FANN_EXTERNAL float FANN_API fann_get_rprop_decrease_factor(struct fann *ann);
+
+
+/* Function: fann_set_rprop_decrease_factor
+
+ Tells how much the stepsize should decrease during learning (default 0.5). */
+FANN_EXTERNAL void FANN_API fann_set_rprop_decrease_factor(struct fann *ann,
+ float rprop_decrease_factor);
+
+
+/* Function: fann_get_rprop_delta_min
+
+ The minimum stepsize (default 0.0). */
+FANN_EXTERNAL float FANN_API fann_get_rprop_delta_min(struct fann *ann);
+
+
+/* Function: fann_set_rprop_delta_min
+
+ The minimum stepsize (default 0.0). */
+FANN_EXTERNAL void FANN_API fann_set_rprop_delta_min(struct fann *ann, float rprop_delta_min);
+
+
+/* Function: fann_get_rprop_delta_max
+
+ The maximum stepsize (default 50.0). */
+FANN_EXTERNAL float FANN_API fann_get_rprop_delta_max(struct fann *ann);
+
+
+/* Function: fann_set_rprop_delta_max
+
+ The maximum stepsize (default 50.0). */
+FANN_EXTERNAL void FANN_API fann_set_rprop_delta_max(struct fann *ann, float rprop_delta_max);
+
+
+#endif
--
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