[libfann] 184/242: fixed fixpoint operations etc.

Christian Kastner chrisk-guest at moszumanska.debian.org
Sat Oct 4 21:10:41 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 8f99acb173f6edda174fa20881ca5d7e0412786f
Author: Steffen Nissen <lukesky at diku.dk>
Date:   Thu Jul 14 19:44:17 2005 +0000

    fixed fixpoint operations etc.
---
 examples/Makefile       |   8 +--
 examples/xor_train.c    |   4 +-
 src/fann.c              |  58 ++++++++++++++------
 src/fann_io.c           |   2 +
 src/fann_options.c      | 140 +++++++++++++++++-------------------------------
 src/fann_train.c        |  82 ----------------------------
 src/include/fann_data.h |   6 ++-
 7 files changed, 104 insertions(+), 196 deletions(-)

diff --git a/examples/Makefile b/examples/Makefile
index 5c07970..05c4f80 100644
--- a/examples/Makefile
+++ b/examples/Makefile
@@ -41,9 +41,9 @@ rundebugtest: $(DEBUG_TARGETS)
 	@echo Testing network with floats
 	./xor_test_debug
 
-#	@echo
-#	@echo Testing network with fixed points
-#	./xor_test_fixed_debug
+	@echo
+	@echo Testing network with fixed points
+	./xor_test_fixed_debug
 
 runcompliancetest: $(DEBUG_TARGETS)
 	./xor_train_debug
@@ -70,7 +70,7 @@ debug: $(DEBUG_TARGETS)
 	$(GCC) -ggdb -lm -DDEBUG -Wall -ansi -I../src/ -I../src/include/ ../src/floatfann.c $< -o $@
 
 %_fixed_debug: %.c Makefile ../src/*c ../src/include/*h
-	$(GCC) -O3 -ggdb -lm -DDEBUG -Wall -ansi -DFIXEDFANN -I../src/ -I../src/include/ ../src/fixedfann.c $< -o $@
+	$(GCC) -ggdb -lm -DDEBUG -Wall -ansi -DFIXEDFANN -I../src/ -I../src/include/ ../src/fixedfann.c $< -o $@
 
 rundebug: $(DEBUG_TARGETS)
 	@echo
diff --git a/examples/xor_train.c b/examples/xor_train.c
index 41e730c..63f6318 100644
--- a/examples/xor_train.c
+++ b/examples/xor_train.c
@@ -35,7 +35,7 @@ int main()
 	const unsigned int num_input = 2;
 	const unsigned int num_output = 1;
 	const unsigned int num_layers = 3;
-	const unsigned int num_neurons_hidden = 5;
+	const unsigned int num_neurons_hidden = 3;
 	const float desired_error = (const float)0.00001;
 	const unsigned int max_iterations = 100000;
 	const unsigned int iterations_between_reports = 1000;
@@ -61,7 +61,7 @@ int main()
 	fann_set_activation_steepness_output(ann, 1);
 	fann_set_rprop_delta_max(ann, 50);
 	
-	fann_set_activation_function_hidden(ann, FANN_ELLIOT_SYMMETRIC);
+	fann_set_activation_function_hidden(ann, FANN_SIGMOID_SYMMETRIC);
 	fann_set_activation_function_output(ann, FANN_GAUSSIAN_SYMMETRIC);
 	
 	fann_init_weights(ann, data);
diff --git a/src/fann.c b/src/fann.c
index 209869e..8d813c0 100644
--- a/src/fann.c
+++ b/src/fann.c
@@ -95,9 +95,9 @@ FANN_EXTERNAL struct fann * FANN_API fann_create_array(float connection_rate, fl
 #ifdef FIXEDFANN
 	decimal_point = ann->decimal_point;
 	multiplier = ann->multiplier;
-#endif
 	fann_update_stepwise_hidden(ann);
 	fann_update_stepwise_output(ann);
+#endif
 
 	/* determine how many neurons there should be in each layer */
 	i = 0;
@@ -354,9 +354,9 @@ FANN_EXTERNAL struct fann * FANN_API fann_create_shortcut_array(float learning_r
 #ifdef FIXEDFANN
 	decimal_point = ann->decimal_point;
 	multiplier = ann->multiplier;
-#endif
 	fann_update_stepwise_hidden(ann);
 	fann_update_stepwise_output(ann);
+#endif
 
 	/* determine how many neurons there should be in each layer */
 	i = 0;
@@ -459,20 +459,19 @@ FANN_EXTERNAL fann_type * FANN_API fann_run(struct fann *ann, fann_type *input)
 	unsigned int activation_function_output = ann->activation_function_output;
 	unsigned int activation_function_hidden = ann->activation_function_hidden;
 	struct fann_neuron *first_neuron = ann->first_layer->first_neuron;
+
 #ifdef FIXEDFANN
 	int multiplier = ann->multiplier;
 	unsigned int decimal_point = ann->decimal_point;
-#endif
 	
 	/* values used for the stepwise linear sigmoid function */
 	fann_type rh1 = 0, rh2 = 0, rh3 = 0, rh4 = 0, rh5 = 0, rh6 = 0;
 	fann_type h1 = 0, h2 = 0, h3 = 0, h4 = 0, h5 = 0, h6 = 0;
 
-	switch(ann->activation_function_hidden){
-#ifdef FIXEDFANN
+	switch(ann->activation_function_hidden)
+	{
 		case FANN_SIGMOID:
 		case FANN_SIGMOID_SYMMETRIC:
-#endif
 		case FANN_SIGMOID_STEPWISE:
 		case FANN_SIGMOID_SYMMETRIC_STEPWISE:			
 			/* the hidden results */
@@ -494,7 +493,8 @@ FANN_EXTERNAL fann_type * FANN_API fann_run(struct fann *ann, fann_type *input)
 		default:
 			break;
 	}
-			
+#endif
+	
 	/* first set the input */
 	num_input = ann->num_input;
 	for(i = 0; i != num_input; i++){
@@ -513,20 +513,22 @@ FANN_EXTERNAL fann_type * FANN_API fann_run(struct fann *ann, fann_type *input)
 #endif
 	
 	last_layer = ann->last_layer;
-	for(layer_it = ann->first_layer+1; layer_it != last_layer; layer_it++){
-		
+	for(layer_it = ann->first_layer+1; layer_it != last_layer; layer_it++)
+	{
 		steepness = (layer_it == last_layer-1) ? 
 			activation_steepness_output : activation_steepness_hidden;
 		
 		activation_function = (layer_it == last_layer-1) ?
 			activation_function_output : activation_function_hidden;
 
-		if(layer_it == layer_it-1){
-			switch(ann->activation_function_output){
 #ifdef FIXEDFANN
+		if(layer_it == layer_it-1 &&
+		   ann->activation_function_output != ann->activation_function_hidden)
+		{
+			switch(ann->activation_function_output)
+			{
 				case FANN_SIGMOID:
 				case FANN_SIGMOID_SYMMETRIC:
-#endif
 				case FANN_SIGMOID_STEPWISE:
 				case FANN_SIGMOID_SYMMETRIC_STEPWISE:			
 					/* the output results */
@@ -549,12 +551,17 @@ FANN_EXTERNAL fann_type * FANN_API fann_run(struct fann *ann, fann_type *input)
 					break;
 			}
 		}
+#endif
 		
 		last_neuron = layer_it->last_neuron;
 		for(neuron_it = layer_it->first_neuron; neuron_it != last_neuron; neuron_it++){
 			if(neuron_it->first_con == neuron_it->last_con){
 				/* bias neurons */
+#ifdef FIXEDFANN
+				neuron_it->value = multiplier;
+#else
 				neuron_it->value = 1;
+#endif
 				continue;
 			}
 			
@@ -590,15 +597,14 @@ FANN_EXTERNAL fann_type * FANN_API fann_run(struct fann *ann, fann_type *input)
 						fann_mult(weights[i+2], neurons[i+2].value) +
 						fann_mult(weights[i+3], neurons[i+3].value);
 				}
+				/* unrolled loop end */
 
 				/*
 				for(i = 0;i != num_connections; i++){
 					printf("%f += %f*%f, ", neuron_sum, weights[i], neurons[i].value);
 					neuron_sum += fann_mult(weights[i], neurons[i].value);
 				}
-				*/
-				
-				/* unrolled loop end */
+				*/				
 			} else {
 				neuron_pointers = ann->connections + neuron_it->first_con;
 				
@@ -626,7 +632,29 @@ FANN_EXTERNAL fann_type * FANN_API fann_run(struct fann *ann, fann_type *input)
 			neuron_sum = fann_mult(steepness, neuron_sum);
 			neuron_it->sum = neuron_sum;
 
+#ifdef FIXEDFANN
+			switch(activation_function)
+			{
+				case FANN_SIGMOID:
+				case FANN_SIGMOID_STEPWISE:
+					neuron_it->value = (fann_type)fann_stepwise(h1, h2, h3, h4, h5, h6, rh1, rh2, rh3, rh4, rh5, rh6, 0, multiplier, neuron_sum);
+					break;
+				case FANN_SIGMOID_SYMMETRIC:
+				case FANN_SIGMOID_SYMMETRIC_STEPWISE:
+					neuron_it->value = (fann_type)fann_stepwise(h1, h2, h3, h4, h5, h6, rh1, rh2, rh3, rh4, rh5, rh6, -multiplier, multiplier, neuron_sum);
+					break;
+				case FANN_THRESHOLD:
+					neuron_it->value = (fann_type)((neuron_sum < 0) ? 0 : 1);
+					break;
+				case FANN_THRESHOLD_SYMMETRIC:
+					neuron_it->value = (fann_type)((neuron_sum < 0) ? -1 : 1);
+					break;
+				default:
+					fann_error((struct fann_error *)ann, FANN_E_CANT_USE_ACTIVATION);
+			}
+#else
 			fann_activation_switch(ann, activation_function, neuron_sum, neuron_it->value);
+#endif
 			/*
 			printf(" sum=%f, value=%f\n", neuron_it->sum, neuron_it->value);
 			switch(activation_function){
diff --git a/src/fann_io.c b/src/fann_io.c
index 062a862..eab1049 100644
--- a/src/fann_io.c
+++ b/src/fann_io.c
@@ -347,8 +347,10 @@ struct fann * fann_create_from_fd(FILE *conf, const char *configuration_file)
 	ann->activation_steepness_output = activation_steepness_output;
 	ann->activation_function_hidden = activation_function_hidden;
 	ann->activation_function_output = activation_function_output;
+#ifdef FIXEDFANN
 	fann_update_stepwise_hidden(ann);
 	fann_update_stepwise_output(ann);
+#endif
 	
 #ifdef DEBUG
 	printf("creating network with learning rate %f\n", learning_rate);
diff --git a/src/fann_options.c b/src/fann_options.c
index 85e2ea7..df81093 100644
--- a/src/fann_options.c
+++ b/src/fann_options.c
@@ -89,25 +89,33 @@ FANN_EXTERNAL void FANN_API fann_set_learning_rate(struct fann *ann, float learn
 FANN_EXTERNAL void FANN_API fann_set_activation_function_hidden(struct fann *ann, unsigned int activation_function)
 {
 	ann->activation_function_hidden = activation_function;
+#ifdef FIXEDFANN
 	fann_update_stepwise_hidden(ann);
+#endif
 }
 
 FANN_EXTERNAL void FANN_API fann_set_activation_function_output(struct fann *ann, unsigned int activation_function)
 {
 	ann->activation_function_output = activation_function;
+#ifdef FIXEDFANN
 	fann_update_stepwise_output(ann);
+#endif
 }
 
 FANN_EXTERNAL void FANN_API fann_set_activation_steepness_hidden(struct fann *ann, fann_type steepness)
 {
 	ann->activation_steepness_hidden = steepness;
+#ifdef FIXEDFANN
 	fann_update_stepwise_hidden(ann);
+#endif
 }
 
 FANN_EXTERNAL void FANN_API fann_set_activation_steepness_output(struct fann *ann, fann_type steepness)
 {
 	ann->activation_steepness_output = steepness;
+#ifdef FIXEDFANN
 	fann_update_stepwise_output(ann);
+#endif
 }
 
 FANN_EXTERNAL void FANN_API fann_set_activation_hidden_steepness(struct fann *ann, fann_type steepness)
@@ -287,41 +295,47 @@ FANN_EXTERNAL unsigned int FANN_API fann_get_multiplier(struct fann *ann)
 
 #endif
 
+#ifdef FIXEDFANN
 /* INTERNAL FUNCTION
    Adjust the steepwise functions (if used)
 */
+/*
 void fann_update_stepwise_hidden(struct fann *ann)
 {
-	unsigned int i = 0;
-#ifndef FIXEDFANN
-	/* For use in stepwise linear activation function.
+	unsigned int i = 0;*/
+	/* Calculate the parameters for the stepwise linear
+	   sigmoid function fixed point.
+	   Using a rewritten sigmoid function.
 	   results 0.005, 0.05, 0.25, 0.75, 0.95, 0.995
 	*/
-	switch(ann->activation_function_hidden){
-		case FANN_SIGMOID:
-		case FANN_SIGMOID_STEPWISE:
-			ann->activation_results_hidden[0] = (fann_type)0.005;
-			ann->activation_results_hidden[1] = (fann_type)0.05;
-			ann->activation_results_hidden[2] = (fann_type)0.25;
-			ann->activation_results_hidden[3] = (fann_type)0.75;
-			ann->activation_results_hidden[4] = (fann_type)0.95;
-			ann->activation_results_hidden[5] = (fann_type)0.995;	
-			break;
-		case FANN_SIGMOID_SYMMETRIC:
-		case FANN_SIGMOID_SYMMETRIC_STEPWISE:
-			ann->activation_results_hidden[0] = (fann_type)-0.99;
-			ann->activation_results_hidden[1] = (fann_type)-0.9;
-			ann->activation_results_hidden[2] = (fann_type)-0.5;
-			ann->activation_results_hidden[3] = (fann_type)0.5;
-			ann->activation_results_hidden[4] = (fann_type)0.9;
-			ann->activation_results_hidden[5] = (fann_type)0.99;
-			break;
-		default:
-			/* the actiavation functions which do not have a stepwise function
-			   should not have it calculated */
-			return;
+/*
+	ann->sigmoid_results[0] = fann_max((fann_type)((ann->multiplier/100.0) - ann->multiplier-0.5), 1-ann->multiplier);
+	ann->sigmoid_results[1] = (fann_type)((ann->multiplier/10.0) - ann->multiplier-0.5);
+	ann->sigmoid_results[2] = (fann_type)((ann->multiplier/2.0) - ann->multiplier-0.5);
+	ann->sigmoid_results[3] = ann->multiplier - (fann_type)(ann->multiplier/2.0+0.5);
+	ann->sigmoid_results[4] = ann->multiplier - (fann_type)(ann->multiplier/10.0+0.5);
+	ann->sigmoid_results[5] = fann_min(ann->multiplier - (fann_type)(ann->multiplier/100.0+1.0), ann->multiplier-1);
+
+	ann->sigmoid_symmetric_results[0] = fann_max((fann_type)((ann->multiplier/100.0) - ann->multiplier-0.5), 1-ann->multiplier);
+	ann->sigmoid_symmetric_results[1] = (fann_type)((ann->multiplier/10.0) - ann->multiplier-0.5);
+	ann->sigmoid_symmetric_results[2] = (fann_type)((ann->multiplier/2.0) - ann->multiplier-0.5);
+	ann->sigmoid_symmetric_results[3] = ann->multiplier - (fann_type)(ann->multiplier/2.0+0.5);
+	ann->sigmoid_symmetric_results[4] = ann->multiplier - (fann_type)(ann->multiplier/10.0+0.5);
+	ann->sigmoid_symmetric_results[5] = fann_min(ann->multiplier - (fann_type)(ann->multiplier/100.0+1.0), ann->multiplier-1);
+
+	for(i = 0; i < 6; i++){
+		ann->sigmoid_values[i] = (fann_type)(((log(ann->multiplier/(float)ann->sigmoid_results[i] -1)*(float)ann->multiplier) / -2.0)*(float)ann->multiplier);
+		ann->sigmoid_symmetric_values[i] = (fann_type)(((log((ann->multiplier - (float)ann->sigmoid_symmetric_results[i])/((float)ann->sigmoid_symmetric_results[i] + ann->multiplier))*(float)ann->multiplier) / -2.0)*(float)ann->multiplier);
 	}
-#else
+}
+*/
+
+/* INTERNAL FUNCTION
+   Adjust the steepwise functions (if used)
+*/
+void fann_update_stepwise_hidden(struct fann *ann)
+{
+	unsigned int i = 0;
 	/* Calculate the parameters for the stepwise linear
 	   sigmoid function fixed point.
 	   Using a rewritten sigmoid function.
@@ -339,9 +353,9 @@ void fann_update_stepwise_hidden(struct fann *ann)
 			break;
 		case FANN_SIGMOID_SYMMETRIC:
 		case FANN_SIGMOID_SYMMETRIC_STEPWISE:
-			ann->activation_results_hidden[0] = (fann_type)((ann->multiplier/100.0) - ann->multiplier + 0.5);
-			ann->activation_results_hidden[1] = (fann_type)((ann->multiplier/10.0) - ann->multiplier + 0.5);
-			ann->activation_results_hidden[2] = (fann_type)((ann->multiplier/2.0) - ann->multiplier + 0.5);
+			ann->activation_results_hidden[0] = (fann_type)((ann->multiplier/100.0) - ann->multiplier-0.5);
+			ann->activation_results_hidden[1] = (fann_type)((ann->multiplier/10.0) - ann->multiplier-0.5);
+			ann->activation_results_hidden[2] = (fann_type)((ann->multiplier/2.0) - ann->multiplier-0.5);
 			ann->activation_results_hidden[3] = ann->multiplier - (fann_type)(ann->multiplier/2.0+0.5);
 			ann->activation_results_hidden[4] = ann->multiplier - (fann_type)(ann->multiplier/10.0+0.5);
 			ann->activation_results_hidden[5] = ann->multiplier - (fann_type)(ann->multiplier/100.0+0.5);
@@ -351,22 +365,8 @@ void fann_update_stepwise_hidden(struct fann *ann)
 			   should not have it calculated */
 			return;
 	}			
-#endif
 
 	for(i = 0; i < 6; i++){
-#ifndef FIXEDFANN
-		switch(ann->activation_function_hidden){
-			case FANN_SIGMOID:
-				break;
-			case FANN_SIGMOID_STEPWISE:
-				ann->activation_values_hidden[i] = (fann_type)((log(1.0/ann->activation_results_hidden[i] -1.0) * 1.0/-2.0) * 1.0/ann->activation_steepness_hidden);
-				break;
-			case FANN_SIGMOID_SYMMETRIC:
-			case FANN_SIGMOID_SYMMETRIC_STEPWISE:
-				ann->activation_values_hidden[i] = (fann_type)((log((1.0-ann->activation_results_hidden[i]) / (ann->activation_results_hidden[i]+1.0)) * 1.0/-2.0) * 1.0/ann->activation_steepness_hidden);
-				break;
-		}
-#else
 		switch(ann->activation_function_hidden){
 			case FANN_SIGMOID:
 			case FANN_SIGMOID_STEPWISE:
@@ -377,7 +377,6 @@ void fann_update_stepwise_hidden(struct fann *ann)
 				ann->activation_values_hidden[i] = (fann_type)((((log((ann->multiplier - (float)ann->activation_results_hidden[i])/((float)ann->activation_results_hidden[i] + ann->multiplier))*(float)ann->multiplier) / -2.0)*(float)ann->multiplier) / ann->activation_steepness_hidden);
 				break;
 		}
-#endif
 	}
 }
 
@@ -387,35 +386,6 @@ void fann_update_stepwise_hidden(struct fann *ann)
 void fann_update_stepwise_output(struct fann *ann)
 {
 	unsigned int i = 0;
-#ifndef FIXEDFANN
-	/* For use in stepwise linear activation function.
-	   results 0.005, 0.05, 0.25, 0.75, 0.95, 0.995
-	*/
-	switch(ann->activation_function_output){
-		case FANN_SIGMOID:
-		case FANN_SIGMOID_STEPWISE:
-			ann->activation_results_output[0] = (fann_type)0.005;
-			ann->activation_results_output[1] = (fann_type)0.05;
-			ann->activation_results_output[2] = (fann_type)0.25;
-			ann->activation_results_output[3] = (fann_type)0.75;
-			ann->activation_results_output[4] = (fann_type)0.95;
-			ann->activation_results_output[5] = (fann_type)0.995;	
-			break;
-		case FANN_SIGMOID_SYMMETRIC:
-		case FANN_SIGMOID_SYMMETRIC_STEPWISE:
-			ann->activation_results_output[0] = (fann_type)-0.99;
-			ann->activation_results_output[1] = (fann_type)-0.9;
-			ann->activation_results_output[2] = (fann_type)-0.5;
-			ann->activation_results_output[3] = (fann_type)0.5;
-			ann->activation_results_output[4] = (fann_type)0.9;
-			ann->activation_results_output[5] = (fann_type)0.99;
-			break;
-		default:
-			/* the actiavation functions which do not have a stepwise function
-			   should not have it calculated */
-			return;
-	}
-#else
 	/* Calculate the parameters for the stepwise linear
 	   sigmoid function fixed point.
 	   Using a rewritten sigmoid function.
@@ -433,9 +403,9 @@ void fann_update_stepwise_output(struct fann *ann)
 			break;
 		case FANN_SIGMOID_SYMMETRIC:
 		case FANN_SIGMOID_SYMMETRIC_STEPWISE:
-			ann->activation_results_output[0] = (fann_type)((ann->multiplier/100.0) - ann->multiplier + 0.5);
-			ann->activation_results_output[1] = (fann_type)((ann->multiplier/10.0) - ann->multiplier + 0.5);
-			ann->activation_results_output[2] = (fann_type)((ann->multiplier/2.0) - ann->multiplier + 0.5);
+			ann->activation_results_output[0] = (fann_type)((ann->multiplier/100.0) - ann->multiplier-0.5);
+			ann->activation_results_output[1] = (fann_type)((ann->multiplier/10.0) - ann->multiplier-0.5);
+			ann->activation_results_output[2] = (fann_type)((ann->multiplier/2.0) - ann->multiplier-0.5);
 			ann->activation_results_output[3] = ann->multiplier - (fann_type)(ann->multiplier/2.0+0.5);
 			ann->activation_results_output[4] = ann->multiplier - (fann_type)(ann->multiplier/10.0+0.5);
 			ann->activation_results_output[5] = ann->multiplier - (fann_type)(ann->multiplier/100.0+0.5);
@@ -445,22 +415,8 @@ void fann_update_stepwise_output(struct fann *ann)
 			   should not have it calculated */
 			return;
 	}			
-#endif
 
 	for(i = 0; i < 6; i++){
-#ifndef FIXEDFANN
-		switch(ann->activation_function_output){
-			case FANN_SIGMOID:
-				break;
-			case FANN_SIGMOID_STEPWISE:
-				ann->activation_values_output[i] = (fann_type)((log(1.0/ann->activation_results_output[i] -1.0) * 1.0/-2.0) * 1.0/ann->activation_steepness_output);
-				break;
-			case FANN_SIGMOID_SYMMETRIC:
-			case FANN_SIGMOID_SYMMETRIC_STEPWISE:
-				ann->activation_values_output[i] = (fann_type)((log((1.0-ann->activation_results_output[i]) / (ann->activation_results_output[i]+1.0)) * 1.0/-2.0) * 1.0/ann->activation_steepness_output);
-				break;
-		}
-#else
 		switch(ann->activation_function_output){
 			case FANN_SIGMOID:
 			case FANN_SIGMOID_STEPWISE:
@@ -471,6 +427,6 @@ void fann_update_stepwise_output(struct fann *ann)
 				ann->activation_values_output[i] = (fann_type)((((log((ann->multiplier - (float)ann->activation_results_output[i])/((float)ann->activation_results_output[i] + ann->multiplier))*(float)ann->multiplier) / -2.0)*(float)ann->multiplier) / ann->activation_steepness_output);
 				break;
 		}
-#endif
 	}
 }
+#endif
diff --git a/src/fann_train.c b/src/fann_train.c
index 11ce9ec..e1abaaa 100644
--- a/src/fann_train.c
+++ b/src/fann_train.c
@@ -68,88 +68,6 @@ fann_type fann_activation_derived(unsigned int activation_function,
   Calculates the activation of a value, given an activation function
    and a steepness
 */
-fann_type fann_activation_old(struct fann *ann, unsigned int is_output_layer,
-	fann_type value)
-{
-	/* values used for the stepwise linear sigmoid function */
-	fann_type rh1 = 0, rh2 = 0, rh3 = 0, rh4 = 0, rh5 = 0, rh6 = 0;
-	fann_type h1 = 0, h2 = 0, h3 = 0, h4 = 0, h5 = 0, h6 = 0;
-	fann_type low = 0;
-
-	fann_type steepness = (is_output_layer) ? 
-		ann->activation_steepness_output : ann->activation_steepness_hidden;
-	
-	unsigned int activation_function = (is_output_layer) ?
-		ann->activation_function_output : ann->activation_function_hidden;
-
-	switch(activation_function){
-		case FANN_LINEAR:
-			return (fann_type)fann_linear(steepness, value);
-		case FANN_SIGMOID:
-			return (fann_type)fann_sigmoid(steepness, value);
-		case FANN_SIGMOID_SYMMETRIC:
-			return (fann_type)fann_sigmoid_symmetric(steepness, value);
-		case FANN_SIGMOID_SYMMETRIC_STEPWISE:
-			low = -1;
-			/* fallthrough */
-		case FANN_SIGMOID_STEPWISE:
-			if(is_output_layer){
-				/* the output results */
-				rh1 = ann->activation_results_output[0];
-				rh2 = ann->activation_results_output[1];
-				rh3 = ann->activation_results_output[2];
-				rh4 = ann->activation_results_output[3];
-				rh5 = ann->activation_results_output[4];
-				rh6 = ann->activation_results_output[5];
-				
-				/* the output parameters */
-				h1 = ann->activation_values_output[0];
-				h2 = ann->activation_values_output[1];
-				h3 = ann->activation_values_output[2];
-				h4 = ann->activation_values_output[3];
-				h5 = ann->activation_values_output[4];
-				h6 = ann->activation_values_output[5];
-			}else{
-				/* the hidden results */
-				rh1 = ann->activation_results_hidden[0];
-				rh2 = ann->activation_results_hidden[1];
-				rh3 = ann->activation_results_hidden[2];
-				rh4 = ann->activation_results_hidden[3];
-				rh5 = ann->activation_results_hidden[4];
-				rh6 = ann->activation_results_hidden[5];
-			
-				/* the hidden parameters */
-				h1 = ann->activation_values_hidden[0];
-				h2 = ann->activation_values_hidden[1];
-				h3 = ann->activation_values_hidden[2];
-				h4 = ann->activation_values_hidden[3];
-				h5 = ann->activation_values_hidden[4];
-				h6 = ann->activation_values_hidden[5];
-			}
-
-			return (fann_type)fann_stepwise(h1, h2, h3, h4, h5, h6, rh1, rh2, rh3, rh4, rh5, rh6, low, 1, value);
-		case FANN_THRESHOLD:
-			return (fann_type)((value < 0) ? 0 : 1);
-		case FANN_THRESHOLD_SYMMETRIC:
-			return (fann_type)((value < 0) ? -1 : 1);
-		case FANN_GAUSSIAN:
-			return (fann_type)fann_gaussian(steepness, value);
-		case FANN_GAUSSIAN_SYMMETRIC:
-			return (fann_type)fann_gaussian_symmetric(steepness, value);
-		case FANN_ELLIOT:
-			return (fann_type)fann_elliot(steepness, value);
-		case FANN_ELLIOT_SYMMETRIC:
-			return (fann_type)fann_elliot_symmetric(steepness, value);			
-		default:
-			fann_error((struct fann_error *)ann, FANN_E_CANT_USE_ACTIVATION);
-			return 0;
-	}
-}
-
-/* INTERNAL FUNCTION
-  Calculates the activation of a value, given an activation function
-   and a steepness
-*/
 fann_type fann_activation(struct fann *ann, unsigned int activation_function, fann_type steepness,
 	fann_type value)
 {
diff --git a/src/include/fann_data.h b/src/include/fann_data.h
index 8739dab..4076c96 100644
--- a/src/include/fann_data.h
+++ b/src/include/fann_data.h
@@ -37,6 +37,10 @@ struct fann_neuron
 	fann_type sum;
 	/* The value of the activation function applied to the sum */
 	fann_type value;
+	/* The steepness of the activation function */
+	/*fann_type steepness;*/
+	/* Used to choose which activation function to use */
+	/*unsigned int activation_function;*/
 #ifdef __GNUC__
 }__attribute__((packed));
 #else
@@ -148,7 +152,6 @@ struct fann
 	   Only used in special cases, since the decimal_point is much faster.
 	*/
 	unsigned int multiplier;
-#endif
 
 	/* When in choosen (or in fixed point), the sigmoid function is
 	   calculated as a stepwise linear function. In the
@@ -159,6 +162,7 @@ struct fann
 	fann_type activation_values_hidden[6];
 	fann_type activation_results_output[6];
 	fann_type activation_values_output[6];
+#endif
 
 	/* Total number of connections.
 	 * very usefull, because the actual connections

-- 
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