ruby-fann 0.7.10 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +6 -1
- data/License.txt +1 -1
- data/Manifest.txt +22 -1
- data/README.txt +0 -1
- data/Rakefile +0 -0
- data/config/hoe.rb +0 -0
- data/config/requirements.rb +0 -0
- data/ext/ruby_fann/MANIFEST +0 -0
- data/ext/ruby_fann/Makefile +36 -28
- data/ext/ruby_fann/doublefann.c +30 -0
- data/ext/ruby_fann/doublefann.h +33 -0
- data/ext/ruby_fann/extconf.rb +9 -5
- data/ext/ruby_fann/fann.c +1552 -0
- data/ext/ruby_fann/fann_activation.h +144 -0
- data/ext/ruby_fann/fann_augment.h +0 -0
- data/ext/ruby_fann/fann_cascade.c +1031 -0
- data/ext/ruby_fann/fann_cascade.h +503 -0
- data/ext/ruby_fann/fann_data.h +799 -0
- data/ext/ruby_fann/fann_error.c +204 -0
- data/ext/ruby_fann/fann_error.h +161 -0
- data/ext/ruby_fann/fann_internal.h +148 -0
- data/ext/ruby_fann/fann_io.c +762 -0
- data/ext/ruby_fann/fann_io.h +100 -0
- data/ext/ruby_fann/fann_train.c +962 -0
- data/ext/ruby_fann/fann_train.h +1203 -0
- data/ext/ruby_fann/fann_train_data.c +1231 -0
- data/ext/ruby_fann/neural_network.c +0 -0
- data/lib/ruby_fann/neurotica.rb +0 -0
- data/lib/ruby_fann/version.rb +3 -3
- data/lib/ruby_fann.rb +0 -0
- data/neurotica1.png +0 -0
- data/neurotica2.vrml +18 -18
- data/setup.rb +0 -0
- data/tasks/deployment.rake +0 -0
- data/tasks/environment.rake +0 -0
- data/tasks/website.rake +0 -0
- data/test/test.train +0 -0
- data/test/test_helper.rb +0 -0
- data/test/test_neurotica.rb +0 -0
- data/test/test_ruby_fann.rb +0 -0
- data/test/test_ruby_fann_functional.rb +0 -0
- data/verify.train +0 -0
- data/website/index.html +42 -92
- data/website/index.txt +0 -0
- data/website/javascripts/rounded_corners_lite.inc.js +0 -0
- data/website/stylesheets/screen.css +0 -0
- data/website/template.rhtml +0 -0
- data/xor.train +0 -0
- data/xor_cascade.net +2 -2
- data/xor_float.net +1 -1
- metadata +22 -6
- data/log/debug.log +0 -0
@@ -0,0 +1,204 @@
|
|
1
|
+
/*
|
2
|
+
Fast Artificial Neural Network Library (fann)
|
3
|
+
Copyright (C) 2003 Steffen Nissen (lukesky@diku.dk)
|
4
|
+
|
5
|
+
This library is free software; you can redistribute it and/or
|
6
|
+
modify it under the terms of the GNU Lesser General Public
|
7
|
+
License as published by the Free Software Foundation; either
|
8
|
+
version 2.1 of the License, or (at your option) any later version.
|
9
|
+
|
10
|
+
This library is distributed in the hope that it will be useful,
|
11
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
13
|
+
Lesser General Public License for more details.
|
14
|
+
|
15
|
+
You should have received a copy of the GNU Lesser General Public
|
16
|
+
License along with this library; if not, write to the Free Software
|
17
|
+
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
18
|
+
*/
|
19
|
+
|
20
|
+
#include <stdio.h>
|
21
|
+
#include <stdlib.h>
|
22
|
+
#include <stdarg.h>
|
23
|
+
#include <string.h>
|
24
|
+
|
25
|
+
#include "config.h"
|
26
|
+
#include "fann.h"
|
27
|
+
|
28
|
+
#ifdef _MSC_VER
|
29
|
+
#define vsnprintf _vsnprintf
|
30
|
+
#define snprintf _snprintf
|
31
|
+
#endif
|
32
|
+
|
33
|
+
FILE * fann_default_error_log = (FILE *)-1;
|
34
|
+
|
35
|
+
/* resets the last error number
|
36
|
+
*/
|
37
|
+
FANN_EXTERNAL void FANN_API fann_reset_errno(struct fann_error *errdat)
|
38
|
+
{
|
39
|
+
errdat->errno_f = FANN_E_NO_ERROR;
|
40
|
+
}
|
41
|
+
|
42
|
+
/* resets the last errstr
|
43
|
+
*/
|
44
|
+
FANN_EXTERNAL void FANN_API fann_reset_errstr(struct fann_error *errdat)
|
45
|
+
{
|
46
|
+
if(errdat->errstr != NULL)
|
47
|
+
free(errdat->errstr);
|
48
|
+
errdat->errstr = NULL;
|
49
|
+
}
|
50
|
+
|
51
|
+
/* returns the last error number
|
52
|
+
*/
|
53
|
+
FANN_EXTERNAL enum fann_errno_enum FANN_API fann_get_errno(struct fann_error *errdat)
|
54
|
+
{
|
55
|
+
return errdat->errno_f;
|
56
|
+
}
|
57
|
+
|
58
|
+
/* returns the last errstr
|
59
|
+
*/
|
60
|
+
FANN_EXTERNAL char *FANN_API fann_get_errstr(struct fann_error *errdat)
|
61
|
+
{
|
62
|
+
char *errstr = errdat->errstr;
|
63
|
+
|
64
|
+
fann_reset_errno(errdat);
|
65
|
+
fann_reset_errstr(errdat);
|
66
|
+
|
67
|
+
return errstr;
|
68
|
+
}
|
69
|
+
|
70
|
+
/* change where errors are logged to
|
71
|
+
*/
|
72
|
+
FANN_EXTERNAL void FANN_API fann_set_error_log(struct fann_error *errdat, FILE * log_file)
|
73
|
+
{
|
74
|
+
if(errdat == NULL)
|
75
|
+
fann_default_error_log = log_file;
|
76
|
+
else
|
77
|
+
errdat->error_log = log_file;
|
78
|
+
}
|
79
|
+
|
80
|
+
/* prints the last error to stderr
|
81
|
+
*/
|
82
|
+
FANN_EXTERNAL void FANN_API fann_print_error(struct fann_error *errdat)
|
83
|
+
{
|
84
|
+
if(errdat->errno_f != FANN_E_NO_ERROR && errdat->errstr != NULL)
|
85
|
+
{
|
86
|
+
fprintf(stderr, "FANN Error %d: %s", errdat->errno_f, errdat->errstr);
|
87
|
+
}
|
88
|
+
}
|
89
|
+
|
90
|
+
/* INTERNAL FUNCTION
|
91
|
+
Populate the error information
|
92
|
+
*/
|
93
|
+
void fann_error(struct fann_error *errdat, const enum fann_errno_enum errno_f, ...)
|
94
|
+
{
|
95
|
+
va_list ap;
|
96
|
+
char *errstr;
|
97
|
+
FILE * error_log = fann_default_error_log;
|
98
|
+
|
99
|
+
if(errdat != NULL)
|
100
|
+
errdat->errno_f = errno_f;
|
101
|
+
|
102
|
+
if(errdat != NULL && errdat->errstr != NULL)
|
103
|
+
{
|
104
|
+
errstr = errdat->errstr;
|
105
|
+
}
|
106
|
+
else
|
107
|
+
{
|
108
|
+
errstr = (char *) malloc(FANN_ERRSTR_MAX);
|
109
|
+
if(errstr == NULL)
|
110
|
+
{
|
111
|
+
fprintf(stderr, "Unable to allocate memory.\n");
|
112
|
+
return;
|
113
|
+
}
|
114
|
+
}
|
115
|
+
|
116
|
+
va_start(ap, errno_f);
|
117
|
+
switch (errno_f)
|
118
|
+
{
|
119
|
+
case FANN_E_NO_ERROR:
|
120
|
+
break;
|
121
|
+
case FANN_E_CANT_OPEN_CONFIG_R:
|
122
|
+
vsprintf(errstr, "Unable to open configuration file \"%s\" for reading.\n", ap);
|
123
|
+
break;
|
124
|
+
case FANN_E_CANT_OPEN_CONFIG_W:
|
125
|
+
vsprintf(errstr, "Unable to open configuration file \"%s\" for writing.\n", ap);
|
126
|
+
break;
|
127
|
+
case FANN_E_WRONG_CONFIG_VERSION:
|
128
|
+
vsprintf(errstr,
|
129
|
+
"Wrong version of configuration file, aborting read of configuration file \"%s\".\n",
|
130
|
+
ap);
|
131
|
+
break;
|
132
|
+
case FANN_E_CANT_READ_CONFIG:
|
133
|
+
vsprintf(errstr, "Error reading \"%s\" from configuration file \"%s\".\n", ap);
|
134
|
+
break;
|
135
|
+
case FANN_E_CANT_READ_NEURON:
|
136
|
+
vsprintf(errstr, "Error reading neuron info from configuration file \"%s\".\n", ap);
|
137
|
+
break;
|
138
|
+
case FANN_E_CANT_READ_CONNECTIONS:
|
139
|
+
vsprintf(errstr, "Error reading connections from configuration file \"%s\".\n", ap);
|
140
|
+
break;
|
141
|
+
case FANN_E_WRONG_NUM_CONNECTIONS:
|
142
|
+
vsprintf(errstr, "ERROR connections_so_far=%d, total_connections=%d\n", ap);
|
143
|
+
break;
|
144
|
+
case FANN_E_CANT_OPEN_TD_W:
|
145
|
+
vsprintf(errstr, "Unable to open train data file \"%s\" for writing.\n", ap);
|
146
|
+
break;
|
147
|
+
case FANN_E_CANT_OPEN_TD_R:
|
148
|
+
vsprintf(errstr, "Unable to open train data file \"%s\" for writing.\n", ap);
|
149
|
+
break;
|
150
|
+
case FANN_E_CANT_READ_TD:
|
151
|
+
vsprintf(errstr, "Error reading info from train data file \"%s\", line: %d.\n", ap);
|
152
|
+
break;
|
153
|
+
case FANN_E_CANT_ALLOCATE_MEM:
|
154
|
+
sprintf(errstr, "Unable to allocate memory.\n");
|
155
|
+
break;
|
156
|
+
case FANN_E_CANT_TRAIN_ACTIVATION:
|
157
|
+
sprintf(errstr, "Unable to train with the selected activation function.\n");
|
158
|
+
break;
|
159
|
+
case FANN_E_CANT_USE_ACTIVATION:
|
160
|
+
sprintf(errstr, "Unable to use the selected activation function.\n");
|
161
|
+
break;
|
162
|
+
case FANN_E_TRAIN_DATA_MISMATCH:
|
163
|
+
sprintf(errstr, "Training data must be of equivalent structure.\n");
|
164
|
+
break;
|
165
|
+
case FANN_E_CANT_USE_TRAIN_ALG:
|
166
|
+
sprintf(errstr, "Unable to use the selected training algorithm.\n");
|
167
|
+
break;
|
168
|
+
case FANN_E_TRAIN_DATA_SUBSET:
|
169
|
+
vsprintf(errstr, "Subset from %d of length %d not valid in training set of length %d.\n", ap);
|
170
|
+
break;
|
171
|
+
case FANN_E_INDEX_OUT_OF_BOUND:
|
172
|
+
vsprintf(errstr, "Index %d is out of bound.\n", ap);
|
173
|
+
break;
|
174
|
+
case FANN_E_SCALE_NOT_PRESENT:
|
175
|
+
sprintf(errstr, "Scaling parameters not present.\n");
|
176
|
+
break;
|
177
|
+
}
|
178
|
+
va_end(ap);
|
179
|
+
|
180
|
+
if(errdat != NULL)
|
181
|
+
{
|
182
|
+
errdat->errstr = errstr;
|
183
|
+
error_log = errdat->error_log;
|
184
|
+
}
|
185
|
+
|
186
|
+
if(error_log == (FILE *)-1) /* This is the default behavior and will give stderr */
|
187
|
+
{
|
188
|
+
fprintf(stderr, "FANN Error %d: %s", errno_f, errstr);
|
189
|
+
}
|
190
|
+
else if(error_log != NULL)
|
191
|
+
{
|
192
|
+
fprintf(error_log, "FANN Error %d: %s", errno_f, errstr);
|
193
|
+
}
|
194
|
+
}
|
195
|
+
|
196
|
+
/* INTERNAL FUNCTION
|
197
|
+
Initialize an error data strcuture
|
198
|
+
*/
|
199
|
+
void fann_init_error_data(struct fann_error *errdat)
|
200
|
+
{
|
201
|
+
errdat->errstr = NULL;
|
202
|
+
errdat->errno_f = FANN_E_NO_ERROR;
|
203
|
+
errdat->error_log = fann_default_error_log;
|
204
|
+
}
|
@@ -0,0 +1,161 @@
|
|
1
|
+
/*
|
2
|
+
Fast Artificial Neural Network Library (fann)
|
3
|
+
Copyright (C) 2003 Steffen Nissen (lukesky@diku.dk)
|
4
|
+
|
5
|
+
This library is free software; you can redistribute it and/or
|
6
|
+
modify it under the terms of the GNU Lesser General Public
|
7
|
+
License as published by the Free Software Foundation; either
|
8
|
+
version 2.1 of the License, or (at your option) any later version.
|
9
|
+
|
10
|
+
This library is distributed in the hope that it will be useful,
|
11
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
13
|
+
Lesser General Public License for more details.
|
14
|
+
|
15
|
+
You should have received a copy of the GNU Lesser General Public
|
16
|
+
License along with this library; if not, write to the Free Software
|
17
|
+
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
18
|
+
*/
|
19
|
+
|
20
|
+
#ifndef __fann_error_h__
|
21
|
+
#define __fann_error_h__
|
22
|
+
|
23
|
+
#include <stdio.h>
|
24
|
+
|
25
|
+
#define FANN_ERRSTR_MAX 128
|
26
|
+
struct fann_error;
|
27
|
+
|
28
|
+
/* Section: FANN Error Handling
|
29
|
+
|
30
|
+
Errors from the fann library are usually reported on stderr.
|
31
|
+
It is however possible to redirect these error messages to a file,
|
32
|
+
or completely ignore them by the <fann_set_error_log> function.
|
33
|
+
|
34
|
+
It is also possible to inspect the last error message by using the
|
35
|
+
<fann_get_errno> and <fann_get_errstr> functions.
|
36
|
+
*/
|
37
|
+
|
38
|
+
/* Enum: fann_errno_enum
|
39
|
+
Used to define error events on <struct fann> and <struct fann_train_data>.
|
40
|
+
|
41
|
+
See also:
|
42
|
+
<fann_get_errno>, <fann_reset_errno>, <fann_get_errstr>
|
43
|
+
|
44
|
+
FANN_E_NO_ERROR - No error
|
45
|
+
FANN_E_CANT_OPEN_CONFIG_R - Unable to open configuration file for reading
|
46
|
+
FANN_E_CANT_OPEN_CONFIG_W - Unable to open configuration file for writing
|
47
|
+
FANN_E_WRONG_CONFIG_VERSION - Wrong version of configuration file
|
48
|
+
FANN_E_CANT_READ_CONFIG - Error reading info from configuration file
|
49
|
+
FANN_E_CANT_READ_NEURON - Error reading neuron info from configuration file
|
50
|
+
FANN_E_CANT_READ_CONNECTIONS - Error reading connections from configuration file
|
51
|
+
FANN_E_WRONG_NUM_CONNECTIONS - Number of connections not equal to the number expected
|
52
|
+
FANN_E_CANT_OPEN_TD_W - Unable to open train data file for writing
|
53
|
+
FANN_E_CANT_OPEN_TD_R - Unable to open train data file for reading
|
54
|
+
FANN_E_CANT_READ_TD - Error reading training data from file
|
55
|
+
FANN_E_CANT_ALLOCATE_MEM - Unable to allocate memory
|
56
|
+
FANN_E_CANT_TRAIN_ACTIVATION - Unable to train with the selected activation function
|
57
|
+
FANN_E_CANT_USE_ACTIVATION - Unable to use the selected activation function
|
58
|
+
FANN_E_TRAIN_DATA_MISMATCH - Irreconcilable differences between two <struct fann_train_data> structures
|
59
|
+
FANN_E_CANT_USE_TRAIN_ALG - Unable to use the selected training algorithm
|
60
|
+
FANN_E_TRAIN_DATA_SUBSET - Trying to take subset which is not within the training set
|
61
|
+
FANN_E_INDEX_OUT_OF_BOUND - Index is out of bound
|
62
|
+
FANN_E_SCALE_NOT_PRESENT - Scaling parameters not present
|
63
|
+
*/
|
64
|
+
enum fann_errno_enum
|
65
|
+
{
|
66
|
+
FANN_E_NO_ERROR = 0,
|
67
|
+
FANN_E_CANT_OPEN_CONFIG_R,
|
68
|
+
FANN_E_CANT_OPEN_CONFIG_W,
|
69
|
+
FANN_E_WRONG_CONFIG_VERSION,
|
70
|
+
FANN_E_CANT_READ_CONFIG,
|
71
|
+
FANN_E_CANT_READ_NEURON,
|
72
|
+
FANN_E_CANT_READ_CONNECTIONS,
|
73
|
+
FANN_E_WRONG_NUM_CONNECTIONS,
|
74
|
+
FANN_E_CANT_OPEN_TD_W,
|
75
|
+
FANN_E_CANT_OPEN_TD_R,
|
76
|
+
FANN_E_CANT_READ_TD,
|
77
|
+
FANN_E_CANT_ALLOCATE_MEM,
|
78
|
+
FANN_E_CANT_TRAIN_ACTIVATION,
|
79
|
+
FANN_E_CANT_USE_ACTIVATION,
|
80
|
+
FANN_E_TRAIN_DATA_MISMATCH,
|
81
|
+
FANN_E_CANT_USE_TRAIN_ALG,
|
82
|
+
FANN_E_TRAIN_DATA_SUBSET,
|
83
|
+
FANN_E_INDEX_OUT_OF_BOUND,
|
84
|
+
FANN_E_SCALE_NOT_PRESENT
|
85
|
+
};
|
86
|
+
|
87
|
+
/* Group: Error Handling */
|
88
|
+
|
89
|
+
/* Function: fann_set_error_log
|
90
|
+
|
91
|
+
Change where errors are logged to. Both <struct fann> and <struct fann_data> can be
|
92
|
+
casted to <struct fann_error>, so this function can be used to set either of these.
|
93
|
+
|
94
|
+
If log_file is NULL, no errors will be printed.
|
95
|
+
|
96
|
+
If errdata is NULL, the default log will be set. The default log is the log used when creating
|
97
|
+
<struct fann> and <struct fann_data>. This default log will also be the default for all new structs
|
98
|
+
that are created.
|
99
|
+
|
100
|
+
The default behavior is to log them to stderr.
|
101
|
+
|
102
|
+
See also:
|
103
|
+
<struct fann_error>
|
104
|
+
|
105
|
+
This function appears in FANN >= 1.1.0.
|
106
|
+
*/
|
107
|
+
FANN_EXTERNAL void FANN_API fann_set_error_log(struct fann_error *errdat, FILE * log_file);
|
108
|
+
|
109
|
+
|
110
|
+
/* Function: fann_get_errno
|
111
|
+
|
112
|
+
Returns the last error number.
|
113
|
+
|
114
|
+
See also:
|
115
|
+
<fann_errno_enum>, <fann_reset_errno>
|
116
|
+
|
117
|
+
This function appears in FANN >= 1.1.0.
|
118
|
+
*/
|
119
|
+
FANN_EXTERNAL enum fann_errno_enum FANN_API fann_get_errno(struct fann_error *errdat);
|
120
|
+
|
121
|
+
|
122
|
+
/* Function: fann_reset_errno
|
123
|
+
|
124
|
+
Resets the last error number.
|
125
|
+
|
126
|
+
This function appears in FANN >= 1.1.0.
|
127
|
+
*/
|
128
|
+
FANN_EXTERNAL void FANN_API fann_reset_errno(struct fann_error *errdat);
|
129
|
+
|
130
|
+
|
131
|
+
/* Function: fann_reset_errstr
|
132
|
+
|
133
|
+
Resets the last error string.
|
134
|
+
|
135
|
+
This function appears in FANN >= 1.1.0.
|
136
|
+
*/
|
137
|
+
FANN_EXTERNAL void FANN_API fann_reset_errstr(struct fann_error *errdat);
|
138
|
+
|
139
|
+
|
140
|
+
/* Function: fann_get_errstr
|
141
|
+
|
142
|
+
Returns the last errstr.
|
143
|
+
|
144
|
+
This function calls <fann_reset_errno> and <fann_reset_errstr>
|
145
|
+
|
146
|
+
This function appears in FANN >= 1.1.0.
|
147
|
+
*/
|
148
|
+
FANN_EXTERNAL char *FANN_API fann_get_errstr(struct fann_error *errdat);
|
149
|
+
|
150
|
+
|
151
|
+
/* Function: fann_print_error
|
152
|
+
|
153
|
+
Prints the last error to stderr.
|
154
|
+
|
155
|
+
This function appears in FANN >= 1.1.0.
|
156
|
+
*/
|
157
|
+
FANN_EXTERNAL void FANN_API fann_print_error(struct fann_error *errdat);
|
158
|
+
|
159
|
+
extern FILE * fann_default_error_log;
|
160
|
+
|
161
|
+
#endif
|
@@ -0,0 +1,148 @@
|
|
1
|
+
/*
|
2
|
+
Fast Artificial Neural Network Library (fann)
|
3
|
+
Copyright (C) 2003 Steffen Nissen (lukesky@diku.dk)
|
4
|
+
|
5
|
+
This library is free software; you can redistribute it and/or
|
6
|
+
modify it under the terms of the GNU Lesser General Public
|
7
|
+
License as published by the Free Software Foundation; either
|
8
|
+
version 2.1 of the License, or (at your option) any later version.
|
9
|
+
|
10
|
+
This library is distributed in the hope that it will be useful,
|
11
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
13
|
+
Lesser General Public License for more details.
|
14
|
+
|
15
|
+
You should have received a copy of the GNU Lesser General Public
|
16
|
+
License along with this library; if not, write to the Free Software
|
17
|
+
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
18
|
+
*/
|
19
|
+
|
20
|
+
#ifndef __fann_internal_h__
|
21
|
+
#define __fann_internal_h__
|
22
|
+
/* internal include file, not to be included directly
|
23
|
+
*/
|
24
|
+
|
25
|
+
#include <math.h>
|
26
|
+
#include <stdio.h>
|
27
|
+
#include <stdlib.h>
|
28
|
+
#include "fann_data.h"
|
29
|
+
|
30
|
+
#define FANN_FIX_VERSION "FANN_FIX_2.0"
|
31
|
+
#define FANN_FLO_VERSION "FANN_FLO_2.1"
|
32
|
+
|
33
|
+
#ifdef FIXEDFANN
|
34
|
+
#define FANN_CONF_VERSION FANN_FIX_VERSION
|
35
|
+
#else
|
36
|
+
#define FANN_CONF_VERSION FANN_FLO_VERSION
|
37
|
+
#endif
|
38
|
+
|
39
|
+
#define FANN_GET(type, name) \
|
40
|
+
FANN_EXTERNAL type FANN_API fann_get_ ## name(struct fann *ann) \
|
41
|
+
{ \
|
42
|
+
return ann->name; \
|
43
|
+
}
|
44
|
+
|
45
|
+
#define FANN_SET(type, name) \
|
46
|
+
FANN_EXTERNAL void FANN_API fann_set_ ## name(struct fann *ann, type value) \
|
47
|
+
{ \
|
48
|
+
ann->name = value; \
|
49
|
+
}
|
50
|
+
|
51
|
+
#define FANN_GET_SET(type, name) \
|
52
|
+
FANN_GET(type, name) \
|
53
|
+
FANN_SET(type, name)
|
54
|
+
|
55
|
+
|
56
|
+
struct fann_train_data;
|
57
|
+
|
58
|
+
struct fann *fann_allocate_structure(unsigned int num_layers);
|
59
|
+
void fann_allocate_neurons(struct fann *ann);
|
60
|
+
|
61
|
+
void fann_allocate_connections(struct fann *ann);
|
62
|
+
|
63
|
+
int fann_save_internal(struct fann *ann, const char *configuration_file,
|
64
|
+
unsigned int save_as_fixed);
|
65
|
+
int fann_save_internal_fd(struct fann *ann, FILE * conf, const char *configuration_file,
|
66
|
+
unsigned int save_as_fixed);
|
67
|
+
int fann_save_train_internal(struct fann_train_data *data, const char *filename,
|
68
|
+
unsigned int save_as_fixed, unsigned int decimal_point);
|
69
|
+
int fann_save_train_internal_fd(struct fann_train_data *data, FILE * file, const char *filename,
|
70
|
+
unsigned int save_as_fixed, unsigned int decimal_point);
|
71
|
+
|
72
|
+
void fann_update_stepwise(struct fann *ann);
|
73
|
+
void fann_seed_rand();
|
74
|
+
|
75
|
+
void fann_error(struct fann_error *errdat, const enum fann_errno_enum errno_f, ...);
|
76
|
+
void fann_init_error_data(struct fann_error *errdat);
|
77
|
+
|
78
|
+
struct fann *fann_create_from_fd(FILE * conf, const char *configuration_file);
|
79
|
+
struct fann_train_data *fann_read_train_from_fd(FILE * file, const char *filename);
|
80
|
+
|
81
|
+
void fann_compute_MSE(struct fann *ann, fann_type * desired_output);
|
82
|
+
void fann_update_output_weights(struct fann *ann);
|
83
|
+
void fann_backpropagate_MSE(struct fann *ann);
|
84
|
+
void fann_update_weights(struct fann *ann);
|
85
|
+
void fann_update_slopes_batch(struct fann *ann, struct fann_layer *layer_begin,
|
86
|
+
struct fann_layer *layer_end);
|
87
|
+
void fann_update_weights_quickprop(struct fann *ann, unsigned int num_data,
|
88
|
+
unsigned int first_weight, unsigned int past_end);
|
89
|
+
void fann_update_weights_batch(struct fann *ann, unsigned int num_data, unsigned int first_weight,
|
90
|
+
unsigned int past_end);
|
91
|
+
void fann_update_weights_irpropm(struct fann *ann, unsigned int first_weight,
|
92
|
+
unsigned int past_end);
|
93
|
+
|
94
|
+
void fann_clear_train_arrays(struct fann *ann);
|
95
|
+
|
96
|
+
fann_type fann_activation(struct fann * ann, unsigned int activation_function, fann_type steepness,
|
97
|
+
fann_type value);
|
98
|
+
|
99
|
+
fann_type fann_activation_derived(unsigned int activation_function,
|
100
|
+
fann_type steepness, fann_type value, fann_type sum);
|
101
|
+
|
102
|
+
int fann_desired_error_reached(struct fann *ann, float desired_error);
|
103
|
+
|
104
|
+
/* Some functions for cascade */
|
105
|
+
int fann_train_outputs(struct fann *ann, struct fann_train_data *data, float desired_error);
|
106
|
+
|
107
|
+
float fann_train_outputs_epoch(struct fann *ann, struct fann_train_data *data);
|
108
|
+
|
109
|
+
int fann_train_candidates(struct fann *ann, struct fann_train_data *data);
|
110
|
+
|
111
|
+
fann_type fann_train_candidates_epoch(struct fann *ann, struct fann_train_data *data);
|
112
|
+
|
113
|
+
void fann_install_candidate(struct fann *ann);
|
114
|
+
|
115
|
+
int fann_initialize_candidates(struct fann *ann);
|
116
|
+
|
117
|
+
void fann_set_shortcut_connections(struct fann *ann);
|
118
|
+
|
119
|
+
int fann_allocate_scale(struct fann *ann);
|
120
|
+
|
121
|
+
/* called fann_max, in order to not interferre with predefined versions of max */
|
122
|
+
#define fann_max(x, y) (((x) > (y)) ? (x) : (y))
|
123
|
+
#define fann_min(x, y) (((x) < (y)) ? (x) : (y))
|
124
|
+
#define fann_safe_free(x) {if(x) { free(x); x = NULL; }}
|
125
|
+
#define fann_clip(x, lo, hi) (((x) < (lo)) ? (lo) : (((x) > (hi)) ? (hi) : (x)))
|
126
|
+
/*#define fann_clip(x, lo, hi) (x)*/
|
127
|
+
|
128
|
+
#define fann_rand(min_value, max_value) (((float)(min_value))+(((float)(max_value)-((float)(min_value)))*rand()/(RAND_MAX+1.0f)))
|
129
|
+
|
130
|
+
#define fann_abs(value) (((value) > 0) ? (value) : -(value))
|
131
|
+
|
132
|
+
#ifdef FIXEDFANN
|
133
|
+
|
134
|
+
#define fann_mult(x,y) ((x*y) >> decimal_point)
|
135
|
+
#define fann_div(x,y) (((x) << decimal_point)/y)
|
136
|
+
#define fann_random_weight() (fann_type)(fann_rand(0,multiplier/10))
|
137
|
+
#define fann_random_bias_weight() (fann_type)(fann_rand((0-multiplier)/10,multiplier/10))
|
138
|
+
|
139
|
+
#else
|
140
|
+
|
141
|
+
#define fann_mult(x,y) (x*y)
|
142
|
+
#define fann_div(x,y) (x/y)
|
143
|
+
#define fann_random_weight() (fann_rand(-0.1f,0.1f))
|
144
|
+
#define fann_random_bias_weight() (fann_rand(-0.1f,0.1f))
|
145
|
+
|
146
|
+
#endif
|
147
|
+
|
148
|
+
#endif
|