[libfann] 156/242: major bug fixed in rprop training (used quickprop core). Also new benchmarks made.
Christian Kastner
chrisk-guest at moszumanska.debian.org
Sat Oct 4 21:10:37 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 07bf649c689c9a5a96c3e7e1b7dd65095c285955
Author: Steffen Nissen <lukesky at diku.dk>
Date: Wed Jul 7 09:46:11 2004 +0000
major bug fixed in rprop training (used quickprop core). Also new benchmarks made.
---
TODO | 2 ++
benchmarks/Makefile | 2 +-
benchmarks/benchmark.sh | 5 ++++-
benchmarks/benchmarks.pdf | Bin 55420 -> 815106 bytes
benchmarks/gnuplot | 35 +++++++++++++----------------------
benchmarks/quality.cc | 16 +++++++---------
examples/mushroom.c | 2 +-
examples/robot.c | 4 ++--
examples/xor_train.c | 2 +-
src/fann_train.c | 8 ++++++--
src/fann_train_data.c | 2 +-
src/include/fann_internal.h | 1 +
12 files changed, 39 insertions(+), 40 deletions(-)
diff --git a/TODO b/TODO
index 04f76b0..bebdc84 100644
--- a/TODO
+++ b/TODO
@@ -38,6 +38,8 @@ Things TODO when releasing a new version (mostly for fann developers)
* Changelog should be updated and timestamp should be set
+* CVS branch for release
+
* PHP Extension should be up-to-date (including documentation)
* Debian packages should be created
diff --git a/benchmarks/Makefile b/benchmarks/Makefile
index 75dc8e8..061e6e4 100644
--- a/benchmarks/Makefile
+++ b/benchmarks/Makefile
@@ -37,4 +37,4 @@ parity: parity.c
$(GCC) $(CFLAGS) $(LFLAGS) $< -o $@
clean:
- rm -rf $(TARGETS) *.net *.out *_fixed_test_* *_fixed_train_* *~ *ps
+ rm -rf -- $(TARGETS) *.net *.out *fixed_test* *fixed_train* *~ *ps
diff --git a/benchmarks/benchmark.sh b/benchmarks/benchmark.sh
index 94282dd..ccef77f 100755
--- a/benchmarks/benchmark.sh
+++ b/benchmarks/benchmark.sh
@@ -1,14 +1,17 @@
#!/bin/sh
+date;
+
max_seconds_training=200;
secs_between_reports=0.01;
function benchmark_algorithm() {
./quality $algo datasets/$prob.train datasets/$prob.test $prob.$algo.train.out $prob.$algo.test.out $n1 $n2 $sec_train $secs_between_reports
+ date;
}
function benchmark_problem() {
- rm -f *_fixed.net
+ #rm -f *_fixed.net
algo="fann_rprop"; benchmark_algorithm;
#./quality_fixed $prob.$algo.train.out_fixed_train $prob.$algo.train.out_fixed_test $prob.$algo.fixed_train.out $prob.$algo.fixed_test.out *_fixed.net
algo="fann_rprop_stepwise"; benchmark_algorithm;
diff --git a/benchmarks/benchmarks.pdf b/benchmarks/benchmarks.pdf
index da60a7d..ac48299 100644
Binary files a/benchmarks/benchmarks.pdf and b/benchmarks/benchmarks.pdf differ
diff --git a/benchmarks/gnuplot b/benchmarks/gnuplot
index c2df335..9c2612a 100644
--- a/benchmarks/gnuplot
+++ b/benchmarks/gnuplot
@@ -10,10 +10,10 @@ set logscale
#set output "performance.ps"
set title "Performance of execution"
plot "fann_performance.out" title "fann" with lines -1, \
- "fann_stepwise_performance.out" title "fann (stepwise)" with lines 1, \
- "fann_fixed_performance.out" title "fann (fix)" with lines 2, \
- "lwnn_performance.out" title "lwnn" with lines 3, \
- "jneural_performance.out" title "jneural" with lines 4
+ "fann_stepwise_performance.out" title "fann (stepwise)" with lines 2, \
+ "fann_fixed_performance.out" title "fann (fix)" with lines 1, \
+ "lwnn_performance.out" title "lwnn" with lines 8, \
+ "jneural_performance.out" title "jneural" with lines 9
set nologscale
@@ -24,7 +24,6 @@ set logscale
#set output "building.ps"
set title "building"
plot "building.fann_rprop.test.out" title "fann rprop test" with lines -1, \
- "building.fann_rprop.fixed_test.out" title "fann rprop (fixed) test" with lines 1, \
"building.fann_rprop_stepwise.test.out" title "fann rprop (stepwise) test" with lines 2, \
"building.fann_quickprop.test.out" title "fann quickprop test" with lines 3, \
"building.fann_batch.test.out" title "fann batch test" with lines 4, \
@@ -32,7 +31,6 @@ plot "building.fann_rprop.test.out" title "fann rprop test" with lines -1, \
"building.lwnn.test.out" title "lwnn incremental test" with lines 8, \
"building.jneural.test.out" title "jneural incremental test" with lines 9, \
"building.fann_rprop.train.out" title "fann rprop train" with lines -1, \
- "building.fann_rprop.fixed_train.out" title "fann rprop (fixed) train" with lines 1, \
"building.fann_rprop_stepwise.train.out" title "fann rprop (stepwise) train" with lines 2, \
"building.fann_quickprop.train.out" title "fann quickprop train" with lines 3, \
"building.fann_batch.train.out" title "fann batch train" with lines 4, \
@@ -41,11 +39,10 @@ plot "building.fann_rprop.test.out" title "fann rprop test" with lines -1, \
"building.jneural.train.out" title "jneural incremental train" with lines 9
set nologscale
-#set logscale x
+set logscale x
#set output "gene.ps"
set title "gene"
plot "gene.fann_rprop.test.out" title "fann rprop test" with lines -1, \
- "gene.fann_rprop.fixed_test.out" title "fann rprop (fixed) test" with lines 1, \
"gene.fann_rprop_stepwise.test.out" title "fann rprop (stepwise) test" with lines 2, \
"gene.fann_quickprop.test.out" title "fann quickprop test" with lines 3, \
"gene.fann_batch.test.out" title "fann batch test" with lines 4, \
@@ -53,20 +50,18 @@ plot "gene.fann_rprop.test.out" title "fann rprop test" with lines -1, \
"gene.lwnn.test.out" title "lwnn incremental test" with lines 8, \
"gene.jneural.test.out" title "jneural incremental test" with lines 9, \
"gene.fann_rprop.train.out" title "fann rprop train" with lines -1, \
- "gene.fann_rprop.fixed_train.out" title "fann rprop (fixed) train" with lines 1, \
"gene.fann_rprop_stepwise.train.out" title "fann rprop (stepwise) train" with lines 2, \
"gene.fann_quickprop.train.out" title "fann quickprop train" with lines 3, \
"gene.fann_batch.train.out" title "fann batch train" with lines 4, \
"gene.fann_incremental.train.out" title "fann incremental train" with lines 5, \
"gene.lwnn.train.out" title "lwnn incremental train" with lines 8, \
"gene.jneural.train.out" title "jneural incremental train" with lines 9
+set nologscale
-set logscale
-#set logscale x
+set logscale x
#set output "mushroom.ps"
set title "mushroom"
plot "mushroom.fann_rprop.test.out" title "fann rprop test" with lines -1, \
- "mushroom.fann_rprop.fixed_test.out" title "fann rprop (fixed) test" with lines 1, \
"mushroom.fann_rprop_stepwise.test.out" title "fann rprop (stepwise) test" with lines 2, \
"mushroom.fann_quickprop.test.out" title "fann quickprop test" with lines 3, \
"mushroom.fann_batch.test.out" title "fann batch test" with lines 4, \
@@ -74,7 +69,6 @@ plot "mushroom.fann_rprop.test.out" title "fann rprop test" with lines -1, \
"mushroom.lwnn.test.out" title "lwnn incremental test" with lines 8, \
"mushroom.jneural.test.out" title "jneural incremental test" with lines 9, \
"mushroom.fann_rprop.train.out" title "fann rprop train" with lines -1, \
- "mushroom.fann_rprop.fixed_train.out" title "fann rprop (fixed) train" with lines 1, \
"mushroom.fann_rprop_stepwise.train.out" title "fann rprop (stepwise) train" with lines 2, \
"mushroom.fann_quickprop.train.out" title "fann quickprop train" with lines 3, \
"mushroom.fann_batch.train.out" title "fann batch train" with lines 4, \
@@ -83,7 +77,7 @@ plot "mushroom.fann_rprop.test.out" title "fann rprop test" with lines -1, \
"mushroom.jneural.train.out" title "jneural incremental train" with lines 9
set nologscale
-#set logscale x
+set logscale x
#set output "parity8.ps"
set title "parity8"
plot "parity8.fann_rprop.train.out" title "fann rprop train" with lines -1, \
@@ -93,8 +87,9 @@ plot "parity8.fann_rprop.train.out" title "fann rprop train" with lines -1, \
"parity8.fann_incremental.train.out" title "fann incremental train" with lines 5, \
"parity8.lwnn.train.out" title "lwnn incremental train" with lines 8, \
"parity8.jneural.train.out" title "jneural incremental train" with lines 9
+set nologscale
-#set logscale x
+set logscale x
#set output "parity13.ps"
set title "parity13"
plot "parity13.fann_rprop.train.out" title "fann rprop train" with lines -1, \
@@ -104,6 +99,7 @@ plot "parity13.fann_rprop.train.out" title "fann rprop train" with lines -1, \
"parity13.fann_incremental.train.out" title "fann incremental train" with lines 5, \
"parity13.lwnn.train.out" title "lwnn incremental train" with lines 8, \
"parity13.jneural.train.out" title "jneural incremental train" with lines 9
+set nologscale
set logscale
#set output "pumadyn-32fm.ps"
@@ -124,11 +120,10 @@ plot "pumadyn-32fm.fann_rprop.test.out" title "fann rprop test" with lines -1, \
"pumadyn-32fm.jneural.train.out" title "jneural incremental train" with lines 9
set nologscale
-#set logscale x
+set logscale x
#set output "robot.ps"
set title "robot"
plot "robot.fann_rprop.test.out" title "fann rprop test" with lines -1, \
- "robot.fann_rprop.fixed_test.out" title "fann rprop (fixed) test" with lines 1, \
"robot.fann_rprop_stepwise.test.out" title "fann rprop (stepwise) test" with lines 2, \
"robot.fann_quickprop.test.out" title "fann quickprop test" with lines 3, \
"robot.fann_batch.test.out" title "fann batch test" with lines 4, \
@@ -136,7 +131,6 @@ plot "robot.fann_rprop.test.out" title "fann rprop test" with lines -1, \
"robot.lwnn.test.out" title "lwnn incremental test" with lines 8, \
"robot.jneural.test.out" title "jneural incremental test" with lines 9, \
"robot.fann_rprop.train.out" title "fann rprop train" with lines -1, \
- "robot.fann_rprop.fixed_train.out" title "fann rprop (fixed) train" with lines 1, \
"robot.fann_rprop_stepwise.train.out" title "fann rprop (stepwise) train" with lines 2, \
"robot.fann_quickprop.train.out" title "fann quickprop train" with lines 3, \
"robot.fann_batch.train.out" title "fann batch train" with lines 4, \
@@ -148,7 +142,6 @@ set logscale
#set output "soybean.ps"
set title "soybean"
plot "soybean.fann_rprop.test.out" title "fann rprop test" with lines -1, \
- "soybean.fann_rprop.fixed_test.out" title "fann rprop (fixed) test" with lines 1, \
"soybean.fann_rprop_stepwise.test.out" title "fann rprop (stepwise) test" with lines 2, \
"soybean.fann_quickprop.test.out" title "fann quickprop test" with lines 3, \
"soybean.fann_batch.test.out" title "fann batch test" with lines 4, \
@@ -156,7 +149,6 @@ plot "soybean.fann_rprop.test.out" title "fann rprop test" with lines -1, \
"soybean.lwnn.test.out" title "lwnn incremental test" with lines 8, \
"soybean.jneural.test.out" title "jneural incremental test" with lines 9, \
"soybean.fann_rprop.train.out" title "fann rprop train" with lines -1, \
- "soybean.fann_rprop.fixed_train.out" title "fann rprop (fixed) train" with lines 1, \
"soybean.fann_rprop_stepwise.train.out" title "fann rprop (stepwise) train" with lines 2, \
"soybean.fann_quickprop.train.out" title "fann quickprop train" with lines 3, \
"soybean.fann_batch.train.out" title "fann batch train" with lines 4, \
@@ -169,7 +161,6 @@ set logscale y
#set output "thyroid.ps"
set title "thyroid"
plot "thyroid.fann_rprop.test.out" title "fann rprop test" with lines -1, \
- "thyroid.fann_rprop.fixed_test.out" title "fann rprop (fixed) test" with lines 1, \
"thyroid.fann_rprop_stepwise.test.out" title "fann rprop (stepwise) test" with lines 2, \
"thyroid.fann_quickprop.test.out" title "fann quickprop test" with lines 3, \
"thyroid.fann_batch.test.out" title "fann batch test" with lines 4, \
@@ -177,7 +168,6 @@ plot "thyroid.fann_rprop.test.out" title "fann rprop test" with lines -1, \
"thyroid.lwnn.test.out" title "lwnn incremental test" with lines 8, \
"thyroid.jneural.test.out" title "jneural incremental test" with lines 9, \
"thyroid.fann_rprop.train.out" title "fann rprop train" with lines -1, \
- "thyroid.fann_rprop.fixed_train.out" title "fann rprop (fixed) train" with lines 1, \
"thyroid.fann_rprop_stepwise.train.out" title "fann rprop (stepwise) train" with lines 2, \
"thyroid.fann_quickprop.train.out" title "fann quickprop train" with lines 3, \
"thyroid.fann_batch.train.out" title "fann batch train" with lines 4, \
@@ -202,6 +192,7 @@ plot "two-spiral.fann_rprop.test.out" title "fann rprop test" with lines -1, \
"two-spiral.fann_incremental.train.out" title "fann incremental train" with lines 5, \
"two-spiral.lwnn.train.out" title "lwnn incremental train" with lines 8, \
"two-spiral.jneural.train.out" title "jneural incremental train" with lines 9
+set nologscale
set output
set terminal x11
diff --git a/benchmarks/quality.cc b/benchmarks/quality.cc
index 9c20c9d..4b5fc72 100644
--- a/benchmarks/quality.cc
+++ b/benchmarks/quality.cc
@@ -122,10 +122,10 @@ void quality_benchmark_jneural(
fprintf(train_out, "%f %.20e %d\n", total_elapsed, train_error, epochs);
fprintf(test_out, "%f %.20e %d\n", total_elapsed, test_error, epochs);
- fprintf(stderr, ".");
+ fprintf(stderr, "secs: %8.2f, train: %8.6f, test: %8.6f, epochs: %5d\r", total_elapsed, train_error, test_error, epochs);
}
- fprintf(stderr, " epochs: %d, epochs/sec: %f", epochs, epochs/total_elapsed);
+ fprintf(stdout, "\nepochs: %d, epochs/sec: %f\n", epochs, epochs/total_elapsed);
delete ann;
}
@@ -203,7 +203,7 @@ void quality_benchmark_fann(bool stepwise, unsigned int training_algorithm,
fprintf(train_out, "%f %.20e %d\n", total_elapsed, train_error, epochs);
fprintf(test_out, "%f %.20e %d\n", total_elapsed, test_error, epochs);
- fprintf(stderr, ".");
+ fprintf(stderr, "secs: %8.2f, train: %8.6f, test: %8.6f, epochs: %5d\r", total_elapsed, train_error, test_error, epochs);
/* Save the data as fixed point, to allow for drawing of
a fixed point graph */
@@ -220,7 +220,7 @@ void quality_benchmark_fann(bool stepwise, unsigned int training_algorithm,
}
}
- fprintf(stderr, " epochs: %d, epochs/sec: %f", epochs, epochs/total_elapsed);
+ fprintf(stdout, "\nepochs: %d, epochs/sec: %f\n", epochs, epochs/total_elapsed);
fann_destroy(ann);
}
@@ -296,10 +296,10 @@ void quality_benchmark_lwnn(
fprintf(train_out, "%f %.20e %d\n", total_elapsed, train_error, epochs);
fprintf(test_out, "%f %.20e %d\n", total_elapsed, test_error, epochs);
- fprintf(stderr, ".");
+ fprintf(stderr, "secs: %8.2f, train: %8.6f, test: %8.6f, epochs: %5d\r", total_elapsed, train_error, test_error, epochs);
}
- fprintf(stderr, " epochs: %d, epochs/sec: %f", epochs, epochs/total_elapsed);
+ fprintf(stdout, "\nepochs: %d, epochs/sec: %f\n", epochs, epochs/total_elapsed);
net_free(ann);
}
@@ -341,7 +341,7 @@ int main(int argc, char* argv[])
test_out = fopen(argv[5], "w");
}
- fprintf(stderr, "Quality test of %s %s ", argv[1], argv[2]);
+ fprintf(stdout, "Quality test of %s %s\n", argv[1], argv[2]);
if(strcmp(argv[1], "fann_incremental") == 0){
quality_benchmark_fann(false, FANN_TRAIN_INCREMENTAL, NULL, train_data, test_data,
@@ -412,8 +412,6 @@ int main(int argc, char* argv[])
printf("unrecognized option %s\n", argv[1]);
}
- fprintf(stderr, "\n");
-
fann_destroy_train(train_data);
fann_destroy_train(test_data);
diff --git a/examples/mushroom.c b/examples/mushroom.c
index 4ba4396..65087dc 100644
--- a/examples/mushroom.c
+++ b/examples/mushroom.c
@@ -55,7 +55,7 @@ int main()
fann_set_activation_function_hidden(ann, FANN_SIGMOID_SYMMETRIC_STEPWISE);
fann_set_activation_function_output(ann, FANN_SIGMOID_STEPWISE);
- fann_set_training_algorithm(ann, FANN_INCREMENTAL_TRAIN);
+ fann_set_training_algorithm(ann, FANN_TRAIN_INCREMENTAL);
fann_train_on_data(ann, train_data, max_iterations, iterations_between_reports, desired_error);
diff --git a/examples/robot.c b/examples/robot.c
index d346cbd..9c33cf3 100644
--- a/examples/robot.c
+++ b/examples/robot.c
@@ -50,9 +50,9 @@ int main()
printf("Training network.\n");
- fann_set_training_algorithm(ann, FANN_INCREMENTAL_TRAIN);
+ fann_set_training_algorithm(ann, FANN_TRAIN_INCREMENTAL);
- fann_train_on_data(ann, train_data, 100000, 10, desired_error);
+ fann_train_on_data(ann, train_data, 1000, 10, desired_error);
/*fann_train_on_data_callback(ann, data, max_iterations, iterations_between_reports, desired_error, print_callback);*/
printf("Testing network.\n");
diff --git a/examples/xor_train.c b/examples/xor_train.c
index 3d9943d..5279611 100644
--- a/examples/xor_train.c
+++ b/examples/xor_train.c
@@ -65,7 +65,7 @@ int main()
fann_init_weights(ann, data);
- /* fann_set_training_algorithm(ann, FANN_QUICKPROP_TRAIN); */
+ /*fann_set_training_algorithm(ann, FANN_TRAIN_QUICKPROP);*/
fann_train_on_data(ann, data, max_iterations, iterations_between_reports, desired_error);
/*fann_train_on_data_callback(ann, data, max_iterations, iterations_between_reports, desired_error, print_callback);*/
diff --git a/src/fann_train.c b/src/fann_train.c
index 67a5fbd..267a5d1 100644
--- a/src/fann_train.c
+++ b/src/fann_train.c
@@ -551,7 +551,7 @@ void fann_update_weights_irpropm(struct fann *ann, unsigned int num_data)
unsigned int i = ann->total_connections;
while(i--){
- prev_step = prev_steps[i];
+ prev_step = fann_max(prev_steps[i], 0.001); /* prev_step may not be zero because then the training will stop */
slope = train_slopes[i];
prev_slope = prev_train_slopes[i];
next_step = 0.0;
@@ -565,11 +565,15 @@ void fann_update_weights_irpropm(struct fann *ann, unsigned int num_data)
slope = 0;
}
- if(slope > 0){
+ if(slope < 0){
weights[i] -= next_step;
}else{
weights[i] += next_step;
}
+
+ /*if(i == 2){
+ printf("weight=%f, slope=%f, next_step=%f, prev_step=%f\n", weights[i], slope, next_step, prev_step);
+ }*/
/* update global data arrays */
prev_steps[i] = next_step;
diff --git a/src/fann_train_data.c b/src/fann_train_data.c
index 09c2bce..11ca2b0 100644
--- a/src/fann_train_data.c
+++ b/src/fann_train_data.c
@@ -111,7 +111,7 @@ float fann_train_epoch_irpropm(struct fann *ann, struct fann_train_data *data)
fann_backpropagate_MSE(ann);
fann_update_slopes_batch(ann);
}
- fann_update_weights_quickprop(ann, data->num_data);
+ fann_update_weights_irpropm(ann, data->num_data);
return fann_get_MSE(ann);
}
diff --git a/src/include/fann_internal.h b/src/include/fann_internal.h
index 55cb602..c9e7d42 100644
--- a/src/include/fann_internal.h
+++ b/src/include/fann_internal.h
@@ -62,6 +62,7 @@ void fann_backpropagate_MSE(struct fann *ann);
void fann_update_weights(struct fann *ann);
void fann_update_slopes_batch(struct fann *ann);
void fann_update_weights_quickprop(struct fann *ann, unsigned int num_data);
+void fann_update_weights_irpropm(struct fann *ann, unsigned int num_data);
void fann_update_weights_batch(struct fann *ann, unsigned int num_data);
--
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