[libfann] 03/242: minor fixes

Christian Kastner chrisk-guest at moszumanska.debian.org
Sat Oct 4 21:10:12 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 7636d6355417028e3f7ca0bb83f154263f1b3d4a
Author: Steffen Nissen <lukesky at diku.dk>
Date:   Mon Nov 3 22:55:07 2003 +0000

    minor fixes
---
 src/Makefile                 |   4 +-
 src/include/doublefann.h~    |  11 ---
 src/include/fann.h~          | 230 -------------------------------------------
 src/include/fann_data.h~     | 135 -------------------------
 src/include/fann_internal.h~ |  57 -----------
 src/include/fixedfann.h~     |  11 ---
 src/include/floatfann.h~     |  11 ---
 src/test/xor_train.c         |   2 +-
 src/xor_float.net            |   7 --
 9 files changed, 3 insertions(+), 465 deletions(-)

diff --git a/src/Makefile b/src/Makefile
index 55ad3f3..b91a0c4 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -3,7 +3,7 @@ CFLAGS = -pipe -fsigned-char -ansi -pedantic -Wall -O3 -finline-functions -funro
 ARM-CFLAGS = -pipe -fsigned-char -ansi -pedantic -Wall -O3 -finline-functions -funroll-loops -Werror -Iinclude/ -Xlinker --strip-all -Xlinker -dy
 
 LFLAGS = -lm
-H_FILES = $(wildcard *.h)
+H_FILES = $(wildcard include/*.h)
 C_FILES = $(wildcard *.c)
 
 GCC = gcc
@@ -173,4 +173,4 @@ runtest: test
 	./test/xor_test_fixed
 
 clean:
-	rm -rf $(TEST_RUN_FILES) $(ARM_FILES) $(O_FILES) $(LIBRARIES) *~ test/*~
+	rm -rf $(TEST_RUN_FILES) $(ARM_FILES) $(O_FILES) $(LIBRARIES) *~ test/*~ include/*~ test/*.net test/*fixed*data test/*float*data
diff --git a/src/include/doublefann.h~ b/src/include/doublefann.h~
deleted file mode 100644
index 54cc439..0000000
--- a/src/include/doublefann.h~
+++ /dev/null
@@ -1,11 +0,0 @@
-#ifndef __doublefann_h__
-#define __doublefann_h__
-
-typedef double fann_type;
-#define DOUBLEFANN
-#define FANNPRINTF "%.20e"
-#define FANNSCANF "%le"
-
-#include "fann.h"
-
-#endif
diff --git a/src/include/fann.h~ b/src/include/fann.h~
deleted file mode 100644
index 1670e40..0000000
--- a/src/include/fann.h~
+++ /dev/null
@@ -1,230 +0,0 @@
-/* This file defines the user interface to the fann library.
-   It is included from fixedfann.h, floatfann.h and doublefann.h and should
-   NOT be included directly.
-*/
-
-#include "fann_data.h"
-#include "fann_internal.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-/* ----- Initialisation and configuration ----- */
-
-/* Constructs a backpropagation neural network, from an connection rate,
-   a learning rate, the number of layers and the number of neurons in each
-   of the layers.
-
-   The connection rate controls how many connections there will be in the
-   network. If the connection rate is set to 1, the network will be fully
-   connected, but if it is set to 0.5 only half of the connections will be set.
-
-   There will be a bias neuron in each layer (except the output layer),
-   and this bias neuron will be connected to all neurons in the next layer.
-   When running the network, the bias nodes always emits 1
- */
-struct fann * fann_create(float connection_rate, float learning_rate,
-	/* the number of layers, including the input and output layer */
-	unsigned int num_layers,
-	/* the number of neurons in each of the layers, starting with
-	   the input layer and ending with the output layer */
-	...);
-
-/* Constructs a backpropagation neural network from a configuration file.
- */
-struct fann * fann_create_from_file(const char *configuration_file);
-
-/* Destructs the entire network.
-   Be sure to call this function after finished using the network.
- */
-void fann_destroy(struct fann *ann);
-
-/* Save the entire network to a configuration file.
- */
-void fann_save(struct fann *ann, const char *configuration_file);
-
-/* Saves the entire network to a configuration file.
-   But it is saved in fixed point format no matter which
-   format it is currently in.
-
-   This is usefull for training a network in floating points,
-   and then later executing it in fixed point.
-
-   The function returns the bit position of the fix point, which
-   can be used to find out how accurate the fixed point network will be.
-   A high value indicates high precision, and a low value indicates low
-   precision.
-
-   A negative value indicates very low precision, and a very
-   strong possibility for overflow.
-   (the actual fix point will be set to 0, since a negative
-   fix point does not make sence).
-
-   Generally, a fix point lower than 6 is bad, and should be avoided.
-   The best way to avoid this, is to have less connections to each neuron,
-   or just less neurons in each layer.
-
-   The fixed point use of this network is only intended for use on machines that
-   have no floating point processor, like an iPAQ. On normal computers the floating
-   point version is actually faster.
-*/
-int fann_save_to_fixed(struct fann *ann, const char *configuration_file);
-
-/* ----- Some stuff to set options on the network on the fly. ----- */
-
-/* Set the learning rate.
- */
-void fann_set_learning_rate(struct fann *ann, float learning_rate);
-
-/* The possible activation functions.
-   Threshold can not be used, when training the network.
- */
-#define FANN_SIGMOID 1
-#define FANN_THRESHOLD 2
-
-/* Set the activation function for the hidden layers (default SIGMOID).
- */
-void fann_set_activation_function_hidden(struct fann *ann, unsigned int activation_function);
-
-/* Set the activation function for the output layer (default SIGMOID).
- */
-void fann_set_activation_function_output(struct fann *ann, unsigned int activation_function);
-
-/* Set the steepness of the sigmoid function used in the hidden layers.
-   Only usefull if sigmoid function is used in the hidden layers (default 0.5).
- */
-void fann_set_activation_hidden_steepness(struct fann *ann, fann_type steepness);
-
-/* Set the steepness of the sigmoid function used in the output layer.
-   Only usefull if sigmoid function is used in the output layer (default 0.5).
- */
-void fann_set_activation_output_steepness(struct fann *ann, fann_type steepness);
-
-/* ----- Some stuff to read network options from the network. ----- */
-
-/* Get the learning rate.
- */
-float fann_get_learning_rate(struct fann *ann);
-
-/* Get the number of input neurons.
- */
-unsigned int fann_get_num_input(struct fann *ann);
-
-/* Get the number of output neurons.
- */
-unsigned int fann_get_num_output(struct fann *ann);
-
-/* Get the activation function used in the hidden layers.
- */
-unsigned int fann_get_activation_function_hidden(struct fann *ann);
-
-/* Get the activation function used in the output layer.
- */
-unsigned int fann_get_activation_function_output(struct fann *ann);
-
-/* Get the steepness parameter for the sigmoid function used in the hidden layers.
- */
-fann_type fann_get_activation_hidden_steepness(struct fann *ann);
-
-/* Get the steepness parameter for the sigmoid function used in the output layer.
- */
-fann_type fann_get_activation_output_steepness(struct fann *ann);
-
-/* Get the total number of neurons in the entire network.
- */
-unsigned int fann_get_total_neurons(struct fann *ann);
-
-/* Get the total number of connections in the entire network.
- */
-unsigned int fann_get_total_connections(struct fann *ann);
-
-/* Randomize weights (from the beginning the weights are random between -0.1 and 0.1)
- */
-void fann_randomize_weights(struct fann *ann, fann_type min_weight, fann_type max_weight);
-
-/* ----- Training ----- */
-
-#ifndef FIXEDFANN
-/* Train one iteration with a set of inputs, and a set of desired outputs.
- */
-void fann_train(struct fann *ann, fann_type *input, fann_type *desired_output);
-#endif
-
-/* Test with a set of inputs, and a set of desired outputs.
-   This operation updates the mean square error, but does not
-   change the network in any way.
-*/
-fann_type *fann_test(struct fann *ann, fann_type *input, fann_type *desired_output);
-
-/* Reads a file that stores training data, in the format:
-   num_train_data num_input num_output\n
-   inputdata seperated by space\n
-   outputdata seperated by space\n
-
-   .
-   .
-   .
-   
-   inputdata seperated by space\n
-   outputdata seperated by space\n
-*/
-struct fann_train_data* fann_read_train_from_file(char *filename);
-
-/* Destructs the training data
-   Be sure to call this function after finished using the training data.
- */
-void fann_destroy_train(struct fann_train_data* train_data);
-
-#ifndef FIXEDFANN
-/* Trains on an entire dataset, for a maximum of max_epochs
-   epochs or until mean square error is lower than desired_error.
-   Reports about the progress is given every
-   epochs_between_reports epochs.
-   If epochs_between_reports is zero, no reports are given.
-*/
-void fann_train_on_data(struct fann *ann, struct fann_train_data *data, unsigned int max_epochs, unsigned int epochs_between_reports, float desired_error);
-
-/* Does the same as train_on_data, but reads the data directly from a file.
- */
-void fann_train_on_file(struct fann *ann, char *filename, unsigned int max_epochs, unsigned int epochs_between_reports, float desired_error);
-#endif
-
-/* Save the training structure to a file.
- */
-void fann_save_train(struct fann_train_data* data, char *filename);
-
-/* Saves the training structure to a fixed point data file.
- *  (Very usefull for testing the quality of a fixed point network).
- */
-void fann_save_train_to_fixed(struct fann_train_data* data, char *filename, unsigned int decimal_point);
-
-/* Reads the mean square error from the network.
- */
-float fann_get_error(struct fann *ann);
-
-/* Resets the mean square error from the network.
- */
-void fann_reset_error(struct fann *ann);
-
-/* ----- Running�----- */
-
-/* Runs a input through the network, and returns the output.
- */
-fann_type* fann_run(struct fann *ann, fann_type *input);
-
-#ifdef FIXEDFANN
-
-/* returns the position of the decimal point.
- */
-unsigned int fann_get_decimal_point(struct fann *ann);
-
-/* returns the multiplier that fix point data is multiplied with.
- */
-unsigned int fann_get_multiplier(struct fann *ann);
-#endif
-
-#ifdef __cplusplus
-}
-#endif
diff --git a/src/include/fann_data.h~ b/src/include/fann_data.h~
deleted file mode 100644
index f5100f8..0000000
--- a/src/include/fann_data.h~
+++ /dev/null
@@ -1,135 +0,0 @@
-#ifndef __fann_data_h__
-#define __fann_data_h__
-
-/* ----- Data structures -----
- * No data within these structures should be altered directly by the user.
- */
-
-struct fann_neuron
-{
-	fann_type *weights;
-	struct fann_neuron **connected_neurons;
-	unsigned int num_connections;
-	fann_type value;
-}__attribute__((packed));
-
-/* A single layer in the neural network.
- */
-struct fann_layer
-{
-	/* A pointer to the first neuron in the layer 
-	 * When allocated, all the neurons in all the layers are actually
-	 * in one long array, this is because we wan't to easily clear all
-	 * the neurons at once.
-	 */
-	struct fann_neuron *first_neuron;
-
-	/* A pointer to the neuron past the last neuron in the layer */
-	/* the number of neurons is last_neuron - first_neuron */
-	struct fann_neuron *last_neuron;
-};
-
-/* The fast artificial neural network(fann) structure
- */
-struct fann
-{
-	/* the learning rate of the network */
-	float learning_rate;
-
-	/* the connection rate of the network
-	 * between 0 and 1, 1 meaning fully connected
-	 */
-	float connection_rate;
-
-	/* pointer to the first layer (input layer) in an array af all the layers,
-	 * including the input and outputlayers 
-	 */
-	struct fann_layer *first_layer;
-
-	/* pointer to the layer past the last layer in an array af all the layers,
-	 * including the input and outputlayers 
-	 */
-	struct fann_layer *last_layer;
-
-	/* Total number of neurons.
-	 * very usefull, because the actual neurons are allocated in one long array
-	 */
-	unsigned int total_neurons;
-
-	/* Number of input neurons (not calculating bias) */
-	unsigned int num_input;
-
-	/* Number of output neurons (not calculating bias) */
-	unsigned int num_output;
-
-	/* Used to contain the error deltas used during training
-	 * Is allocated during first training session,
-	 * which means that if we do not train, it is never allocated.
-	 */
-	fann_type *train_deltas;
-
-	/* Used to choose which activation function to use
-	   
-	   Sometimes it can be smart, to set the activation function for the hidden neurons
-	   to THRESHOLD and the activation function for the output neurons to SIGMOID,
-	   in this way you get a very fast network, that is still cabable of
-	   producing real valued output.
-	 */
-	unsigned int activation_function_hidden, activation_function_output;
-
-	/* Parameters for the activation function */
-	fann_type activation_hidden_steepness;
-	fann_type activation_output_steepness;
-
-#ifdef FIXEDFANN
-	/* the decimal_point, used for shifting the fix point
-	   in fixed point integer operatons.
-	*/
-	unsigned int decimal_point;
-	
-	/* the multiplier, used for multiplying the fix point
-	   in fixed point integer operatons.
-	   Only used in special cases, since the decimal_point is much faster.
-	*/
-	unsigned int multiplier;
-
-	/* When in fixed point, the sigmoid function is calculated as a stepwise linear
-	   function. In the activation_results array, the result is saved, and in the two values arrays,
-	   the values that gives the results are saved.
-	 */
-	fann_type activation_results[6];
-	fann_type activation_hidden_values[6];
-	fann_type activation_output_values[6];
-
-#endif
-
-	/* Total number of connections.
-	 * very usefull, because the actual connections
-	 * are allocated in one long array
-	 */
-	unsigned int total_connections;
-
-	/* used to store outputs in */
-	fann_type *output;
-
-	/* the number of data used to calculate the error.
-	 */
-	unsigned int num_errors;
-
-	/* the total error value.
-	   the real mean square error is error_value/num_errors
-	 */
-	float error_value;
-};
-
-/* Structure used to store data, for use with training. */
-struct fann_train_data
-{
-	unsigned int num_data;
-	unsigned int num_input;
-	unsigned int num_output;
-	fann_type **input;
-	fann_type **output;
-};
-
-#endif
diff --git a/src/include/fann_internal.h~ b/src/include/fann_internal.h~
deleted file mode 100644
index 28c714c..0000000
--- a/src/include/fann_internal.h~
+++ /dev/null
@@ -1,57 +0,0 @@
-#ifndef __fann_internal_h__
-#define __fann_internal_h__
-/* internal include file, not to be included directly
- */
-
-#include <math.h>
-#include "fann_data.h"
-
-#define FANN_FIX_VERSION "FANN_FIX_0.1"
-#define FANN_FLO_VERSION "FANN_FLO_0.1"
-
-#ifdef FIXEDFANN
-#define FANN_VERSION FANN_FIX_VERSION
-#else
-#define FANN_VERSION FANN_FLO_VERSION
-#endif
-
-struct fann * fann_allocate_structure(float learning_rate, unsigned int num_layers);
-void fann_allocate_neurons(struct fann *ann);
-
-void fann_allocate_connections(struct fann *ann);
-
-int fann_save_internal(struct fann *ann, const char *configuration_file, unsigned int save_as_fixed);
-void fann_save_train_internal(struct fann_train_data* data, char *filename, unsigned int save_as_fixed, unsigned int decimal_point);
-
-int fann_compare_connections(const void* c1, const void* c2);
-void fann_seed_rand();
-
-/* called fann_max, in order to not interferre with predefined versions of max */
-#define fann_max(x, y) (((x) > (y)) ? (x) : (y))
-#define fann_min(x, y) (((x) < (y)) ? (x) : (y))
-
-#define fann_rand(min_value, max_value) (((double)(min_value))+(((double)(max_value)-((double)(min_value)))*rand()/(RAND_MAX+1.0)))
-
-#define fann_abs(value) (((value) > 0) ? (value) : -(value))
-
-#ifdef FIXEDFANN
-
-#define fann_mult(x,y) ((x*y) >> decimal_point)
-#define fann_div(x,y) (((x) << decimal_point)/y)
-#define fann_random_weight() (fann_type)(fann_rand(-multiplier/10,multiplier/10))
-/* sigmoid calculated with use of floats, only as reference */
-#define fann_sigmoid(steepness, value) ((fann_type)(0.5+((1.0/(1.0 + exp(-2.0 * ((float)steepness/multiplier) * ((float)value/multiplier))))*multiplier)))
-/* sigmoid as a stepwise linear function */
-#define fann_linear(v1, r1, v2, r2, value) ((((r2-r1) * (value-v1))/(v2-v1)) + r1)
-#define fann_sigmoid_stepwise(v1, v2, v3, v4, v5, v6, r1, r2, r3, r4, r5, r6, value, multiplier) (value < v5 ? (value < v3 ? (value < v2 ? (value < v1 ? 0 : fann_linear(v1, r1, v2, r2, value)) : fann_linear(v2, r2, v3, r3, value)) : (value < v4 ? fann_linear(v3, r3, v4, r4, value) : fann_linear(v4, r4, v5, r5, value))) : (value < v6 ? fann_linear(v5, r5, v6, r6, value) : multiplier))
-#else
-
-#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_sigmoid(steepness, value) (1.0/(1.0 + exp(-2.0 * steepness * value)))
-#define fann_sigmoid_derive(steepness, value) (2.0 * steepness * value * (1.0 - value))
-
-#endif
-
-#endif
diff --git a/src/include/fixedfann.h~ b/src/include/fixedfann.h~
deleted file mode 100644
index 9540113..0000000
--- a/src/include/fixedfann.h~
+++ /dev/null
@@ -1,11 +0,0 @@
-#ifndef __fixedfann_h__
-#define __fixedfann_h__
-
-typedef int fann_type;
-#define FIXEDFANN
-#define FANNPRINTF "%d"
-#define FANNSCANF "%d"
-
-#include "fann.h"
-
-#endif
diff --git a/src/include/floatfann.h~ b/src/include/floatfann.h~
deleted file mode 100644
index 19f289f..0000000
--- a/src/include/floatfann.h~
+++ /dev/null
@@ -1,11 +0,0 @@
-#ifndef __floatfann_h__
-#define __floatfann_h__
-
-typedef float fann_type;
-#define FLOATFANN
-#define FANNPRINTF "%.20e"
-#define FANNSCANF "%f"
-
-#include "fann.h"
-
-#endif
diff --git a/src/test/xor_train.c b/src/test/xor_train.c
index c34b813..3ac28ad 100644
--- a/src/test/xor_train.c
+++ b/src/test/xor_train.c
@@ -64,7 +64,7 @@ int main()
 	
 	printf("Saving network.\n");
 
-	fann_save(ann, "xor_float.net");
+	fann_save(ann, "test/xor_float.net");
 
 	decimal_point = fann_save_to_fixed(ann, "test/xor_fixed.net");
 	fann_save_train_to_fixed(data, "test/xor_fixed.data", decimal_point);
diff --git a/src/xor_float.net b/src/xor_float.net
deleted file mode 100644
index b0c5a89..0000000
--- a/src/xor_float.net
+++ /dev/null
@@ -1,7 +0,0 @@
-FANN_FLO_0.1
-3 0.700000 1.000000 1 1 5.00000000000000000000e-01 5.00000000000000000000e-01
-3 5 2 
-0 0 0 
-3 3 3 3 0 
-5 0 
-(0 -9.48918282985687255859e-01) (1 -1.23705720901489257812e+00) (2 6.65207684040069580078e-01) (0 -4.59167146682739257812e+00) (1 -4.51027774810791015625e+00) (2 6.69409322738647460938e+00) (0 -6.24567556381225585938e+00) (1 -6.31592130661010742188e+00) (2 2.44613099098205566406e+00) (0 -3.09236335754394531250e+00) (1 -3.18698549270629882812e+00) (2 9.77448076009750366211e-02) (3 2.11537027359008789062e+00) (4 1.09966716766357421875e+01) (5 -1.07013969421386718750e+01) (6 -3.217698574066 [...]

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