[libfann] 227/242: MS Windows changes
Christian Kastner
chrisk-guest at moszumanska.debian.org
Sat Oct 4 21:10:48 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 f19794b3ed03b7fe8a483f6c509bec70f282d81a
Author: Steffen Nissen <lukesky at diku.dk>
Date: Sun Dec 18 09:35:57 2005 +0000
MS Windows changes
---
examples/xor_train.c | 2 +-
src/fann.c | 12 ++++++------
src/fann_cascade.c | 14 +++++++-------
src/include/fann.h | 5 ++---
src/include/fann_activation.h | 2 +-
src/include/fann_internal.h | 9 ++++-----
6 files changed, 21 insertions(+), 23 deletions(-)
diff --git a/examples/xor_train.c b/examples/xor_train.c
index d2418d0..e7d706c 100644
--- a/examples/xor_train.c
+++ b/examples/xor_train.c
@@ -60,7 +60,7 @@ int main()
fann_set_activation_function_output(ann, FANN_SIGMOID_SYMMETRIC);
fann_set_train_stop_function(ann, FANN_STOPFUNC_BIT);
- fann_set_bit_fail_limit(ann, 0.01);
+ fann_set_bit_fail_limit(ann, 0.01f);
fann_init_weights(ann, data);
diff --git a/src/fann.c b/src/fann.c
index 6f1a349..40bf25b 100644
--- a/src/fann.c
+++ b/src/fann.c
@@ -1100,7 +1100,7 @@ struct fann *fann_allocate_structure(unsigned int num_layers)
ann->errno_f = FANN_E_NO_ERROR;
ann->error_log = fann_default_error_log;
ann->errstr = NULL;
- ann->learning_rate = 0.7;
+ ann->learning_rate = 0.7f;
ann->learning_momentum = 0.0;
ann->total_neurons = 0;
ann->total_connections = 0;
@@ -1115,20 +1115,20 @@ 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.35;
+ ann->bit_fail_limit = 0.35f;
ann->shortcut_connections = 0;
ann->train_error_function = FANN_ERRORFUNC_TANH;
ann->train_stop_function = FANN_STOPFUNC_MSE;
ann->callback = NULL;
/* variables used for cascade correlation (reasonable defaults) */
- ann->cascade_output_change_fraction = 0.01;
- ann->cascade_candidate_change_fraction = 0.01;
+ ann->cascade_output_change_fraction = 0.01f;
+ ann->cascade_candidate_change_fraction = 0.01f;
ann->cascade_output_stagnation_epochs = 12;
ann->cascade_candidate_stagnation_epochs = 12;
ann->cascade_num_candidate_groups = 2;
- ann->cascade_weight_multiplier = 0.4;
- ann->cascade_candidate_limit = 1000.0;
+ ann->cascade_weight_multiplier = 0.4f;
+ ann->cascade_candidate_limit = 1000.0f;
ann->cascade_max_out_epochs = 150;
ann->cascade_max_cand_epochs = 150;
ann->cascade_candidate_scores = NULL;
diff --git a/src/fann_cascade.c b/src/fann_cascade.c
index 34a6028..0669371 100644
--- a/src/fann_cascade.c
+++ b/src/fann_cascade.c
@@ -144,7 +144,7 @@ int fann_train_outputs(struct fann *ann, struct fann_train_data *data, float des
{
float error, initial_error, error_improvement;
float target_improvement = 0.0;
- float backslide_improvement = -1.0e20;
+ float backslide_improvement = -1.0e20f;
unsigned int i;
unsigned int max_epochs = ann->cascade_max_out_epochs;
unsigned int stagnation = max_epochs;
@@ -181,8 +181,8 @@ int fann_train_outputs(struct fann *ann, struct fann_train_data *data, float des
{
/*printf("error_improvement=%f, target_improvement=%f, backslide_improvement=%f, stagnation=%d\n", error_improvement, target_improvement, backslide_improvement, stagnation); */
- target_improvement = error_improvement * (1.0 + ann->cascade_output_change_fraction);
- backslide_improvement = error_improvement * (1.0 - ann->cascade_output_change_fraction);
+ target_improvement = error_improvement * (1.0f + ann->cascade_output_change_fraction);
+ backslide_improvement = error_improvement * (1.0f - ann->cascade_output_change_fraction);
stagnation = i + ann->cascade_output_stagnation_epochs;
}
@@ -453,7 +453,7 @@ 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.0e20;
+ float backslide_cand_score = -1.0e20f;
unsigned int i;
unsigned int max_epochs = ann->cascade_max_cand_epochs;
unsigned int stagnation = max_epochs;
@@ -490,8 +490,8 @@ int fann_train_candidates(struct fann *ann, struct fann_train_data *data)
/* printf("best_cand_score=%f, target_cand_score=%f, backslide_cand_score=%f, stagnation=%d\n", best_cand_score, target_cand_score, backslide_cand_score, stagnation); */
#endif
- target_cand_score = best_cand_score * (1.0 + ann->cascade_candidate_change_fraction);
- backslide_cand_score = best_cand_score * (1.0 - ann->cascade_candidate_change_fraction);
+ target_cand_score = best_cand_score * (1.0f + ann->cascade_candidate_change_fraction);
+ backslide_cand_score = best_cand_score * (1.0f - ann->cascade_candidate_change_fraction);
stagnation = i + ann->cascade_candidate_stagnation_epochs;
}
@@ -593,7 +593,7 @@ void fann_update_candidate_slopes(struct fann *ann)
#ifdef CASCADE_DEBUG_FULL
/* printf("diff = %f = (%f * %f) - %f;\n", diff, activation, cand_out_weights[j], output_train_errors[j]); */
#endif
- cand_out_slopes[j] -= 2.0 * diff * activation;
+ cand_out_slopes[j] -= 2.0f * diff * activation;
#ifdef CASCADE_DEBUG_FULL
/* printf("cand_out_slopes[%d] <= %f += %f * %f;\n", j, cand_out_slopes[j], diff, activation); */
#endif
diff --git a/src/include/fann.h b/src/include/fann.h
index 77f632f..1497705 100644
--- a/src/include/fann.h
+++ b/src/include/fann.h
@@ -50,9 +50,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#ifndef _WIN32
#include <sys/time.h>
#else /* _WIN32 */
-#if !defined(_MSC_EXTENSIONS) &&
- !defined(_INC_WINDOWS) extern unsigned long __stdcall GetTickCount(void);
-
+#if !defined(_MSC_EXTENSIONS) && !defined(_INC_WINDOWS)
+extern unsigned long __stdcall GetTickCount(void);
#else /* _MSC_EXTENSIONS */
#define WIN32_LEAN_AND_MEAN
diff --git a/src/include/fann_activation.h b/src/include/fann_activation.h
index e8a2c4c..1528a4e 100644
--- a/src/include/fann_activation.h
+++ b/src/include/fann_activation.h
@@ -29,7 +29,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
/* defines used for the stepwise linear functions */
-#define fann_linear_func(v1, r1, v2, r2, sum) ((((r2-r1) * (sum-v1))/(v2-v1)) + r1)
+#define fann_linear_func(v1, r1, v2, r2, sum) (((((r2)-(r1)) * ((sum)-(v1)))/((v2)-(v1))) + (r1))
#define fann_stepwise(v1, v2, v3, v4, v5, v6, r1, r2, r3, r4, r5, r6, min, max, sum) (sum < v5 ? (sum < v3 ? (sum < v2 ? (sum < v1 ? min : fann_linear_func(v1, r1, v2, r2, sum)) : fann_linear_func(v2, r2, v3, r3, sum)) : (sum < v4 ? fann_linear_func(v3, r3, v4, r4, sum) : fann_linear_func(v4, r4, v5, r5, sum))) : (sum < v6 ? fann_linear_func(v5, r5, v6, r6, sum) : max))
/* FANN_LINEAR */
diff --git a/src/include/fann_internal.h b/src/include/fann_internal.h
index 85351ca..6ca75a8 100644
--- a/src/include/fann_internal.h
+++ b/src/include/fann_internal.h
@@ -93,9 +93,8 @@ void fann_update_weights_irpropm(struct fann *ann, unsigned int first_weight,
void fann_clear_train_arrays(struct fann *ann);
-fann_type fann_activation_old(struct fann *ann, unsigned int is_output_layer, fann_type value);
-fann_type fann_activation_new(struct fann *ann, unsigned int activation_function,
- fann_type steepness, fann_type value);
+fann_type fann_activation(struct fann * ann, unsigned int activation_function, fann_type steepness,
+ fann_type value);
fann_type fann_activation_derived(unsigned int activation_function,
fann_type steepness, fann_type value, fann_type sum);
@@ -124,7 +123,7 @@ void fann_set_shortcut_connections(struct fann *ann);
#define fann_clip(x, lo, hi) (((x) < (lo)) ? (lo) : (((x) > (hi)) ? (hi) : (x)))
/*#define fann_clip(x, lo, hi) (x)*/
-#define fann_rand(min_value, max_value) (((double)(min_value))+(((double)(max_value)-((double)(min_value)))*rand()/(RAND_MAX+1.0)))
+#define fann_rand(min_value, max_value) (((float)(min_value))+(((float)(max_value)-((float)(min_value)))*rand()/(RAND_MAX+1.0f)))
#define fann_abs(value) (((value) > 0) ? (value) : -(value))
@@ -139,7 +138,7 @@ void fann_set_shortcut_connections(struct fann *ann);
#define fann_mult(x,y) (x*y)
#define fann_div(x,y) (x/y)
-#define fann_random_weight() (fann_rand(-0.1,0.1))
+#define fann_random_weight() (fann_rand(-0.1f,0.1f))
#endif
--
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