[libfann] 192/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 98a525b82db6c88448c5658a12885acec4e02d49
Author: Steffen Nissen <lukesky at diku.dk>
Date: Tue Sep 13 22:39:08 2005 +0000
*** empty log message ***
---
examples/cascade_train.c | 39 +--
src/fann.c | 10 +-
src/fann_cascade.c | 36 ++-
src/fann_error.c | 11 +-
src/fann_io.c | 10 +-
src/fann_options.c | 283 ++++++--------------
src/fann_train.c | 14 +-
src/fann_train_data.c | 72 +++--
src/include/fann.h | 606 +++++++++++++++++++++---------------------
src/include/fann_activation.h | 6 +-
src/include/fann_data.h | 129 ++++-----
src/include/fann_errno.h | 2 +-
src/include/fann_internal.h | 4 +-
13 files changed, 556 insertions(+), 666 deletions(-)
diff --git a/examples/cascade_train.c b/examples/cascade_train.c
index 84ee0df..0e38b41 100644
--- a/examples/cascade_train.c
+++ b/examples/cascade_train.c
@@ -35,7 +35,7 @@ int print_callback(unsigned int epochs, float error)
mse1 = fann_test_data(ann, train_data);
bit1 = ann->num_bit_fail;
- printf("Nerons %8d. Current MSE-Error: %.10f ", epochs, error);
+ printf("Nerons %4d. Epochs: %7d ", epochs, (int)error);
printf("Train error: %.10f (%d), Test error: %.10f (%d)\n", mse1, bit1, mse2, bit2);
return 0;
}
@@ -109,41 +109,20 @@ int main()
fann_set_train_error_function(ann, FANN_ERRORFUNC_LINEAR);
+ fann_set_train_stop_function(ann, FANN_STOPFUNC_BIT);
fann_set_rprop_increase_factor(ann, 1.2);
fann_set_rprop_decrease_factor(ann, 0.5);
fann_set_rprop_delta_min(ann, 0.0);
fann_set_rprop_delta_max(ann, 50.0);
- ann->cascade_change_fraction = 0.01;
- ann->cascade_stagnation_epochs = 12;
- ann->cascade_weight_multiplier = 0.4;
- ann->cascade_candidate_limit = 1000.0;
- ann->cascade_max_out_epochs = 150;
- ann->cascade_max_cand_epochs = 150;
- ann->cascade_num_candidate_groups = 1;
-
- ann->cascade_activation_functions_count = 6;
- ann->cascade_activation_functions =
- (unsigned int *)calloc(ann->cascade_activation_functions_count,
- sizeof(unsigned int));
-
- ann->cascade_activation_functions[0] = FANN_SIGMOID;
- ann->cascade_activation_functions[1] = FANN_SIGMOID_SYMMETRIC;
- ann->cascade_activation_functions[2] = FANN_GAUSSIAN;
- ann->cascade_activation_functions[3] = FANN_GAUSSIAN_SYMMETRIC;
- ann->cascade_activation_functions[4] = FANN_ELLIOT;
- ann->cascade_activation_functions[5] = FANN_ELLIOT_SYMMETRIC;
-
- ann->cascade_activation_steepnesses_count = 4;
- ann->cascade_activation_steepnesses =
- (fann_type *)calloc(ann->cascade_activation_steepnesses_count,
- sizeof(fann_type));
-
- ann->cascade_activation_steepnesses[0] = 0.25;
- ann->cascade_activation_steepnesses[1] = 0.5;
- ann->cascade_activation_steepnesses[2] = 0.75;
- ann->cascade_activation_steepnesses[3] = 1.0;
+ fann_set_cascade_change_fraction(ann, 0.01);
+ fann_set_cascade_stagnation_epochs(ann, 12);
+ fann_set_cascade_weight_multiplier(ann, 0.4);
+ fann_set_cascade_candidate_limit(ann, 1000.0);
+ fann_set_cascade_max_out_epochs(ann, 150);
+ fann_set_cascade_max_cand_epochs(ann, 150);
+ fann_set_cascade_num_candidate_groups(ann, 1);
fann_print_parameters(ann);
/*fann_print_connections(ann); */
diff --git a/src/fann.c b/src/fann.c
index efe6d3b..b6dd69b 100644
--- a/src/fann.c
+++ b/src/fann.c
@@ -676,7 +676,7 @@ FANN_EXTERNAL fann_type *FANN_API fann_run(struct fann * ann, fann_type * input)
v5 = ann->sigmoid_symmetric_values[4] / steepness;
v6 = ann->sigmoid_symmetric_values[5] / steepness;
break;
- default:
+ case FANN_THRESHOLD:
break;
}
}
@@ -701,7 +701,7 @@ FANN_EXTERNAL fann_type *FANN_API fann_run(struct fann * ann, fann_type * input)
case FANN_THRESHOLD_SYMMETRIC:
neuron_it->value = (fann_type) ((neuron_sum < 0) ? -1 : 1);
break;
- default:
+ case FANN_ELLIOT:
fann_error((struct fann_error *) ann, FANN_E_CANT_USE_ACTIVATION);
}
last_steepness = steepness;
@@ -941,7 +941,7 @@ struct fann *fann_allocate_structure(float learning_rate, unsigned int num_layer
return NULL;
}
- ann->errno_f = 0;
+ ann->errno_f = FANN_E_NO_ERROR;
ann->error_log = NULL;
ann->errstr = NULL;
ann->learning_rate = learning_rate;
@@ -973,8 +973,8 @@ struct fann *fann_allocate_structure(float learning_rate, unsigned int num_layer
ann->cascade_candidate_scores = NULL;
ann->cascade_activation_functions_count = 6;
ann->cascade_activation_functions =
- (unsigned int *)calloc(ann->cascade_activation_functions_count,
- sizeof(unsigned int));
+ (enum fann_activationfunc_enum *)calloc(ann->cascade_activation_functions_count,
+ sizeof(enum fann_activationfunc_enum));
if(ann->cascade_activation_functions == NULL)
{
fann_error(NULL, FANN_E_CANT_ALLOCATE_MEM);
diff --git a/src/fann_cascade.c b/src/fann_cascade.c
index c0c12bb..8a016cf 100644
--- a/src/fann_cascade.c
+++ b/src/fann_cascade.c
@@ -73,6 +73,7 @@ void fann_cascadetrain_on_data_callback(struct fann *ann, struct fann_train_data
float error;
unsigned int i;
unsigned int total_epochs = 0;
+ int desired_error_reached;
if(neurons_between_reports && callback == NULL)
{
@@ -93,6 +94,7 @@ void fann_cascadetrain_on_data_callback(struct fann *ann, struct fann_train_data
#endif
total_epochs += fann_train_outputs(ann, data, desired_error);
error = fann_get_MSE(ann);
+ desired_error_reached = fann_desired_error_reached(ann, desired_error);
#ifdef CASCADE_DEBUG
printf("\n");
@@ -101,7 +103,7 @@ void fann_cascadetrain_on_data_callback(struct fann *ann, struct fann_train_data
/* print current error */
if(neurons_between_reports &&
(i % neurons_between_reports == 0
- || i == max_neurons || i == 1 || error < desired_error))
+ || i == max_neurons || i == 1 || desired_error_reached == 0))
{
if(callback == NULL)
{
@@ -109,7 +111,10 @@ void fann_cascadetrain_on_data_callback(struct fann *ann, struct fann_train_data
("Neurons %6d. Current error: %.6f. Total error: %.6f. Epochs %6d. Bit fail %d.\n",
i, error, ann->MSE_value, total_epochs, ann->num_bit_fail);
}
- else if((*callback) (i, error) == -1)
+ else if((*callback) (i, total_epochs) == -1)
+ /* TODO the callback should be changed, to include more info
+ * now total_epochs is included in the error field.
+ */
{
/* you can break the training by returning -1 */
break;
@@ -122,10 +127,8 @@ void fann_cascadetrain_on_data_callback(struct fann *ann, struct fann_train_data
fann_print_connections_raw(ann);
#endif
- if(error < desired_error)
- {
+ if(desired_error_reached == 0)
break;
- }
if(fann_initialize_candidates(ann) == -1)
{
@@ -184,10 +187,8 @@ int fann_train_outputs(struct fann *ann, struct fann_train_data *data, float des
/* run an initial epoch to set the initital error */
initial_error = fann_train_outputs_epoch(ann, data);
- if(initial_error < desired_error)
- {
+ if(fann_desired_error_reached(ann, desired_error) == 0)
return 1;
- }
for(i = 1; i < max_epochs; i++)
{
@@ -195,7 +196,7 @@ int fann_train_outputs(struct fann *ann, struct fann_train_data *data, float des
/*printf("Epoch %6d. Current error: %.6f. Bit fail %d.\n", i, error, ann->num_bit_fail); */
- if(error < desired_error)
+ if(fann_desired_error_reached(ann, desired_error) == 0)
{
#ifdef CASCADE_DEBUG
printf("Error %f < %f\n", error, desired_error);
@@ -251,7 +252,8 @@ float fann_train_outputs_epoch(struct fann *ann, struct fann_train_data *data)
(ann->last_layer - 1)->first_neuron->first_con,
ann->total_connections);
break;
- default:
+ case FANN_TRAIN_BATCH:
+ case FANN_TRAIN_INCREMENTAL:
fann_error((struct fann_error *) ann, FANN_E_CANT_USE_TRAIN_ALG);
}
@@ -663,8 +665,10 @@ void fann_update_candidate_weights(struct fann *ann, unsigned int num_data)
fann_update_weights_quickprop(ann, num_data, first_cand->first_con,
last_cand->last_con + ann->num_output);
break;
- default:
+ case FANN_TRAIN_BATCH:
+ case FANN_TRAIN_INCREMENTAL:
fann_error((struct fann_error *) ann, FANN_E_CANT_USE_TRAIN_ALG);
+ break;
}
}
@@ -707,10 +711,20 @@ float fann_train_candidates_epoch(struct fann *ann, struct fann_train_data *data
case FANN_LINEAR_PIECE_SYMMETRIC:
case FANN_SIGMOID_SYMMETRIC:
case FANN_SIGMOID_SYMMETRIC_STEPWISE:
+ case FANN_THRESHOLD_SYMMETRIC:
case FANN_ELLIOT_SYMMETRIC:
case FANN_GAUSSIAN_SYMMETRIC:
output_train_errors[j] /= 2.0;
break;
+ case FANN_LINEAR:
+ case FANN_THRESHOLD:
+ case FANN_SIGMOID:
+ case FANN_SIGMOID_STEPWISE:
+ case FANN_GAUSSIAN:
+ case FANN_GAUSSIAN_STEPWISE:
+ case FANN_ELLIOT:
+ case FANN_LINEAR_PIECE:
+ break;
}
}
diff --git a/src/fann_error.c b/src/fann_error.c
index d83e9ed..bd51c0a 100644
--- a/src/fann_error.c
+++ b/src/fann_error.c
@@ -36,7 +36,7 @@
*/
FANN_EXTERNAL void FANN_API fann_reset_errno(struct fann_error *errdat)
{
- errdat->errno_f = 0;
+ errdat->errno_f = FANN_E_NO_ERROR;
}
/* resets the last errstr
@@ -50,7 +50,7 @@ FANN_EXTERNAL void FANN_API fann_reset_errstr(struct fann_error *errdat)
/* returns the last error number
*/
-FANN_EXTERNAL unsigned int FANN_API fann_get_errno(struct fann_error *errdat)
+FANN_EXTERNAL enum fann_errno_enum FANN_API fann_get_errno(struct fann_error *errdat)
{
return errdat->errno_f;
}
@@ -87,7 +87,7 @@ FANN_EXTERNAL void FANN_API fann_print_error(struct fann_error *errdat)
/* INTERNAL FUNCTION
Populate the error information
*/
-void fann_error(struct fann_error *errdat, const unsigned int errno_f, ...)
+void fann_error(struct fann_error *errdat, const enum fann_errno_enum errno_f, ...)
{
va_list ap;
char *errstr;
@@ -160,9 +160,6 @@ void fann_error(struct fann_error *errdat, const unsigned int errno_f, ...)
break;
case FANN_E_CANT_USE_TRAIN_ALG:
sprintf(errstr, "Unable to use the selected training algorithm.\n");
-
- default:
- vsprintf(errstr, "Unknown error.\n", ap);
break;
}
va_end(ap);
@@ -187,6 +184,6 @@ void fann_error(struct fann_error *errdat, const unsigned int errno_f, ...)
void fann_init_error_data(struct fann_error *errdat)
{
errdat->errstr = NULL;
- errdat->errno_f = 0;
+ errdat->errno_f = FANN_E_NO_ERROR;
errdat->error_log = stderr;
}
diff --git a/src/fann_io.c b/src/fann_io.c
index b7ac439..89c4c01 100644
--- a/src/fann_io.c
+++ b/src/fann_io.c
@@ -362,8 +362,8 @@ void fann_save_train_internal_fd(struct fann_train_data *data, FILE * file, char
*/
struct fann *fann_create_from_fd_1_1(FILE * conf, const char *configuration_file)
{
- unsigned int num_layers, layer_size, activation_function_hidden, activation_function_output,
- input_neuron, i, shortcut_connections, num_connections;
+ unsigned int num_layers, layer_size, input_neuron, i, shortcut_connections, num_connections;
+ unsigned int activation_function_hidden, activation_function_output;
#ifdef FIXEDFANN
unsigned int decimal_point, multiplier;
#endif
@@ -495,8 +495,8 @@ struct fann *fann_create_from_fd_1_1(FILE * conf, const char *configuration_file
fann_set_activation_steepness_hidden(ann, activation_steepness_hidden);
fann_set_activation_steepness_output(ann, activation_steepness_output);
- fann_set_activation_function_hidden(ann, activation_function_hidden);
- fann_set_activation_function_output(ann, activation_function_output);
+ fann_set_activation_function_hidden(ann, (enum fann_activationfunc_enum)activation_function_hidden);
+ fann_set_activation_function_output(ann, (enum fann_activationfunc_enum)activation_function_output);
#ifdef DEBUG
printf("output\n");
@@ -638,7 +638,7 @@ struct fann *fann_create_from_fd(FILE * conf, const char *configuration_file)
for(neuron_it = ann->first_layer->first_neuron; neuron_it != last_neuron; neuron_it++)
{
if(fscanf
- (conf, "%u %u " FANNSCANF " ", &num_connections, &neuron_it->activation_function,
+ (conf, "%u %u " FANNSCANF " ", &num_connections, (unsigned int *)&neuron_it->activation_function,
&neuron_it->activation_steepness) != 3)
{
fann_error((struct fann_error *) ann, FANN_E_CANT_READ_NEURON, configuration_file);
diff --git a/src/fann_options.c b/src/fann_options.c
index 4cf5aee..45f5849 100644
--- a/src/fann_options.c
+++ b/src/fann_options.c
@@ -26,7 +26,6 @@
#include "fann.h"
#include "fann_errno.h"
-/* Prints all of the parameters and options of the ANN */
FANN_EXTERNAL void FANN_API fann_print_parameters(struct fann *ann)
{
struct fann_layer *layer_it;
@@ -80,24 +79,27 @@ FANN_EXTERNAL void FANN_API fann_print_parameters(struct fann *ann)
printf("Cascade no. of candidates :%4d\n", fann_get_cascade_num_candidates(ann));
}
-FANN_EXTERNAL unsigned int FANN_API fann_get_training_algorithm(struct fann *ann)
-{
- return ann->training_algorithm;
+#define FANN_GET(type, name) \
+FANN_EXTERNAL type FANN_API fann_get_ ## name(struct fann *ann) \
+{ \
+ return ann->name; \
}
-FANN_EXTERNAL void FANN_API fann_set_training_algorithm(struct fann *ann,
- unsigned int training_algorithm)
-{
- ann->training_algorithm = training_algorithm;
+#define FANN_SET(type, name) \
+FANN_EXTERNAL void FANN_API fann_set_ ## name(struct fann *ann, type value) \
+{ \
+ ann->name = value; \
}
-FANN_EXTERNAL void FANN_API fann_set_learning_rate(struct fann *ann, float learning_rate)
-{
- ann->learning_rate = learning_rate;
-}
+#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,
- unsigned int activation_function)
+ enum fann_activationfunc_enum activation_function)
{
struct fann_neuron *last_neuron, *neuron_it;
struct fann_layer *layer_it;
@@ -114,7 +116,7 @@ FANN_EXTERNAL void FANN_API fann_set_activation_function_hidden(struct fann *ann
}
FANN_EXTERNAL void FANN_API fann_set_activation_function_output(struct fann *ann,
- unsigned int activation_function)
+ enum fann_activationfunc_enum activation_function)
{
struct fann_neuron *last_neuron, *neuron_it;
struct fann_layer *last_layer = ann->last_layer - 1;
@@ -156,64 +158,8 @@ FANN_EXTERNAL void FANN_API fann_set_activation_steepness_output(struct fann *an
}
}
-FANN_EXTERNAL void FANN_API fann_set_activation_hidden_steepness(struct fann *ann,
- fann_type steepness)
-{
- fann_set_activation_steepness_hidden(ann, steepness);
-}
-
-FANN_EXTERNAL void FANN_API fann_set_activation_output_steepness(struct fann *ann,
- fann_type steepness)
-{
- fann_set_activation_steepness_output(ann, steepness);
-}
-
-FANN_EXTERNAL float FANN_API fann_get_learning_rate(struct fann *ann)
-{
- return ann->learning_rate;
-}
-
-FANN_EXTERNAL unsigned int FANN_API fann_get_num_input(struct fann *ann)
-{
- return ann->num_input;
-}
-
-FANN_EXTERNAL unsigned int FANN_API fann_get_num_output(struct fann *ann)
-{
- return ann->num_output;
-}
-
-/*
-FANN_EXTERNAL unsigned int FANN_API fann_get_activation_function_hidden(struct fann *ann)
-{
- return ann->activation_function_hidden;
-}
-
-FANN_EXTERNAL unsigned int FANN_API fann_get_activation_function_output(struct fann *ann)
-{
- return ann->activation_function_output;
-}
-
-FANN_EXTERNAL fann_type FANN_API fann_get_activation_hidden_steepness(struct fann *ann)
-{
- return ann->activation_steepness_hidden;
-}
-
-FANN_EXTERNAL fann_type FANN_API fann_get_activation_output_steepness(struct fann *ann)
-{
- return ann->activation_steepness_output;
-}
-
-FANN_EXTERNAL fann_type FANN_API fann_get_activation_steepness_hidden(struct fann *ann)
-{
- return ann->activation_steepness_hidden;
-}
-
-FANN_EXTERNAL fann_type FANN_API fann_get_activation_steepness_output(struct fann *ann)
-{
- return ann->activation_steepness_output;
-}
-*/
+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)
{
@@ -228,128 +174,91 @@ FANN_EXTERNAL unsigned int FANN_API fann_get_total_neurons(struct fann *ann)
}
}
-FANN_EXTERNAL unsigned int FANN_API fann_get_total_connections(struct fann *ann)
-{
- return ann->total_connections;
-}
-
-/* When using this, training is usually faster. (default ).
- Makes the error used for calculating the slopes
- higher when the difference is higher.
- */
-FANN_EXTERNAL void FANN_API fann_set_train_error_function(struct fann *ann,
- unsigned int train_error_function)
-{
- ann->train_error_function = train_error_function;
-}
-
-/* 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)
-{
- ann->quickprop_decay = quickprop_decay;
-}
-
-/* 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)
-{
- ann->quickprop_mu = quickprop_mu;
-}
+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)
-/* 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)
-{
- ann->rprop_increase_factor = rprop_increase_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)
-{
- ann->rprop_decrease_factor = rprop_decrease_factor;
-}
-
-/* The minimum stepsize (default 0.0). */
-FANN_EXTERNAL void FANN_API fann_set_rprop_delta_min(struct fann *ann, float rprop_delta_min)
-{
- ann->rprop_delta_min = rprop_delta_min;
-}
-
-/* The maximum stepsize (default 50.0). */
-FANN_EXTERNAL void FANN_API fann_set_rprop_delta_max(struct fann *ann, float rprop_delta_max)
-{
- ann->rprop_delta_max = rprop_delta_max;
-}
-
-/* When using this, training is usually faster. (default ).
- Makes the error used for calculating the slopes
- higher when the difference is higher.
- */
-FANN_EXTERNAL unsigned int FANN_API fann_get_train_error_function(struct fann *ann)
+FANN_EXTERNAL unsigned int FANN_API fann_get_cascade_num_candidates(struct fann *ann)
{
- return ann->train_error_function;
+ return ann->cascade_activation_functions_count *
+ ann->cascade_activation_steepnesses_count *
+ ann->cascade_num_candidate_groups;
}
-/* 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)
-{
- return ann->quickprop_decay;
-}
+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)
-/* 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)
-{
- return ann->quickprop_mu;
-}
+FANN_GET(unsigned int, cascade_activation_functions_count)
+FANN_GET(enum fann_activationfunc_enum *, cascade_activation_functions)
-/* 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)
+FANN_EXTERNAL void fann_set_cascade_activation_functions(struct fann *ann,
+ enum fann_activationfunc_enum *
+ cascade_activation_functions,
+ unsigned int
+ cascade_activation_functions_count)
{
- return ann->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)
-{
- return ann->rprop_decrease_factor;
-}
-
-/* The minimum stepsize (default 0.0). */
-FANN_EXTERNAL float FANN_API fann_get_rprop_delta_min(struct fann *ann)
-{
- return ann->rprop_delta_min;
+ 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));
}
-/* The maximum stepsize (default 50.0). */
-FANN_EXTERNAL float FANN_API fann_get_rprop_delta_max(struct fann *ann)
-{
- return ann->rprop_delta_max;
-}
+FANN_GET(unsigned int, cascade_activation_steepnesses_count)
+FANN_GET(fann_type *, cascade_activation_steepnesses)
-/* 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)
+FANN_EXTERNAL void fann_set_cascade_activation_steepnesses(struct fann *ann,
+ fann_type *
+ cascade_activation_steepnesses,
+ unsigned int
+ cascade_activation_steepnesses_count)
{
- return ann->cascade_activation_functions_count *
- ann->cascade_activation_steepnesses_count *
- ann->cascade_num_candidate_groups;
+ 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
-/* returns the position of the fix point.
- */
-FANN_EXTERNAL unsigned int FANN_API fann_get_decimal_point(struct fann *ann)
-{
- return ann->decimal_point;
-}
-/* returns the multiplier that fix point data is multiplied with.
- */
-FANN_EXTERNAL unsigned int FANN_API fann_get_multiplier(struct fann *ann)
-{
- return ann->multiplier;
-}
+FANN_GET(unsigned int, decimal_point)
+FANN_GET(unsigned int, multiplier)
/* INTERNAL FUNCTION
Adjust the steepwise functions (if used)
@@ -386,22 +295,6 @@ void fann_update_stepwise(struct fann *ann)
fann_min(ann->multiplier - (fann_type) (ann->multiplier / 100.0 + 1.0),
ann->multiplier - 1);
- /*DEBUG
- * ann->sigmoid_results[0] = (fann_type)(ann->multiplier/200.0+0.5);
- * 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] = ann->multiplier - (fann_type)(ann->multiplier/200.0+0.5);
- *
- * ann->sigmoid_symmetric_results[0] = (fann_type)((ann->multiplier/100.0) - ann->multiplier + 0.5);
- * 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] = ann->multiplier - (fann_type)(ann->multiplier/100.0+0.5);
- */
-
for(i = 0; i < 6; i++)
{
ann->sigmoid_values[i] =
diff --git a/src/fann_train.c b/src/fann_train.c
index 71b1172..d3d9728 100644
--- a/src/fann_train.c
+++ b/src/fann_train.c
@@ -62,10 +62,10 @@ fann_type fann_activation_derived(unsigned int activation_function,
case FANN_ELLIOT_SYMMETRIC:
value = fann_clip(value, -0.98f, 0.98f);
return (fann_type) fann_elliot_symmetric_derive(steepness, value, sum);
- default:
+ case FANN_THRESHOLD:
fann_error(NULL, FANN_E_CANT_TRAIN_ACTIVATION);
- return 0;
}
+ return 0;
}
/* INTERNAL FUNCTION
@@ -106,12 +106,22 @@ fann_type fann_update_MSE(struct fann *ann, struct fann_neuron* neuron, fann_typ
switch (neuron->activation_function)
{
case FANN_LINEAR_PIECE_SYMMETRIC:
+ case FANN_THRESHOLD_SYMMETRIC:
case FANN_SIGMOID_SYMMETRIC:
case FANN_SIGMOID_SYMMETRIC_STEPWISE:
case FANN_ELLIOT_SYMMETRIC:
case FANN_GAUSSIAN_SYMMETRIC:
neuron_diff /= 2.0;
break;
+ case FANN_THRESHOLD:
+ case FANN_LINEAR:
+ case FANN_SIGMOID:
+ case FANN_SIGMOID_STEPWISE:
+ case FANN_GAUSSIAN:
+ case FANN_GAUSSIAN_STEPWISE:
+ case FANN_ELLIOT:
+ case FANN_LINEAR_PIECE:
+ break;
}
#ifdef FIXEDFANN
diff --git a/src/fann_train_data.c b/src/fann_train_data.c
index a98c4a1..75159c4 100644
--- a/src/fann_train_data.c
+++ b/src/fann_train_data.c
@@ -178,22 +178,16 @@ FANN_EXTERNAL float FANN_API fann_train_epoch(struct fann *ann, struct fann_trai
{
switch (ann->training_algorithm)
{
- case FANN_TRAIN_QUICKPROP:
- return fann_train_epoch_quickprop(ann, data);
- break;
- case FANN_TRAIN_RPROP:
- return fann_train_epoch_irpropm(ann, data);
- break;
- case FANN_TRAIN_BATCH:
- return fann_train_epoch_batch(ann, data);
- break;
- case FANN_TRAIN_INCREMENTAL:
- return fann_train_epoch_incremental(ann, data);
- break;
- default:
- fann_error((struct fann_error *) ann, FANN_E_CANT_USE_TRAIN_ALG);
- return 0.0;
- }
+ case FANN_TRAIN_QUICKPROP:
+ return fann_train_epoch_quickprop(ann, data);
+ case FANN_TRAIN_RPROP:
+ return fann_train_epoch_irpropm(ann, data);
+ case FANN_TRAIN_BATCH:
+ return fann_train_epoch_batch(ann, data);
+ case FANN_TRAIN_INCREMENTAL:
+ return fann_train_epoch_incremental(ann, data);
+ }
+ return 0;
}
/*
@@ -227,25 +221,10 @@ FANN_EXTERNAL void FANN_API fann_train_on_data_callback(struct fann *ann,
{
float error;
unsigned int i;
+ int desired_error_reached;
#ifdef DEBUG
- printf("Training with ");
- switch (ann->training_algorithm)
- {
- case FANN_TRAIN_QUICKPROP:
- printf("FANN_TRAIN_QUICKPROP");
- break;
- case FANN_TRAIN_RPROP:
- printf("FANN_TRAIN_RPROP");
- break;
- case FANN_TRAIN_BATCH:
- printf("FANN_TRAIN_BATCH");
- break;
- case FANN_TRAIN_INCREMENTAL:
- printf("FANN_TRAIN_INCREMENTAL");
- break;
- }
- printf("\n");
+ printf("Training with %s\n", FANN_TRAIN_NAMES[ann->training_algorithm]);
#endif
if(epochs_between_reports && callback == NULL)
@@ -259,12 +238,14 @@ FANN_EXTERNAL void FANN_API fann_train_on_data_callback(struct fann *ann,
* train
*/
error = fann_train_epoch(ann, data);
+ desired_error_reached = fann_desired_error_reached(ann, desired_error);
/*
* print current output
*/
if(epochs_between_reports &&
- (i % epochs_between_reports == 0 || i == max_epochs || i == 1 || error < desired_error))
+ (i % epochs_between_reports == 0 || i == max_epochs || i == 1 ||
+ desired_error_reached == 0))
{
if(callback == NULL)
{
@@ -280,10 +261,8 @@ FANN_EXTERNAL void FANN_API fann_train_on_data_callback(struct fann *ann,
}
}
- if(error < desired_error)
- {
+ if(desired_error_reached == 0)
break;
- }
}
}
@@ -667,3 +646,22 @@ struct fann_train_data *fann_read_train_from_fd(FILE * file, char *filename)
}
return data;
}
+
+/*
+ * INTERNAL FUNCTION returns 0 if the desired error is reached and -1 if it is not reached
+ */
+int fann_desired_error_reached(struct fann *ann, float desired_error)
+{
+ switch (ann->train_stop_function)
+ {
+ case FANN_STOPFUNC_MSE:
+ if(fann_get_MSE(ann) < desired_error)
+ return 0;
+ break;
+ case FANN_STOPFUNC_BIT:
+ if(ann->num_bit_fail < desired_error)
+ return 0;
+ break;
+ }
+ return -1;
+}
diff --git a/src/include/fann.h b/src/include/fann.h
index 52e3415..2d18762 100644
--- a/src/include/fann.h
+++ b/src/include/fann.h
@@ -27,11 +27,11 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
/* just to allow for inclusion of fann.h in normal stuations where only floats are needed */
#ifdef FIXEDFANN
#include "fixedfann.h"
-#else /*
*/
+#else
#include "floatfann.h"
#endif /* FIXEDFANN */
-#else /*
*/
+#else
/* COMPAT_TIME REPLACEMENT */
#ifndef _WIN32
@@ -50,6 +50,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#include "fann_data.h"
#include "fann_internal.h"
#include "fann_activation.h"
+#include "fann_errno.h"
#ifndef __fann_h__
#define __fann_h__
@@ -58,12 +59,15 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
extern "C"
{
+#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.
@@ -94,7 +98,7 @@ extern "C"
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
@@ -112,18 +116,18 @@ extern "C"
#if defined(_MSC_VER) && (defined(FANN_USE_DLL) || defined(FANN_DLL_EXPORTS))
#ifdef FANN_DLL_EXPORTS
#define FANN_EXTERNAL __declspec(dllexport)
-#else /*
*/
+#else /*
*/
#define FANN_EXTERNAL __declspec(dllimport)
#endif /* FANN_DLL_EXPORTS*/
#define FANN_API __stdcall
-#else /*
*/
+#else /*
*/
#define FANN_EXTERNAL
#define FANN_API
#endif /* _MSC_VER */
/* ----- End of macros used to define DLL external entrypoints ----- */
-
+
/* ----- Implemented in fann.c Creation, running and destruction of ANNs ----- */
-
+
/* 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.
@@ -136,72 +140,66 @@ 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,
- /* 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 */
- ...);
-
+ 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
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);
-
+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.
*/
-
- 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(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 */
+
/* 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);
-
+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.
*/
- FANN_EXTERNAL fann_type * FANN_API fann_run(struct fann *ann, fann_type * input);
-
+FANN_EXTERNAL fann_type * FANN_API fann_run(struct fann *ann, fann_type * input);
+
/* 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);
-
+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)
*/
-
- FANN_EXTERNAL void FANN_API fann_randomize_weights(struct fann *ann, fann_type min_weight,
- fann_type max_weight);
-
+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.
*/
-
- FANN_EXTERNAL void FANN_API fann_init_weights(struct fann *ann,
- struct fann_train_data *train_data);
-
+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 */
- FANN_EXTERNAL void FANN_API fann_print_connections(struct fann *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);
-
+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);
-
+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.
@@ -227,49 +225,45 @@ extern "C"
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);
-
+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);
-
+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);
-
+ 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);
-
+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);
-
+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);
-
+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);
-
+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
@@ -282,339 +276,343 @@ extern "C"
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);
-
+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);
-
+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);
-
+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);
-
-/* Trains on an entire dataset, for a maximum of max_epochs
+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);
-
-/* Same as fann_train_on_data, but a callback function is 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));
-
+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);
-
+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));
-
+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);
-
+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);
-
+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);
-
+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);
-
+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);
-
+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);
-
+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);
-
+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);
-
+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 ----- */
-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);
-
+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);
-
+FANN_EXTERNAL void FANN_API fann_print_parameters(struct fann *ann);
+
/* Get the training algorithm.
*/
- FANN_EXTERNAL unsigned int FANN_API fann_get_training_algorithm(struct fann *ann);
-
+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,
- unsigned int 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);
-
+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);
-
-/* Get the activation function used in the hidden layers.
- */
- FANN_EXTERNAL unsigned int FANN_API fann_get_activation_function_hidden(struct fann *ann);
-
+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,
- unsigned int
- activation_function);
-
-/* Get the activation function used in the output layer.
- */
- FANN_EXTERNAL unsigned int FANN_API fann_get_activation_function_output(struct fann *ann);
-
+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,
- unsigned int
- activation_function);
-
-/* Get the steepness parameter for the sigmoid function used in the hidden layers.
- */
- FANN_EXTERNAL fann_type FANN_API fann_get_activation_steepness_hidden(struct fann *ann);
-
-/* Set the steepness of the sigmoid function used in the hidden layers.
+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);
-
-/* Get the steepness parameter for the sigmoid function used in the output layer.
- */
- FANN_EXTERNAL fann_type FANN_API fann_get_activation_steepness_output(struct fann *ann);
-
+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);
-
-/* OBSOLETE use fann_get_activation_steepness_hidden
- Get the steepness parameter for the sigmoid function used in the hidden layers.
- */
- FANN_EXTERNAL fann_type FANN_API fann_get_activation_hidden_steepness(struct fann *ann);
-
-/* OBSOLETE use fann_set_activation_steepness_hidden
- 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_hidden_steepness(struct fann *ann,
- fann_type steepness);
-
-/* OBSOLETE use fann_get_activation_steepness_output
- Get the steepness parameter for the sigmoid function used in the output layer.
- */
- FANN_EXTERNAL fann_type FANN_API fann_get_activation_output_steepness(struct fann *ann);
-
-/* OBSOLETE use 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);
+
+
+/* Set the error function used during training. (default FANN_ERRORFUNC_TANH)
*/
-
- FANN_EXTERNAL void FANN_API fann_set_activation_output_steepness(struct fann *ann,
- fann_type steepness);
-
-/* Get the error function used during training. (default FANN_ERRORFUNC_TANH)
- */
-
- FANN_EXTERNAL void FANN_API fann_set_train_error_function(struct fann *ann,
- unsigned int
- train_error_function);
-
+FANN_EXTERNAL void FANN_API fann_set_train_error_function(struct fann *ann,
+ enum fann_errorfunc_enum
+ train_error_function);
+
+
/* Get the error function used during training.
*/
- FANN_EXTERNAL unsigned int FANN_API fann_get_train_error_function(struct fann *ann);
-
+FANN_EXTERNAL enum fann_errorfunc_enum FANN_API fann_get_train_error_function(struct fann *ann);
+
+
+/* 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);
+
+
+/* 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);
-
+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);
-
+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);
-
+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);
-
+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);
-
+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);
-
+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);
-
+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);
-
+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);
-
+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);
-
+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);
-
+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);
-
+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);
-
+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);
-
+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);
-
+FANN_EXTERNAL unsigned int FANN_API fann_get_total_neurons(struct fann *ann);
+
/* Get the total number of connections 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_connections(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).
+ */
+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);
-/* 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);
-
+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);
+
#ifdef FIXEDFANN
-
+
/* returns the position of the decimal point.
*/
- FANN_EXTERNAL unsigned int FANN_API fann_get_decimal_point(struct fann *ann);
-
+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_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);
-
+FANN_EXTERNAL void FANN_API fann_set_error_log(struct fann_error *errdat, FILE * log_file);
+
/* returns the last error number
*/
- FANN_EXTERNAL unsigned int FANN_API fann_get_errno(struct fann_error *errdat);
-
+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);
-
+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);
-
+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);
-
+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);
-
+FANN_EXTERNAL void FANN_API fann_print_error(struct fann_error *errdat);
+
#ifdef __cplusplus
+#ifndef __cplusplus
+/* to fool automatic indention engines */
+{
+
+#endif
}
#endif /* __cplusplus */
-
+
#endif /* __fann_h__ */
-
-#endif /* NOT FANN_INCLUDE */
+
+#endif /* NOT FANN_INCLUDE */
diff --git a/src/include/fann_activation.h b/src/include/fann_activation.h
index 64311ef..a55781a 100644
--- a/src/include/fann_activation.h
+++ b/src/include/fann_activation.h
@@ -30,7 +30,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
d is the derivation.
*/
-enum
+enum fann_activationfunc_enum
{
/* Linear activation function.
* span: -inf < y < inf
@@ -230,10 +230,6 @@ switch(activation_function) \
case FANN_ELLIOT_SYMMETRIC: \
result = (fann_type)fann_elliot_symmetric_real(value); \
break; \
- default: \
- fann_error((struct fann_error *)ann, FANN_E_CANT_USE_ACTIVATION); \
- result = 0; \
- break; \
}
#endif
diff --git a/src/include/fann_data.h b/src/include/fann_data.h
index aeaceb0..d2282b4 100644
--- a/src/include/fann_data.h
+++ b/src/include/fann_data.h
@@ -21,6 +21,56 @@ 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"
+
+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
+};
+
+static char const *const FANN_TRAIN_NAMES[] = {
+ "FANN_TRAIN_INCREMENTAL",
+ "FANN_TRAIN_BATCH",
+ "FANN_TRAIN_RPROP",
+ "FANN_TRAIN_QUICKPROP"
+};
+
+/* Error function used during training */
+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
+};
+
+static char const *const FANN_ERRORFUNC_NAMES[] = {
+ "FANN_ERRORFUNC_LINEAR",
+ "FANN_ERRORFUNC_TANH"
+};
+
+/* Stop function used during training */
+enum fann_stopfunc_enum
+{
+ /* Stop criteria is MSE value */
+ FANN_STOPFUNC_MSE = 0,
+ /* Stop criteria is number of bits that fail */
+ FANN_STOPFUNC_BIT
+};
+
+static char const *const FANN_STOPFUNC_NAMES[] = {
+ "FANN_STOPFUNC_MSE",
+ "FANN_STOPFUNC_BIT"
+};
/* ----- Data structures -----
* No data within these structures should be altered directly by the user.
@@ -40,7 +90,7 @@ struct fann_neuron
/* The steepness of the activation function */
fann_type activation_steepness;
/* Used to choose which activation function to use */
- unsigned int activation_function;
+ enum fann_activationfunc_enum activation_function;
#ifdef __GNUC__
} __attribute__ ((packed));
#else
@@ -63,12 +113,21 @@ struct fann_layer
struct fann_neuron *last_neuron;
};
+/* Structure used to store error-related information */
+struct fann_error
+{
+ enum fann_errno_enum errno_f;
+ FILE *error_log;
+ char *errstr;
+};
+
+
/* The fast artificial neural network(fann) structure
*/
struct fann
{
/* The type of error that last occured. */
- unsigned int errno_f;
+ enum fann_errno_enum errno_f;
/* Where to log error messages. */
FILE *error_log;
@@ -126,7 +185,7 @@ struct fann
/* Training algorithm used when calling fann_train_on_..
*/
- unsigned int training_algorithm;
+ enum fann_train_enum training_algorithm;
#ifdef FIXEDFANN
/* the decimal_point, used for shifting the fix point
@@ -182,11 +241,11 @@ struct fann
/* The error function used during training. (default FANN_ERRORFUNC_TANH)
*/
- unsigned int train_error_function;
+ enum fann_errorfunc_enum train_error_function;
/* The stop function used during training. (default FANN_STOPFUNC_MSE)
*/
- unsigned int train_stop_function;
+ enum fann_stopfunc_enum train_stop_function;
/* Variables for use with Cascade Correlation */
@@ -224,7 +283,7 @@ struct fann
/* An array consisting of the activation functions used when doing
* cascade training.
*/
- unsigned int *cascade_activation_functions;
+ enum fann_activationfunc_enum *cascade_activation_functions;
/* The number of elements in the cascade_activation_functions array.
*/
@@ -308,7 +367,7 @@ struct fann
/* Structure used to store data, for use with training. */
struct fann_train_data
{
- unsigned int errno_f;
+ enum fann_errno_enum errno_f;
FILE *error_log;
char *errstr;
@@ -319,60 +378,4 @@ struct fann_train_data
fann_type **output;
};
-/* Structure used to store error-related information */
-struct fann_error
-{
- unsigned int errno_f;
- FILE *error_log;
- char *errstr;
-};
-
-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
-};
-
-static char const *const FANN_TRAIN_NAMES[] = {
- "FANN_TRAIN_INCREMENTAL",
- "FANN_TRAIN_BATCH",
- "FANN_TRAIN_RPROP",
- "FANN_TRAIN_QUICKPROP"
-};
-
-/* Error function used during training */
-enum
-{
- /* Standard linear error function */
- FANN_ERRORFUNC_LINEAR = 0,
- /* Tanh error function, usually better but can require
- * a lower learning rate */
- FANN_ERRORFUNC_TANH
-};
-
-static char const *const FANN_ERRORFUNC_NAMES[] = {
- "FANN_ERRORFUNC_LINEAR",
- "FANN_ERRORFUNC_TANH"
-};
-
-/* Stop function used during training */
-enum fann_stopfunc_enum
-{
- /* Stop criteria is MSE value */
- FANN_STOPFUNC_MSE = 0,
- /* Stop criteria is number of bits that fail */
- FANN_STOPFUNC_BIT
-};
-
-static char const *const FANN_STOPFUNC_NAMES[] = {
- "FANN_STOPFUNC_MSE",
- "FANN_STOPFUNC_BIT"
-};
-
#endif
diff --git a/src/include/fann_errno.h b/src/include/fann_errno.h
index 0975505..d65df18 100644
--- a/src/include/fann_errno.h
+++ b/src/include/fann_errno.h
@@ -28,7 +28,7 @@ extern "C"
/* Maximum length (in bytes) of an error message */
#define FANN_ERRSTR_MAX 128
- enum
+ enum fann_errno_enum
{
/* No error */
FANN_E_NO_ERROR = 0,
diff --git a/src/include/fann_internal.h b/src/include/fann_internal.h
index e78de78..373ce1d 100644
--- a/src/include/fann_internal.h
+++ b/src/include/fann_internal.h
@@ -54,7 +54,7 @@ void fann_seed_rand();
void fann_update_stepwise(struct fann *ann);
-void fann_error(struct fann_error *errdat, const unsigned int errno_f, ...);
+void fann_error(struct fann_error *errdat, const enum fann_errno_enum errno_f, ...);
void fann_init_error_data(struct fann_error *errdat);
struct fann *fann_create_from_fd(FILE * conf, const char *configuration_file);
@@ -82,6 +82,8 @@ fann_type fann_activation_new(struct fann *ann, unsigned int activation_function
fann_type fann_activation_derived(unsigned int activation_function,
fann_type steepness, fann_type value, fann_type sum);
+int fann_desired_error_reached(struct fann *ann, float desired_error);
+
/* called fann_max, in order to not interferre with predefined versions of max */
#define fann_max(x, y) (((x) > (y)) ? (x) : (y))
#define fann_min(x, y) (((x) < (y)) ? (x) : (y))
--
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