[libfann] 235/242: *** empty log message ***
Christian Kastner
chrisk-guest at moszumanska.debian.org
Sat Oct 4 21:10:49 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 6a70851eef30bbf576023f976e5c73d2d6d520ab
Author: Steffen Nissen <lukesky at diku.dk>
Date: Fri Jan 6 19:12:13 2006 +0000
*** empty log message ***
---
examples/Makefile | 2 +-
examples/cascade_train.c | 25 +------------------------
examples/momentums.c | 2 --
examples/xor_train.c | 5 +----
src/fann.c | 38 ++++++++++++++++++++++----------------
src/fann_cascade.c | 8 ++++----
src/fann_train.c | 10 ++++------
src/include/fann_internal.h | 6 +++---
src/include/fann_train.h | 2 +-
9 files changed, 37 insertions(+), 61 deletions(-)
diff --git a/examples/Makefile b/examples/Makefile
index 395cd69..5a88fcd 100644
--- a/examples/Makefile
+++ b/examples/Makefile
@@ -15,7 +15,7 @@ all: $(TARGETS)
$(GCC) -O3 -lm -lfixedfann -DFIXEDFANN $< -o $@
clean:
- rm -f $(TARGETS) $(DEBUG_TARGETS) xor_fixed.data *.net *~
+ rm -f $(TARGETS) $(DEBUG_TARGETS) xor_fixed.data *.net *~ *.obj *.exe *.tds
runtest: $(TARGETS)
@echo
diff --git a/examples/cascade_train.c b/examples/cascade_train.c
index 11ae73a..43b0a13 100644
--- a/examples/cascade_train.c
+++ b/examples/cascade_train.c
@@ -29,7 +29,6 @@ int main()
const float desired_error = (const float) 0.001;
unsigned int max_neurons = 40;
unsigned int neurons_between_reports = 1;
- fann_type steepnesses[] = {0.1,0.2,0.4,0.5,0.6,0.7,0.8,0.9,1.0,1.1};
printf("Reading data.\n");
@@ -44,32 +43,10 @@ int main()
ann = fann_create_shortcut(2, fann_num_input_train_data(train_data), fann_num_output_train_data(train_data));
fann_set_training_algorithm(ann, FANN_TRAIN_RPROP);
-
fann_set_activation_function_hidden(ann, FANN_SIGMOID_SYMMETRIC);
fann_set_activation_function_output(ann, FANN_LINEAR_PIECE);
- fann_set_activation_steepness_hidden(ann, 0.5);
- fann_set_activation_steepness_output(ann, 0.5);
-
fann_set_train_error_function(ann, FANN_ERRORFUNC_LINEAR);
- 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);
-
- fann_set_cascade_output_change_fraction(ann, 0.01);
- fann_set_cascade_output_stagnation_epochs(ann, 12);
- fann_set_cascade_candidate_change_fraction(ann, 0.01);
- fann_set_cascade_candidate_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_activation_steepnesses(ann, steepnesses, 10);
- fann_set_cascade_num_candidate_groups(ann, 1);
-
- /*fann_set_callback(ann, print_callback);*/
-
fann_print_parameters(ann);
printf("Training network.\n");
@@ -83,7 +60,7 @@ int main()
printf("Saving network.\n");
- fann_save(ann, "xor_float.net");
+ fann_save(ann, "two_spirali.net");
printf("Cleaning up.\n");
fann_destroy_train(train_data);
diff --git a/examples/momentums.c b/examples/momentums.c
index 6514930..8b07fca 100644
--- a/examples/momentums.c
+++ b/examples/momentums.c
@@ -29,8 +29,6 @@ int main()
struct fann *ann;
struct fann_train_data *train_data, *test_data;
- unsigned int i = 0;
-
float momentum;
train_data = fann_read_train_from_file("../benchmarks/datasets/robot.train");
diff --git a/examples/xor_train.c b/examples/xor_train.c
index e7d706c..17866f0 100644
--- a/examples/xor_train.c
+++ b/examples/xor_train.c
@@ -46,11 +46,8 @@ int main()
unsigned int decimal_point;
printf("Creating network.\n");
-
ann = fann_create_standard(num_layers, num_input, num_neurons_hidden, num_output);
- printf("Training network.\n");
-
data = fann_read_train_from_file("xor.data");
fann_set_activation_steepness_hidden(ann, 1);
@@ -64,9 +61,9 @@ int main()
fann_init_weights(ann, data);
+ printf("Training network.\n");
fann_train_on_data(ann, data, max_epochs, epochs_between_reports, desired_error);
-
printf("Testing network. %f\n", fann_test_data(ann, data));
for(i = 0; i < fann_length_train_data(data); i++)
diff --git a/src/fann.c b/src/fann.c
index 40bf25b..45bef7c 100644
--- a/src/fann.c
+++ b/src/fann.c
@@ -1,17 +1,17 @@
/*
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
@@ -89,14 +89,16 @@ FANN_EXTERNAL struct fann *FANN_API fann_create_sparse(float connection_rate,
}
FANN_EXTERNAL struct fann *FANN_API fann_create_sparse_array(float connection_rate,
- unsigned int num_layers,
+ unsigned int num_layers,
unsigned int *layers)
{
struct fann_layer *layer_it, *last_layer, *prev_layer;
struct fann *ann;
- struct fann_neuron *neuron_it, *first_neuron, *last_neuron, *random_neuron, *bias_neuron;
- unsigned int prev_layer_size, i, j;
- unsigned int num_neurons_in, num_neurons_out;
+ struct fann_neuron *neuron_it, *last_neuron, *random_neuron, *bias_neuron;
+#ifdef DEBUG
+ unsigned int prev_layer_size;
+#endif
+ unsigned int num_neurons_in, num_neurons_out, i, j;
unsigned int min_connections, max_connections, num_connections;
unsigned int connections_per_neuron, allocated_connections;
unsigned int random_number, found_connection;
@@ -213,11 +215,11 @@ FANN_EXTERNAL struct fann *FANN_API fann_create_sparse_array(float connection_ra
return NULL;
}
- first_neuron = ann->first_layer->first_neuron;
-
if(connection_rate >= 1)
{
+#ifdef DEBUG
prev_layer_size = ann->num_input + 1;
+#endif
prev_layer = ann->first_layer;
last_layer = ann->last_layer;
for(layer_it = ann->first_layer + 1; layer_it != last_layer; layer_it++)
@@ -234,7 +236,9 @@ FANN_EXTERNAL struct fann *FANN_API fann_create_sparse_array(float connection_ra
ann->connections[i] = prev_layer->first_neuron + (i - neuron_it->first_con);
}
}
+#ifdef DEBUG
prev_layer_size = layer_it->last_neuron - layer_it->first_neuron;
+#endif
prev_layer = layer_it;
#ifdef DEBUG
printf(" layer : %d neurons, 1 bias\n", prev_layer_size - 1);
@@ -1115,7 +1119,7 @@ struct fann *fann_allocate_structure(unsigned int num_layers)
ann->num_MSE = 0;
ann->MSE_value = 0;
ann->num_bit_fail = 0;
- ann->bit_fail_limit = 0.35f;
+ ann->bit_fail_limit = (fann_type)0.35;
ann->shortcut_connections = 0;
ann->train_error_function = FANN_ERRORFUNC_TANH;
ann->train_stop_function = FANN_STOPFUNC_MSE;
@@ -1127,8 +1131,8 @@ struct fann *fann_allocate_structure(unsigned int num_layers)
ann->cascade_output_stagnation_epochs = 12;
ann->cascade_candidate_stagnation_epochs = 12;
ann->cascade_num_candidate_groups = 2;
- ann->cascade_weight_multiplier = 0.4f;
- ann->cascade_candidate_limit = 1000.0f;
+ ann->cascade_weight_multiplier = (fann_type)0.4;
+ ann->cascade_candidate_limit = (fann_type)1000.0;
ann->cascade_max_out_epochs = 150;
ann->cascade_max_cand_epochs = 150;
ann->cascade_candidate_scores = NULL;
@@ -1162,10 +1166,10 @@ struct fann *fann_allocate_structure(unsigned int num_layers)
return NULL;
}
- 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;
+ ann->cascade_activation_steepnesses[0] = (fann_type)0.25;
+ ann->cascade_activation_steepnesses[1] = (fann_type)0.5;
+ ann->cascade_activation_steepnesses[2] = (fann_type)0.75;
+ ann->cascade_activation_steepnesses[3] = (fann_type)1.0;
/* Variables for use with with Quickprop training (reasonable defaults) */
ann->quickprop_decay = (float) -0.0001;
@@ -1263,6 +1267,7 @@ void fann_allocate_connections(struct fann *ann)
}
}
+
/* INTERNAL FUNCTION
Seed the random function.
*/
@@ -1292,3 +1297,4 @@ void fann_seed_rand()
srand(GetTickCount());
#endif
}
+
diff --git a/src/fann_cascade.c b/src/fann_cascade.c
index 0669371..47d1743 100644
--- a/src/fann_cascade.c
+++ b/src/fann_cascade.c
@@ -451,9 +451,9 @@ int fann_initialize_candidates(struct fann *ann)
int fann_train_candidates(struct fann *ann, struct fann_train_data *data)
{
- float best_cand_score = 0.0;
- float target_cand_score = 0.0;
- float backslide_cand_score = -1.0e20f;
+ fann_type best_cand_score = 0.0;
+ fann_type target_cand_score = 0.0;
+ fann_type backslide_cand_score = -1.0e20f;
unsigned int i;
unsigned int max_epochs = ann->cascade_max_cand_epochs;
unsigned int stagnation = max_epochs;
@@ -641,7 +641,7 @@ void fann_update_candidate_weights(struct fann *ann, unsigned int num_data)
}
}
-float fann_train_candidates_epoch(struct fann *ann, struct fann_train_data *data)
+fann_type fann_train_candidates_epoch(struct fann *ann, struct fann_train_data *data)
{
unsigned int i, j;
unsigned int best_candidate;
diff --git a/src/fann_train.c b/src/fann_train.c
index f68d070..95e5479 100644
--- a/src/fann_train.c
+++ b/src/fann_train.c
@@ -100,7 +100,7 @@ FANN_EXTERNAL void FANN_API fann_train(struct fann *ann, fann_type * input,
*/
fann_type fann_update_MSE(struct fann *ann, struct fann_neuron* neuron, fann_type neuron_diff)
{
- fann_type neuron_diff2;
+ float neuron_diff2;
switch (neuron->activation_function)
{
@@ -110,7 +110,7 @@ fann_type fann_update_MSE(struct fann *ann, struct fann_neuron* neuron, fann_typ
case FANN_SIGMOID_SYMMETRIC_STEPWISE:
case FANN_ELLIOT_SYMMETRIC:
case FANN_GAUSSIAN_SYMMETRIC:
- neuron_diff /= 2.0;
+ neuron_diff /= (fann_type)2.0;
break;
case FANN_THRESHOLD:
case FANN_LINEAR:
@@ -353,7 +353,7 @@ void fann_backpropagate_MSE(struct fann *ann)
*/
void fann_update_weights(struct fann *ann)
{
- struct fann_neuron *neuron_it, *last_neuron, *prev_neurons, **connections;
+ struct fann_neuron *neuron_it, *last_neuron, *prev_neurons;
fann_type tmp_error, delta_w, *weights;
struct fann_layer *layer_it;
unsigned int i;
@@ -418,7 +418,6 @@ void fann_update_weights(struct fann *ann)
tmp_error = error_begin[neuron_it - first_neuron] * learning_rate;
num_connections = neuron_it->last_con - neuron_it->first_con;
weights = ann->weights + neuron_it->first_con;
- connections = ann->connections + neuron_it->first_con;
weights_deltas = deltas_begin + neuron_it->first_con;
for(i = 0; i != num_connections; i++)
{
@@ -441,7 +440,7 @@ void fann_update_slopes_batch(struct fann *ann, struct fann_layer *layer_begin,
struct fann_layer *layer_end)
{
struct fann_neuron *neuron_it, *last_neuron, *prev_neurons, **connections;
- fann_type tmp_error, *weights_begin;
+ fann_type tmp_error;
unsigned int i, num_connections;
/* store some variabels local for fast access */
@@ -472,7 +471,6 @@ void fann_update_slopes_batch(struct fann *ann, struct fann_layer *layer_begin,
}
slope_begin = ann->train_slopes;
- weights_begin = ann->weights;
#ifdef DEBUGTRAIN
printf("\nupdate slopes\n");
diff --git a/src/include/fann_internal.h b/src/include/fann_internal.h
index 6ca75a8..17a8d2f 100644
--- a/src/include/fann_internal.h
+++ b/src/include/fann_internal.h
@@ -52,6 +52,7 @@ FANN_EXTERNAL void FANN_API fann_set_ ## name(struct fann *ann, type value) \
FANN_GET(type, name) \
FANN_SET(type, name)
+
struct fann_train_data;
struct fann *fann_allocate_structure(unsigned int num_layers);
@@ -68,9 +69,8 @@ int fann_save_train_internal(struct fann_train_data *data, const char *filename,
int fann_save_train_internal_fd(struct fann_train_data *data, FILE * file, const char *filename,
unsigned int save_as_fixed, unsigned int decimal_point);
-void fann_seed_rand();
-
void fann_update_stepwise(struct fann *ann);
+void fann_seed_rand();
void fann_error(struct fann_error *errdat, const enum fann_errno_enum errno_f, ...);
void fann_init_error_data(struct fann_error *errdat);
@@ -108,7 +108,7 @@ float fann_train_outputs_epoch(struct fann *ann, struct fann_train_data *data);
int fann_train_candidates(struct fann *ann, struct fann_train_data *data);
-float fann_train_candidates_epoch(struct fann *ann, struct fann_train_data *data);
+fann_type fann_train_candidates_epoch(struct fann *ann, struct fann_train_data *data);
void fann_install_candidate(struct fann *ann);
diff --git a/src/include/fann_train.h b/src/include/fann_train.h
index 9aa9caa..c0ecd52 100644
--- a/src/include/fann_train.h
+++ b/src/include/fann_train.h
@@ -752,7 +752,7 @@ FANN_EXTERNAL void FANN_API fann_set_bit_fail_limit(struct fann *ann, fann_type
This function appears in FANN >= 2.0.0.
*/
-FANN_EXTERNAL void fann_set_callback(struct fann *ann, fann_callback_type callback);
+FANN_EXTERNAL void FANN_API fann_set_callback(struct fann *ann, fann_callback_type callback);
/* Function: fann_get_quickprop_decay
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/libfann.git
More information about the debian-science-commits
mailing list