[libfann] 104/242: use tanh
Christian Kastner
chrisk-guest at moszumanska.debian.org
Sat Oct 4 21:10:25 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 03ef16ecda171375b9479c79583568f9936086c2
Author: Steffen Nissen <lukesky at diku.dk>
Date: Thu Mar 18 14:45:46 2004 +0000
use tanh
---
examples/xor.data | 10 +++++-----
examples/xor_test.c | 2 +-
examples/xor_train.c | 16 ++++++++++------
3 files changed, 16 insertions(+), 12 deletions(-)
diff --git a/examples/xor.data b/examples/xor.data
index 1d8fe3e..e831fc6 100644
--- a/examples/xor.data
+++ b/examples/xor.data
@@ -1,9 +1,9 @@
4 2 1
-0 0
-0
-0 1
+-1 -1
+-1
+-1 1
1
-1 0
+1 -1
1
1 1
-0
+-1
diff --git a/examples/xor_test.c b/examples/xor_test.c
index c72e665..b4c9540 100644
--- a/examples/xor_test.c
+++ b/examples/xor_test.c
@@ -58,7 +58,7 @@ int main()
printf("XOR test (%d, %d) -> %d, should be %d, difference=%f\n",
data->input[i][0], data->input[i][1], *calc_out, data->output[i][0], (float)fann_abs(*calc_out - data->output[i][0])/fann_get_multiplier(ann));
- if((float)fann_abs(*calc_out - data->output[i][0])/fann_get_multiplier(ann) > 0.1){
+ if((float)fann_abs(*calc_out - data->output[i][0])/fann_get_multiplier(ann) > 0.2){
printf("Test failed\n");
ret = -1;
}
diff --git a/examples/xor_train.c b/examples/xor_train.c
index b701c80..93ec555 100644
--- a/examples/xor_train.c
+++ b/examples/xor_train.c
@@ -31,14 +31,14 @@ int main()
{
fann_type *calc_out;
const float connection_rate = 1;
- const float learning_rate = 0.7;
+ const float learning_rate = (const float)0.4;
const unsigned int num_input = 2;
const unsigned int num_output = 1;
const unsigned int num_layers = 3;
- const unsigned int num_neurons_hidden = 4;
- const float desired_error = 0.001;
- const unsigned int max_iterations = 20000;
- const unsigned int iterations_between_reports = 100;
+ const unsigned int num_neurons_hidden = 6;
+ const float desired_error = (const float)0.001;
+ const unsigned int max_iterations = 300000;
+ const unsigned int iterations_between_reports = 1000;
struct fann *ann;
struct fann_train_data *data;
@@ -56,8 +56,12 @@ int main()
data = fann_read_train_from_file("xor.data");
+ fann_set_activation_function_hidden(ann, FANN_SIGMOID_SYMMETRIC_STEPWISE);
+ fann_set_activation_function_output(ann, FANN_SIGMOID_SYMMETRIC_STEPWISE);
+ fann_init_weights(ann, data);
+
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);*/
--
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