ruby-fann 0.7.10 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. data/History.txt +6 -1
  2. data/License.txt +1 -1
  3. data/Manifest.txt +22 -1
  4. data/README.txt +0 -1
  5. data/Rakefile +0 -0
  6. data/config/hoe.rb +0 -0
  7. data/config/requirements.rb +0 -0
  8. data/ext/ruby_fann/MANIFEST +0 -0
  9. data/ext/ruby_fann/Makefile +36 -28
  10. data/ext/ruby_fann/doublefann.c +30 -0
  11. data/ext/ruby_fann/doublefann.h +33 -0
  12. data/ext/ruby_fann/extconf.rb +9 -5
  13. data/ext/ruby_fann/fann.c +1552 -0
  14. data/ext/ruby_fann/fann_activation.h +144 -0
  15. data/ext/ruby_fann/fann_augment.h +0 -0
  16. data/ext/ruby_fann/fann_cascade.c +1031 -0
  17. data/ext/ruby_fann/fann_cascade.h +503 -0
  18. data/ext/ruby_fann/fann_data.h +799 -0
  19. data/ext/ruby_fann/fann_error.c +204 -0
  20. data/ext/ruby_fann/fann_error.h +161 -0
  21. data/ext/ruby_fann/fann_internal.h +148 -0
  22. data/ext/ruby_fann/fann_io.c +762 -0
  23. data/ext/ruby_fann/fann_io.h +100 -0
  24. data/ext/ruby_fann/fann_train.c +962 -0
  25. data/ext/ruby_fann/fann_train.h +1203 -0
  26. data/ext/ruby_fann/fann_train_data.c +1231 -0
  27. data/ext/ruby_fann/neural_network.c +0 -0
  28. data/lib/ruby_fann/neurotica.rb +0 -0
  29. data/lib/ruby_fann/version.rb +3 -3
  30. data/lib/ruby_fann.rb +0 -0
  31. data/neurotica1.png +0 -0
  32. data/neurotica2.vrml +18 -18
  33. data/setup.rb +0 -0
  34. data/tasks/deployment.rake +0 -0
  35. data/tasks/environment.rake +0 -0
  36. data/tasks/website.rake +0 -0
  37. data/test/test.train +0 -0
  38. data/test/test_helper.rb +0 -0
  39. data/test/test_neurotica.rb +0 -0
  40. data/test/test_ruby_fann.rb +0 -0
  41. data/test/test_ruby_fann_functional.rb +0 -0
  42. data/verify.train +0 -0
  43. data/website/index.html +42 -92
  44. data/website/index.txt +0 -0
  45. data/website/javascripts/rounded_corners_lite.inc.js +0 -0
  46. data/website/stylesheets/screen.css +0 -0
  47. data/website/template.rhtml +0 -0
  48. data/xor.train +0 -0
  49. data/xor_cascade.net +2 -2
  50. data/xor_float.net +1 -1
  51. metadata +22 -6
  52. data/log/debug.log +0 -0
@@ -0,0 +1,1203 @@
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_train_h__
21
+ #define __fann_train_h__
22
+
23
+ /* Section: FANN Training
24
+
25
+ There are many different ways of training neural networks and the FANN library supports
26
+ a number of different approaches.
27
+
28
+ Two fundementally different approaches are the most commonly used:
29
+
30
+ Fixed topology training - The size and topology of the ANN is determined in advance
31
+ and the training alters the weights in order to minimize the difference between
32
+ the desired output values and the actual output values. This kind of training is
33
+ supported by <fann_train_on_data>.
34
+
35
+ Evolving topology training - The training start out with an empty ANN, only consisting
36
+ of input and output neurons. Hidden neurons and connections is the added during training,
37
+ in order to reach the same goal as for fixed topology training. This kind of training
38
+ is supported by <FANN Cascade Training>.
39
+ */
40
+
41
+ /* Struct: struct fann_train_data
42
+ Structure used to store data, for use with training.
43
+
44
+ The data inside this structure should never be manipulated directly, but should use some
45
+ of the supplied functions in <Training Data Manipulation>.
46
+
47
+ The training data structure is very usefull for storing data during training and testing of a
48
+ neural network.
49
+
50
+ See also:
51
+ <fann_read_train_from_file>, <fann_train_on_data>, <fann_destroy_train>
52
+ */
53
+ struct fann_train_data
54
+ {
55
+ enum fann_errno_enum errno_f;
56
+ FILE *error_log;
57
+ char *errstr;
58
+
59
+ unsigned int num_data;
60
+ unsigned int num_input;
61
+ unsigned int num_output;
62
+ fann_type **input;
63
+ fann_type **output;
64
+ };
65
+
66
+ /* Section: FANN Training */
67
+
68
+ /* Group: Training */
69
+
70
+ #ifndef FIXEDFANN
71
+ /* Function: fann_train
72
+
73
+ Train one iteration with a set of inputs, and a set of desired outputs.
74
+ This training is always incremental training (see <fann_train_enum>), since
75
+ only one pattern is presented.
76
+
77
+ Parameters:
78
+ ann - The neural network structure
79
+ input - an array of inputs. This array must be exactly <fann_get_num_input> long.
80
+ desired_output - an array of desired outputs. This array must be exactly <fann_get_num_output> long.
81
+
82
+ See also:
83
+ <fann_train_on_data>, <fann_train_epoch>
84
+
85
+ This function appears in FANN >= 1.0.0.
86
+ */
87
+ FANN_EXTERNAL void FANN_API fann_train(struct fann *ann, fann_type * input,
88
+ fann_type * desired_output);
89
+
90
+ #endif /* NOT FIXEDFANN */
91
+
92
+ /* Function: fann_test
93
+ Test with a set of inputs, and a set of desired outputs.
94
+ This operation updates the mean square error, but does not
95
+ change the network in any way.
96
+
97
+ See also:
98
+ <fann_test_data>, <fann_train>
99
+
100
+ This function appears in FANN >= 1.0.0.
101
+ */
102
+ FANN_EXTERNAL fann_type * FANN_API fann_test(struct fann *ann, fann_type * input,
103
+ fann_type * desired_output);
104
+
105
+ /* Function: fann_get_MSE
106
+ Reads the mean square error from the network.
107
+
108
+ Reads the mean square error from the network. This value is calculated during
109
+ training or testing, and can therefore sometimes be a bit off if the weights
110
+ have been changed since the last calculation of the value.
111
+
112
+ See also:
113
+ <fann_test_data>
114
+
115
+ This function appears in FANN >= 1.1.0.
116
+ */
117
+ FANN_EXTERNAL float FANN_API fann_get_MSE(struct fann *ann);
118
+
119
+ /* Function: fann_get_bit_fail
120
+
121
+ The number of fail bits; means the number of output neurons which differ more
122
+ than the bit fail limit (see <fann_get_bit_fail_limit>, <fann_set_bit_fail_limit>).
123
+ The bits are counted in all of the training data, so this number can be higher than
124
+ the number of training data.
125
+
126
+ This value is reset by <fann_reset_MSE> and updated by all the same functions which also
127
+ updates the MSE value (e.g. <fann_test_data>, <fann_train_epoch>)
128
+
129
+ See also:
130
+ <fann_stopfunc_enum>, <fann_get_MSE>
131
+
132
+ This function appears in FANN >= 2.0.0
133
+ */
134
+ FANN_EXTERNAL unsigned int FANN_API fann_get_bit_fail(struct fann *ann);
135
+
136
+ /* Function: fann_reset_MSE
137
+ Resets the mean square error from the network.
138
+
139
+ This function also resets the number of bits that fail.
140
+
141
+ See also:
142
+ <fann_get_MSE>, <fann_get_bit_fail_limit>
143
+
144
+ This function appears in FANN >= 1.1.0
145
+ */
146
+ FANN_EXTERNAL void FANN_API fann_reset_MSE(struct fann *ann);
147
+
148
+ /* Group: Training Data Training */
149
+
150
+ #ifndef FIXEDFANN
151
+
152
+ /* Function: fann_train_on_data
153
+
154
+ Trains on an entire dataset, for a period of time.
155
+
156
+ This training uses the training algorithm chosen by <fann_set_training_algorithm>,
157
+ and the parameters set for these training algorithms.
158
+
159
+ Parameters:
160
+ ann - The neural network
161
+ data - The data, which should be used during training
162
+ max_epochs - The maximum number of epochs the training should continue
163
+ epochs_between_reports - The number of epochs between printing a status report to stdout.
164
+ A value of zero means no reports should be printed.
165
+ desired_error - The desired <fann_get_MSE> or <fann_get_bit_fail>, depending on which stop function
166
+ is chosen by <fann_set_train_stop_function>.
167
+
168
+ Instead of printing out reports every epochs_between_reports, a callback function can be called
169
+ (see <fann_set_callback>).
170
+
171
+ See also:
172
+ <fann_train_on_file>, <fann_train_epoch>, <Parameters>
173
+
174
+ This function appears in FANN >= 1.0.0.
175
+ */
176
+ FANN_EXTERNAL void FANN_API fann_train_on_data(struct fann *ann, struct fann_train_data *data,
177
+ unsigned int max_epochs,
178
+ unsigned int epochs_between_reports,
179
+ float desired_error);
180
+
181
+ /* Function: fann_train_on_file
182
+
183
+ Does the same as <fann_train_on_data>, but reads the training data directly from a file.
184
+
185
+ See also:
186
+ <fann_train_on_data>
187
+
188
+ This function appears in FANN >= 1.0.0.
189
+ */
190
+ FANN_EXTERNAL void FANN_API fann_train_on_file(struct fann *ann, const char *filename,
191
+ unsigned int max_epochs,
192
+ unsigned int epochs_between_reports,
193
+ float desired_error);
194
+
195
+ /* Function: fann_train_epoch
196
+ Train one epoch with a set of training data.
197
+
198
+ Train one epoch with the training data stored in data. One epoch is where all of
199
+ the training data is considered exactly once.
200
+
201
+ This function returns the MSE error as it is calculated either before or during
202
+ the actual training. This is not the actual MSE after the training epoch, but since
203
+ calculating this will require to go through the entire training set once more, it is
204
+ more than adequate to use this value during training.
205
+
206
+ The training algorithm used by this function is chosen by the <fann_set_training_algorithm>
207
+ function.
208
+
209
+ See also:
210
+ <fann_train_on_data>, <fann_test_data>
211
+
212
+ This function appears in FANN >= 1.2.0.
213
+ */
214
+ FANN_EXTERNAL float FANN_API fann_train_epoch(struct fann *ann, struct fann_train_data *data);
215
+ #endif /* NOT FIXEDFANN */
216
+
217
+ /* Function: fann_test_data
218
+
219
+ Test a set of training data and calculates the MSE for the training data.
220
+
221
+ This function updates the MSE and the bit fail values.
222
+
223
+ See also:
224
+ <fann_test>, <fann_get_MSE>, <fann_get_bit_fail>
225
+
226
+ This function appears in FANN >= 1.2.0.
227
+ */
228
+ FANN_EXTERNAL float FANN_API fann_test_data(struct fann *ann, struct fann_train_data *data);
229
+
230
+ /* Group: Training Data Manipulation */
231
+
232
+ /* Function: fann_read_train_from_file
233
+ Reads a file that stores training data.
234
+
235
+ The file must be formatted like:
236
+ >num_train_data num_input num_output
237
+ >inputdata seperated by space
238
+ >outputdata seperated by space
239
+ >
240
+ >.
241
+ >.
242
+ >.
243
+ >
244
+ >inputdata seperated by space
245
+ >outputdata seperated by space
246
+
247
+ See also:
248
+ <fann_train_on_data>, <fann_destroy_train>, <fann_save_train>
249
+
250
+ This function appears in FANN >= 1.0.0
251
+ */
252
+ FANN_EXTERNAL struct fann_train_data *FANN_API fann_read_train_from_file(const char *filename);
253
+
254
+
255
+ /* Function: fann_create_train_from_callback
256
+ Creates the training data struct from a user supplied function.
257
+ As the training data are numerable (data 1, data 2...), the user must write
258
+ a function that receives the number of the training data set (input,output)
259
+ and returns the set.
260
+
261
+ Parameters:
262
+ num_data - The number of training data
263
+ num_input - The number of inputs per training data
264
+ num_output - The number of ouputs per training data
265
+ user_function - The user suplied function
266
+
267
+ Parameters for the user function:
268
+ num - The number of the training data set
269
+ num_input - The number of inputs per training data
270
+ num_output - The number of ouputs per training data
271
+ input - The set of inputs
272
+ output - The set of desired outputs
273
+
274
+ See also:
275
+ <fann_read_train_from_file>, <fann_train_on_data>, <fann_destroy_train>,
276
+ <fann_save_train>
277
+
278
+ This function appears in FANN >= 2.1.0
279
+ */
280
+ FANN_EXTERNAL struct fann_train_data * FANN_API fann_create_train_from_callback(unsigned int num_data,
281
+ unsigned int num_input,
282
+ unsigned int num_output,
283
+ void (FANN_API *user_function)( unsigned int,
284
+ unsigned int,
285
+ unsigned int,
286
+ fann_type * ,
287
+ fann_type * ));
288
+
289
+ /* Function: fann_destroy_train
290
+ Destructs the training data and properly deallocates all of the associated data.
291
+ Be sure to call this function after finished using the training data.
292
+
293
+ This function appears in FANN >= 1.0.0
294
+ */
295
+ FANN_EXTERNAL void FANN_API fann_destroy_train(struct fann_train_data *train_data);
296
+
297
+
298
+ /* Function: fann_shuffle_train_data
299
+
300
+ Shuffles training data, randomizing the order.
301
+ This is recommended for incremental training, while it have no influence during batch training.
302
+
303
+ This function appears in FANN >= 1.1.0.
304
+ */
305
+ FANN_EXTERNAL void FANN_API fann_shuffle_train_data(struct fann_train_data *train_data);
306
+
307
+ #ifndef FIXEDFANN
308
+ /* Function: fann_scale_train
309
+
310
+ Scale input and output data based on previously calculated parameters.
311
+
312
+ Parameters:
313
+ ann - ann for which were calculated trained parameters before
314
+ data - training data that needs to be scaled
315
+
316
+ See also:
317
+ <fann_descale_train>, <fann_set_scaling_params>
318
+
319
+ This function appears in FANN >= 2.1.0
320
+ */
321
+ FANN_EXTERNAL void FANN_API fann_scale_train( struct fann *ann, struct fann_train_data *data );
322
+
323
+ /* Function: fann_descale_train
324
+
325
+ Descale input and output data based on previously calculated parameters.
326
+
327
+ Parameters:
328
+ ann - ann for which were calculated trained parameters before
329
+ data - training data that needs to be descaled
330
+
331
+ See also:
332
+ <fann_scale_train>, <fann_set_scaling_params>
333
+
334
+ This function appears in FANN >= 2.1.0
335
+ */
336
+ FANN_EXTERNAL void FANN_API fann_descale_train( struct fann *ann, struct fann_train_data *data );
337
+
338
+ /* Function: fann_set_input_scaling_params
339
+
340
+ Calculate input scaling parameters for future use based on training data.
341
+
342
+ Parameters:
343
+ ann - ann for wgich parameters needs to be calculated
344
+ data - training data that will be used to calculate scaling parameters
345
+ new_input_min - desired lower bound in input data after scaling (not strictly followed)
346
+ new_input_max - desired upper bound in input data after scaling (not strictly followed)
347
+
348
+ See also:
349
+ <fann_set_output_scaling_params>
350
+
351
+ This function appears in FANN >= 2.1.0
352
+ */
353
+ FANN_EXTERNAL int FANN_API fann_set_input_scaling_params(
354
+ struct fann *ann,
355
+ const struct fann_train_data *data,
356
+ float new_input_min,
357
+ float new_input_max);
358
+
359
+ /* Function: fann_set_output_scaling_params
360
+
361
+ Calculate output scaling parameters for future use based on training data.
362
+
363
+ Parameters:
364
+ ann - ann for wgich parameters needs to be calculated
365
+ data - training data that will be used to calculate scaling parameters
366
+ new_output_min - desired lower bound in input data after scaling (not strictly followed)
367
+ new_output_max - desired upper bound in input data after scaling (not strictly followed)
368
+
369
+ See also:
370
+ <fann_set_input_scaling_params>
371
+
372
+ This function appears in FANN >= 2.1.0
373
+ */
374
+ FANN_EXTERNAL int FANN_API fann_set_output_scaling_params(
375
+ struct fann *ann,
376
+ const struct fann_train_data *data,
377
+ float new_output_min,
378
+ float new_output_max);
379
+
380
+ /* Function: fann_set_scaling_params
381
+
382
+ Calculate input and output scaling parameters for future use based on training data.
383
+
384
+ Parameters:
385
+ ann - ann for wgich parameters needs to be calculated
386
+ data - training data that will be used to calculate scaling parameters
387
+ new_input_min - desired lower bound in input data after scaling (not strictly followed)
388
+ new_input_max - desired upper bound in input data after scaling (not strictly followed)
389
+ new_output_min - desired lower bound in input data after scaling (not strictly followed)
390
+ new_output_max - desired upper bound in input data after scaling (not strictly followed)
391
+
392
+ See also:
393
+ <fann_set_input_scaling_params>, <fann_set_output_scaling_params>
394
+
395
+ This function appears in FANN >= 2.1.0
396
+ */
397
+ FANN_EXTERNAL int FANN_API fann_set_scaling_params(
398
+ struct fann *ann,
399
+ const struct fann_train_data *data,
400
+ float new_input_min,
401
+ float new_input_max,
402
+ float new_output_min,
403
+ float new_output_max);
404
+
405
+ /* Function: fann_clear_scaling_params
406
+
407
+ Clears scaling parameters.
408
+
409
+ Parameters:
410
+ ann - ann for which to clear scaling parameters
411
+
412
+ This function appears in FANN >= 2.1.0
413
+ */
414
+ FANN_EXTERNAL int FANN_API fann_clear_scaling_params(struct fann *ann);
415
+
416
+ /* Function: fann_scale_input
417
+
418
+ Scale data in input vector before feed it to ann based on previously calculated parameters.
419
+
420
+ Parameters:
421
+ ann - for which scaling parameters were calculated
422
+ input_vector - input vector that will be scaled
423
+
424
+ See also:
425
+ <fann_descale_input>, <fann_scale_output>
426
+
427
+ This function appears in FANN >= 2.1.0
428
+ */
429
+ FANN_EXTERNAL void FANN_API fann_scale_input( struct fann *ann, fann_type *input_vector );
430
+
431
+ /* Function: fann_scale_output
432
+
433
+ Scale data in output vector before feed it to ann based on previously calculated parameters.
434
+
435
+ Parameters:
436
+ ann - for which scaling parameters were calculated
437
+ output_vector - output vector that will be scaled
438
+
439
+ See also:
440
+ <fann_descale_output>, <fann_scale_input>
441
+
442
+ This function appears in FANN >= 2.1.0
443
+ */
444
+ FANN_EXTERNAL void FANN_API fann_scale_output( struct fann *ann, fann_type *output_vector );
445
+
446
+ /* Function: fann_descale_input
447
+
448
+ Scale data in input vector after get it from ann based on previously calculated parameters.
449
+
450
+ Parameters:
451
+ ann - for which scaling parameters were calculated
452
+ input_vector - input vector that will be descaled
453
+
454
+ See also:
455
+ <fann_scale_input>, <fann_descale_output>
456
+
457
+ This function appears in FANN >= 2.1.0
458
+ */
459
+ FANN_EXTERNAL void FANN_API fann_descale_input( struct fann *ann, fann_type *input_vector );
460
+
461
+ /* Function: fann_descale_output
462
+
463
+ Scale data in output vector after get it from ann based on previously calculated parameters.
464
+
465
+ Parameters:
466
+ ann - for which scaling parameters were calculated
467
+ output_vector - output vector that will be descaled
468
+
469
+ See also:
470
+ <fann_scale_output>, <fann_descale_input>
471
+
472
+ This function appears in FANN >= 2.1.0
473
+ */
474
+ FANN_EXTERNAL void FANN_API fann_descale_output( struct fann *ann, fann_type *output_vector );
475
+
476
+ #endif
477
+
478
+ /* Function: fann_scale_input_train_data
479
+
480
+ Scales the inputs in the training data to the specified range.
481
+
482
+ See also:
483
+ <fann_scale_output_train_data>, <fann_scale_train_data>
484
+
485
+ This function appears in FANN >= 2.0.0.
486
+ */
487
+ FANN_EXTERNAL void FANN_API fann_scale_input_train_data(struct fann_train_data *train_data,
488
+ fann_type new_min, fann_type new_max);
489
+
490
+
491
+ /* Function: fann_scale_output_train_data
492
+
493
+ Scales the outputs in the training data to the specified range.
494
+
495
+ See also:
496
+ <fann_scale_input_train_data>, <fann_scale_train_data>
497
+
498
+ This function appears in FANN >= 2.0.0.
499
+ */
500
+ FANN_EXTERNAL void FANN_API fann_scale_output_train_data(struct fann_train_data *train_data,
501
+ fann_type new_min, fann_type new_max);
502
+
503
+
504
+ /* Function: fann_scale_train_data
505
+
506
+ Scales the inputs and outputs in the training data to the specified range.
507
+
508
+ See also:
509
+ <fann_scale_output_train_data>, <fann_scale_input_train_data>
510
+
511
+ This function appears in FANN >= 2.0.0.
512
+ */
513
+ FANN_EXTERNAL void FANN_API fann_scale_train_data(struct fann_train_data *train_data,
514
+ fann_type new_min, fann_type new_max);
515
+
516
+
517
+ /* Function: fann_merge_train_data
518
+
519
+ Merges the data from *data1* and *data2* into a new <struct fann_train_data>.
520
+
521
+ This function appears in FANN >= 1.1.0.
522
+ */
523
+ FANN_EXTERNAL struct fann_train_data *FANN_API fann_merge_train_data(struct fann_train_data *data1,
524
+ struct fann_train_data *data2);
525
+
526
+
527
+ /* Function: fann_duplicate_train_data
528
+
529
+ Returns an exact copy of a <struct fann_train_data>.
530
+
531
+ This function appears in FANN >= 1.1.0.
532
+ */
533
+ FANN_EXTERNAL struct fann_train_data *FANN_API fann_duplicate_train_data(struct fann_train_data
534
+ *data);
535
+
536
+ /* Function: fann_subset_train_data
537
+
538
+ Returns an copy of a subset of the <struct fann_train_data>, starting at position *pos*
539
+ and *length* elements forward.
540
+
541
+ >fann_subset_train_data(train_data, 0, fann_length_train_data(train_data))
542
+
543
+ Will do the same as <fann_duplicate_train_data>.
544
+
545
+ See also:
546
+ <fann_length_train_data>
547
+
548
+ This function appears in FANN >= 2.0.0.
549
+ */
550
+ FANN_EXTERNAL struct fann_train_data *FANN_API fann_subset_train_data(struct fann_train_data
551
+ *data, unsigned int pos,
552
+ unsigned int length);
553
+
554
+ /* Function: fann_length_train_data
555
+
556
+ Returns the number of training patterns in the <struct fann_train_data>.
557
+
558
+ This function appears in FANN >= 2.0.0.
559
+ */
560
+ FANN_EXTERNAL unsigned int FANN_API fann_length_train_data(struct fann_train_data *data);
561
+
562
+ /* Function: fann_num_input_train_data
563
+
564
+ Returns the number of inputs in each of the training patterns in the <struct fann_train_data>.
565
+
566
+ See also:
567
+ <fann_num_train_data>, <fann_num_output_train_data>
568
+
569
+ This function appears in FANN >= 2.0.0.
570
+ */
571
+ FANN_EXTERNAL unsigned int FANN_API fann_num_input_train_data(struct fann_train_data *data);
572
+
573
+ /* Function: fann_num_output_train_data
574
+
575
+ Returns the number of outputs in each of the training patterns in the <struct fann_train_data>.
576
+
577
+ See also:
578
+ <fann_num_train_data>, <fann_num_input_train_data>
579
+
580
+ This function appears in FANN >= 2.0.0.
581
+ */
582
+ FANN_EXTERNAL unsigned int FANN_API fann_num_output_train_data(struct fann_train_data *data);
583
+
584
+ /* Function: fann_save_train
585
+
586
+ Save the training structure to a file, with the format as specified in <fann_read_train_from_file>
587
+
588
+ Return:
589
+ The function returns 0 on success and -1 on failure.
590
+
591
+ See also:
592
+ <fann_read_train_from_file>, <fann_save_train_to_fixed>
593
+
594
+ This function appears in FANN >= 1.0.0.
595
+ */
596
+ FANN_EXTERNAL int FANN_API fann_save_train(struct fann_train_data *data, const char *filename);
597
+
598
+
599
+ /* Function: fann_save_train_to_fixed
600
+
601
+ Saves the training structure to a fixed point data file.
602
+
603
+ This function is very usefull for testing the quality of a fixed point network.
604
+
605
+ Return:
606
+ The function returns 0 on success and -1 on failure.
607
+
608
+ See also:
609
+ <fann_save_train>
610
+
611
+ This function appears in FANN >= 1.0.0.
612
+ */
613
+ FANN_EXTERNAL int FANN_API fann_save_train_to_fixed(struct fann_train_data *data, const char *filename,
614
+ unsigned int decimal_point);
615
+
616
+
617
+ /* Group: Parameters */
618
+
619
+ /* Function: fann_get_training_algorithm
620
+
621
+ Return the training algorithm as described by <fann_train_enum>. This training algorithm
622
+ is used by <fann_train_on_data> and associated functions.
623
+
624
+ Note that this algorithm is also used during <fann_cascadetrain_on_data>, although only
625
+ FANN_TRAIN_RPROP and FANN_TRAIN_QUICKPROP is allowed during cascade training.
626
+
627
+ The default training algorithm is FANN_TRAIN_RPROP.
628
+
629
+ See also:
630
+ <fann_set_training_algorithm>, <fann_train_enum>
631
+
632
+ This function appears in FANN >= 1.0.0.
633
+ */
634
+ FANN_EXTERNAL enum fann_train_enum FANN_API fann_get_training_algorithm(struct fann *ann);
635
+
636
+
637
+ /* Function: fann_set_training_algorithm
638
+
639
+ Set the training algorithm.
640
+
641
+ More info available in <fann_get_training_algorithm>
642
+
643
+ This function appears in FANN >= 1.0.0.
644
+ */
645
+ FANN_EXTERNAL void FANN_API fann_set_training_algorithm(struct fann *ann,
646
+ enum fann_train_enum training_algorithm);
647
+
648
+
649
+ /* Function: fann_get_learning_rate
650
+
651
+ Return the learning rate.
652
+
653
+ The learning rate is used to determine how aggressive training should be for some of the
654
+ training algorithms (FANN_TRAIN_INCREMENTAL, FANN_TRAIN_BATCH, FANN_TRAIN_QUICKPROP).
655
+ Do however note that it is not used in FANN_TRAIN_RPROP.
656
+
657
+ The default learning rate is 0.7.
658
+
659
+ See also:
660
+ <fann_set_learning_rate>, <fann_set_training_algorithm>
661
+
662
+ This function appears in FANN >= 1.0.0.
663
+ */
664
+ FANN_EXTERNAL float FANN_API fann_get_learning_rate(struct fann *ann);
665
+
666
+
667
+ /* Function: fann_set_learning_rate
668
+
669
+ Set the learning rate.
670
+
671
+ More info available in <fann_get_learning_rate>
672
+
673
+ This function appears in FANN >= 1.0.0.
674
+ */
675
+ FANN_EXTERNAL void FANN_API fann_set_learning_rate(struct fann *ann, float learning_rate);
676
+
677
+ /* Function: fann_get_learning_momentum
678
+
679
+ Get the learning momentum.
680
+
681
+ The learning momentum can be used to speed up FANN_TRAIN_INCREMENTAL training.
682
+ A too high momentum will however not benefit training. Setting momentum to 0 will
683
+ be the same as not using the momentum parameter. The recommended value of this parameter
684
+ is between 0.0 and 1.0.
685
+
686
+ The default momentum is 0.
687
+
688
+ See also:
689
+ <fann_set_learning_momentum>, <fann_set_training_algorithm>
690
+
691
+ This function appears in FANN >= 2.0.0.
692
+ */
693
+ FANN_EXTERNAL float FANN_API fann_get_learning_momentum(struct fann *ann);
694
+
695
+
696
+ /* Function: fann_set_learning_momentum
697
+
698
+ Set the learning momentum.
699
+
700
+ More info available in <fann_get_learning_momentum>
701
+
702
+ This function appears in FANN >= 2.0.0.
703
+ */
704
+ FANN_EXTERNAL void FANN_API fann_set_learning_momentum(struct fann *ann, float learning_momentum);
705
+
706
+
707
+ /* Function: fann_get_activation_function
708
+
709
+ Get the activation function for neuron number *neuron* in layer number *layer*,
710
+ counting the input layer as layer 0.
711
+
712
+ It is not possible to get activation functions for the neurons in the input layer.
713
+
714
+ Information about the individual activation functions is available at <fann_activationfunc_enum>.
715
+
716
+ Returns:
717
+ The activation function for the neuron or -1 if the neuron is not defined in the neural network.
718
+
719
+ See also:
720
+ <fann_set_activation_function_layer>, <fann_set_activation_function_hidden>,
721
+ <fann_set_activation_function_output>, <fann_set_activation_steepness>,
722
+ <fann_set_activation_function>
723
+
724
+ This function appears in FANN >= 2.1.0
725
+ */
726
+ FANN_EXTERNAL enum fann_activationfunc_enum FANN_API fann_get_activation_function(struct fann *ann,
727
+ int layer,
728
+ int neuron);
729
+
730
+ /* Function: fann_set_activation_function
731
+
732
+ Set the activation function for neuron number *neuron* in layer number *layer*,
733
+ counting the input layer as layer 0.
734
+
735
+ It is not possible to set activation functions for the neurons in the input layer.
736
+
737
+ When choosing an activation function it is important to note that the activation
738
+ functions have different range. FANN_SIGMOID is e.g. in the 0 - 1 range while
739
+ FANN_SIGMOID_SYMMETRIC is in the -1 - 1 range and FANN_LINEAR is unbound.
740
+
741
+ Information about the individual activation functions is available at <fann_activationfunc_enum>.
742
+
743
+ The default activation function is FANN_SIGMOID_STEPWISE.
744
+
745
+ See also:
746
+ <fann_set_activation_function_layer>, <fann_set_activation_function_hidden>,
747
+ <fann_set_activation_function_output>, <fann_set_activation_steepness>,
748
+ <fann_get_activation_function>
749
+
750
+ This function appears in FANN >= 2.0.0.
751
+ */
752
+ FANN_EXTERNAL void FANN_API fann_set_activation_function(struct fann *ann,
753
+ enum fann_activationfunc_enum
754
+ activation_function,
755
+ int layer,
756
+ int neuron);
757
+
758
+ /* Function: fann_set_activation_function_layer
759
+
760
+ Set the activation function for all the neurons in the layer number *layer*,
761
+ counting the input layer as layer 0.
762
+
763
+ It is not possible to set activation functions for the neurons in the input layer.
764
+
765
+ See also:
766
+ <fann_set_activation_function>, <fann_set_activation_function_hidden>,
767
+ <fann_set_activation_function_output>, <fann_set_activation_steepness_layer>
768
+
769
+ This function appears in FANN >= 2.0.0.
770
+ */
771
+ FANN_EXTERNAL void FANN_API fann_set_activation_function_layer(struct fann *ann,
772
+ enum fann_activationfunc_enum
773
+ activation_function,
774
+ int layer);
775
+
776
+ /* Function: fann_set_activation_function_hidden
777
+
778
+ Set the activation function for all of the hidden layers.
779
+
780
+ See also:
781
+ <fann_set_activation_function>, <fann_set_activation_function_layer>,
782
+ <fann_set_activation_function_output>, <fann_set_activation_steepness_hidden>
783
+
784
+ This function appears in FANN >= 1.0.0.
785
+ */
786
+ FANN_EXTERNAL void FANN_API fann_set_activation_function_hidden(struct fann *ann,
787
+ enum fann_activationfunc_enum
788
+ activation_function);
789
+
790
+
791
+ /* Function: fann_set_activation_function_output
792
+
793
+ Set the activation function for the output layer.
794
+
795
+ See also:
796
+ <fann_set_activation_function>, <fann_set_activation_function_layer>,
797
+ <fann_set_activation_function_hidden>, <fann_set_activation_steepness_output>
798
+
799
+ This function appears in FANN >= 1.0.0.
800
+ */
801
+ FANN_EXTERNAL void FANN_API fann_set_activation_function_output(struct fann *ann,
802
+ enum fann_activationfunc_enum
803
+ activation_function);
804
+
805
+ /* Function: fann_get_activation_steepness
806
+
807
+ Get the activation steepness for neuron number *neuron* in layer number *layer*,
808
+ counting the input layer as layer 0.
809
+
810
+ It is not possible to get activation steepness for the neurons in the input layer.
811
+
812
+ The steepness of an activation function says something about how fast the activation function
813
+ goes from the minimum to the maximum. A high value for the activation function will also
814
+ give a more agressive training.
815
+
816
+ When training neural networks where the output values should be at the extremes (usually 0 and 1,
817
+ depending on the activation function), a steep activation function can be used (e.g. 1.0).
818
+
819
+ The default activation steepness is 0.5.
820
+
821
+ Returns:
822
+ The activation steepness for the neuron or -1 if the neuron is not defined in the neural network.
823
+
824
+ See also:
825
+ <fann_set_activation_steepness_layer>, <fann_set_activation_steepness_hidden>,
826
+ <fann_set_activation_steepness_output>, <fann_set_activation_function>,
827
+ <fann_set_activation_steepness>
828
+
829
+ This function appears in FANN >= 2.1.0
830
+ */
831
+ FANN_EXTERNAL fann_type FANN_API fann_get_activation_steepness(struct fann *ann,
832
+ int layer,
833
+ int neuron);
834
+
835
+ /* Function: fann_set_activation_steepness
836
+
837
+ Set the activation steepness for neuron number *neuron* in layer number *layer*,
838
+ counting the input layer as layer 0.
839
+
840
+ It is not possible to set activation steepness for the neurons in the input layer.
841
+
842
+ The steepness of an activation function says something about how fast the activation function
843
+ goes from the minimum to the maximum. A high value for the activation function will also
844
+ give a more agressive training.
845
+
846
+ When training neural networks where the output values should be at the extremes (usually 0 and 1,
847
+ depending on the activation function), a steep activation function can be used (e.g. 1.0).
848
+
849
+ The default activation steepness is 0.5.
850
+
851
+ See also:
852
+ <fann_set_activation_steepness_layer>, <fann_set_activation_steepness_hidden>,
853
+ <fann_set_activation_steepness_output>, <fann_set_activation_function>,
854
+ <fann_get_activation_steepness>
855
+
856
+ This function appears in FANN >= 2.0.0.
857
+ */
858
+ FANN_EXTERNAL void FANN_API fann_set_activation_steepness(struct fann *ann,
859
+ fann_type steepness,
860
+ int layer,
861
+ int neuron);
862
+
863
+ /* Function: fann_set_activation_steepness_layer
864
+
865
+ Set the activation steepness all of the neurons in layer number *layer*,
866
+ counting the input layer as layer 0.
867
+
868
+ It is not possible to set activation steepness for the neurons in the input layer.
869
+
870
+ See also:
871
+ <fann_set_activation_steepness>, <fann_set_activation_steepness_hidden>,
872
+ <fann_set_activation_steepness_output>, <fann_set_activation_function_layer>
873
+
874
+ This function appears in FANN >= 2.0.0.
875
+ */
876
+ FANN_EXTERNAL void FANN_API fann_set_activation_steepness_layer(struct fann *ann,
877
+ fann_type steepness,
878
+ int layer);
879
+
880
+ /* Function: fann_set_activation_steepness_hidden
881
+
882
+ Set the steepness of the activation steepness in all of the hidden layers.
883
+
884
+ See also:
885
+ <fann_set_activation_steepness>, <fann_set_activation_steepness_layer>,
886
+ <fann_set_activation_steepness_output>, <fann_set_activation_function_hidden>
887
+
888
+ This function appears in FANN >= 1.2.0.
889
+ */
890
+ FANN_EXTERNAL void FANN_API fann_set_activation_steepness_hidden(struct fann *ann,
891
+ fann_type steepness);
892
+
893
+
894
+ /* Function: fann_set_activation_steepness_output
895
+
896
+ Set the steepness of the activation steepness in the output layer.
897
+
898
+ See also:
899
+ <fann_set_activation_steepness>, <fann_set_activation_steepness_layer>,
900
+ <fann_set_activation_steepness_hidden>, <fann_set_activation_function_output>
901
+
902
+ This function appears in FANN >= 1.2.0.
903
+ */
904
+ FANN_EXTERNAL void FANN_API fann_set_activation_steepness_output(struct fann *ann,
905
+ fann_type steepness);
906
+
907
+
908
+ /* Function: fann_get_train_error_function
909
+
910
+ Returns the error function used during training.
911
+
912
+ The error functions is described further in <fann_errorfunc_enum>
913
+
914
+ The default error function is FANN_ERRORFUNC_TANH
915
+
916
+ See also:
917
+ <fann_set_train_error_function>
918
+
919
+ This function appears in FANN >= 1.2.0.
920
+ */
921
+ FANN_EXTERNAL enum fann_errorfunc_enum FANN_API fann_get_train_error_function(struct fann *ann);
922
+
923
+
924
+ /* Function: fann_set_train_error_function
925
+
926
+ Set the error function used during training.
927
+
928
+ The error functions is described further in <fann_errorfunc_enum>
929
+
930
+ See also:
931
+ <fann_get_train_error_function>
932
+
933
+ This function appears in FANN >= 1.2.0.
934
+ */
935
+ FANN_EXTERNAL void FANN_API fann_set_train_error_function(struct fann *ann,
936
+ enum fann_errorfunc_enum
937
+ train_error_function);
938
+
939
+
940
+ /* Function: fann_get_train_stop_function
941
+
942
+ Returns the the stop function used during training.
943
+
944
+ The stop function is described further in <fann_stopfunc_enum>
945
+
946
+ The default stop function is FANN_STOPFUNC_MSE
947
+
948
+ See also:
949
+ <fann_get_train_stop_function>, <fann_get_bit_fail_limit>
950
+
951
+ This function appears in FANN >= 2.0.0.
952
+ */
953
+ FANN_EXTERNAL enum fann_stopfunc_enum FANN_API fann_get_train_stop_function(struct fann *ann);
954
+
955
+
956
+ /* Function: fann_set_train_stop_function
957
+
958
+ Set the stop function used during training.
959
+
960
+ Returns the the stop function used during training.
961
+
962
+ The stop function is described further in <fann_stopfunc_enum>
963
+
964
+ See also:
965
+ <fann_get_train_stop_function>
966
+
967
+ This function appears in FANN >= 2.0.0.
968
+ */
969
+ FANN_EXTERNAL void FANN_API fann_set_train_stop_function(struct fann *ann,
970
+ enum fann_stopfunc_enum train_stop_function);
971
+
972
+
973
+ /* Function: fann_get_bit_fail_limit
974
+
975
+ Returns the bit fail limit used during training.
976
+
977
+ The bit fail limit is used during training where the <fann_stopfunc_enum> is set to FANN_STOPFUNC_BIT.
978
+
979
+ The limit is the maximum accepted difference between the desired output and the actual output during
980
+ training. Each output that diverges more than this limit is counted as an error bit.
981
+ This difference is divided by two when dealing with symmetric activation functions,
982
+ so that symmetric and not symmetric activation functions can use the same limit.
983
+
984
+ The default bit fail limit is 0.35.
985
+
986
+ See also:
987
+ <fann_set_bit_fail_limit>
988
+
989
+ This function appears in FANN >= 2.0.0.
990
+ */
991
+ FANN_EXTERNAL fann_type FANN_API fann_get_bit_fail_limit(struct fann *ann);
992
+
993
+ /* Function: fann_set_bit_fail_limit
994
+
995
+ Set the bit fail limit used during training.
996
+
997
+ See also:
998
+ <fann_get_bit_fail_limit>
999
+
1000
+ This function appears in FANN >= 2.0.0.
1001
+ */
1002
+ FANN_EXTERNAL void FANN_API fann_set_bit_fail_limit(struct fann *ann, fann_type bit_fail_limit);
1003
+
1004
+ /* Function: fann_set_callback
1005
+
1006
+ Sets the callback function for use during training.
1007
+
1008
+ See <fann_callback_type> for more information about the callback function.
1009
+
1010
+ The default callback function simply prints out some status information.
1011
+
1012
+ This function appears in FANN >= 2.0.0.
1013
+ */
1014
+ FANN_EXTERNAL void FANN_API fann_set_callback(struct fann *ann, fann_callback_type callback);
1015
+
1016
+ /* Function: fann_get_quickprop_decay
1017
+
1018
+ The decay is a small negative valued number which is the factor that the weights
1019
+ should become smaller in each iteration during quickprop training. This is used
1020
+ to make sure that the weights do not become too high during training.
1021
+
1022
+ The default decay is -0.0001.
1023
+
1024
+ See also:
1025
+ <fann_set_quickprop_decay>
1026
+
1027
+ This function appears in FANN >= 1.2.0.
1028
+ */
1029
+ FANN_EXTERNAL float FANN_API fann_get_quickprop_decay(struct fann *ann);
1030
+
1031
+
1032
+ /* Function: fann_set_quickprop_decay
1033
+
1034
+ Sets the quickprop decay factor.
1035
+
1036
+ See also:
1037
+ <fann_get_quickprop_decay>
1038
+
1039
+ This function appears in FANN >= 1.2.0.
1040
+ */
1041
+ FANN_EXTERNAL void FANN_API fann_set_quickprop_decay(struct fann *ann, float quickprop_decay);
1042
+
1043
+
1044
+ /* Function: fann_get_quickprop_mu
1045
+
1046
+ The mu factor is used to increase and decrease the step-size during quickprop training.
1047
+ The mu factor should always be above 1, since it would otherwise decrease the step-size
1048
+ when it was suppose to increase it.
1049
+
1050
+ The default mu factor is 1.75.
1051
+
1052
+ See also:
1053
+ <fann_set_quickprop_mu>
1054
+
1055
+ This function appears in FANN >= 1.2.0.
1056
+ */
1057
+ FANN_EXTERNAL float FANN_API fann_get_quickprop_mu(struct fann *ann);
1058
+
1059
+
1060
+ /* Function: fann_set_quickprop_mu
1061
+
1062
+ Sets the quickprop mu factor.
1063
+
1064
+ See also:
1065
+ <fann_get_quickprop_mu>
1066
+
1067
+ This function appears in FANN >= 1.2.0.
1068
+ */
1069
+ FANN_EXTERNAL void FANN_API fann_set_quickprop_mu(struct fann *ann, float quickprop_mu);
1070
+
1071
+
1072
+ /* Function: fann_get_rprop_increase_factor
1073
+
1074
+ The increase factor is a value larger than 1, which is used to
1075
+ increase the step-size during RPROP training.
1076
+
1077
+ The default increase factor is 1.2.
1078
+
1079
+ See also:
1080
+ <fann_set_rprop_increase_factor>
1081
+
1082
+ This function appears in FANN >= 1.2.0.
1083
+ */
1084
+ FANN_EXTERNAL float FANN_API fann_get_rprop_increase_factor(struct fann *ann);
1085
+
1086
+
1087
+ /* Function: fann_set_rprop_increase_factor
1088
+
1089
+ The increase factor used during RPROP training.
1090
+
1091
+ See also:
1092
+ <fann_get_rprop_increase_factor>
1093
+
1094
+ This function appears in FANN >= 1.2.0.
1095
+ */
1096
+ FANN_EXTERNAL void FANN_API fann_set_rprop_increase_factor(struct fann *ann,
1097
+ float rprop_increase_factor);
1098
+
1099
+
1100
+ /* Function: fann_get_rprop_decrease_factor
1101
+
1102
+ The decrease factor is a value smaller than 1, which is used to decrease the step-size during RPROP training.
1103
+
1104
+ The default decrease factor is 0.5.
1105
+
1106
+ See also:
1107
+ <fann_set_rprop_decrease_factor>
1108
+
1109
+ This function appears in FANN >= 1.2.0.
1110
+ */
1111
+ FANN_EXTERNAL float FANN_API fann_get_rprop_decrease_factor(struct fann *ann);
1112
+
1113
+
1114
+ /* Function: fann_set_rprop_decrease_factor
1115
+
1116
+ The decrease factor is a value smaller than 1, which is used to decrease the step-size during RPROP training.
1117
+
1118
+ See also:
1119
+ <fann_get_rprop_decrease_factor>
1120
+
1121
+ This function appears in FANN >= 1.2.0.
1122
+ */
1123
+ FANN_EXTERNAL void FANN_API fann_set_rprop_decrease_factor(struct fann *ann,
1124
+ float rprop_decrease_factor);
1125
+
1126
+
1127
+ /* Function: fann_get_rprop_delta_min
1128
+
1129
+ The minimum step-size is a small positive number determining how small the minimum step-size may be.
1130
+
1131
+ The default value delta min is 0.0.
1132
+
1133
+ See also:
1134
+ <fann_set_rprop_delta_min>
1135
+
1136
+ This function appears in FANN >= 1.2.0.
1137
+ */
1138
+ FANN_EXTERNAL float FANN_API fann_get_rprop_delta_min(struct fann *ann);
1139
+
1140
+
1141
+ /* Function: fann_set_rprop_delta_min
1142
+
1143
+ The minimum step-size is a small positive number determining how small the minimum step-size may be.
1144
+
1145
+ See also:
1146
+ <fann_get_rprop_delta_min>
1147
+
1148
+ This function appears in FANN >= 1.2.0.
1149
+ */
1150
+ FANN_EXTERNAL void FANN_API fann_set_rprop_delta_min(struct fann *ann, float rprop_delta_min);
1151
+
1152
+
1153
+ /* Function: fann_get_rprop_delta_max
1154
+
1155
+ The maximum step-size is a positive number determining how large the maximum step-size may be.
1156
+
1157
+ The default delta max is 50.0.
1158
+
1159
+ See also:
1160
+ <fann_set_rprop_delta_max>, <fann_get_rprop_delta_min>
1161
+
1162
+ This function appears in FANN >= 1.2.0.
1163
+ */
1164
+ FANN_EXTERNAL float FANN_API fann_get_rprop_delta_max(struct fann *ann);
1165
+
1166
+
1167
+ /* Function: fann_set_rprop_delta_max
1168
+
1169
+ The maximum step-size is a positive number determining how large the maximum step-size may be.
1170
+
1171
+ See also:
1172
+ <fann_get_rprop_delta_max>, <fann_get_rprop_delta_min>
1173
+
1174
+ This function appears in FANN >= 1.2.0.
1175
+ */
1176
+ FANN_EXTERNAL void FANN_API fann_set_rprop_delta_max(struct fann *ann, float rprop_delta_max);
1177
+
1178
+ /* Function: fann_get_rprop_delta_zero
1179
+
1180
+ The initial step-size is a positive number determining the initial step size.
1181
+
1182
+ The default delta zero is 0.1.
1183
+
1184
+ See also:
1185
+ <fann_set_rprop_delta_zero>, <fann_get_rprop_delta_min>, <fann_get_rprop_delta_max>
1186
+
1187
+ This function appears in FANN >= 2.1.0.
1188
+ */
1189
+ FANN_EXTERNAL float FANN_API fann_get_rprop_delta_zero(struct fann *ann);
1190
+
1191
+
1192
+ /* Function: fann_set_rprop_delta_zero
1193
+
1194
+ The initial step-size is a positive number determining the initial step size.
1195
+
1196
+ See also:
1197
+ <fann_get_rprop_delta_zero>, <fann_get_rprop_delta_zero>
1198
+
1199
+ This function appears in FANN >= 2.1.0.
1200
+ */
1201
+ FANN_EXTERNAL void FANN_API fann_set_rprop_delta_zero(struct fann *ann, float rprop_delta_max);
1202
+
1203
+ #endif