-
Notifications
You must be signed in to change notification settings - Fork 0
/
FileSelect.h
2901 lines (2593 loc) · 80.3 KB
/
FileSelect.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# data file for the Fltk User Interface Designer (fluid)
version 1.0300
header_name {.h}
code_name {.cpp}
comment {//
// FannTool, GUI tool for ANN by using FANN library
// Programmed by BlueKid
// http://derindelimavi.blogspot.com/
// Send me any suggestion, modification or bugs.
// Don't hesitate to contact me for any question,
// I will be very grateful with your feedbacks.
// Copyright (C) 2008 BlueKid
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
} {in_source in_header
}
decl {\#include <string>} {public local
}
decl {\#include <math.h>} {public local
}
decl {\#include <deque>} {public local
}
decl {\#include "Fl_PlotXY.H"} {public local
}
decl {\#include "DataProcess.h"} {public local
}
decl {\#include <FL/fl_ask.H>} {public local
}
decl {\#include <FL/Fl_File_Chooser.H>} {public local
}
decl {\#include <FL/Fl_Native_File_Chooser.H>} {public local
}
decl {\#include <FL/Fl_Float_Input.H>} {public local
}
decl {\#include <FL/Fl_Chart.H>} {public local
}
decl {\#include <FL/filename.H>} {public local
}
decl {\#include <stdio.h>} {public local
}
decl {\#include <fann.h>} {public local
}
declblock {\#ifdef WIN32} {after {\#endif}
} {
decl {\#include "fanntoolrc.h"} {private local
}
decl {extern HINSTANCE fl_display;} {private local
}
decl {\#elif !defined(__APPLE__)} {private local
}
decl {\#include <X11/xpm.h>} {private local
}
decl {\#include "fanntool_icon.xpm"} {private local
}
decl {extern Display *fl_display;} {private local
}
}
decl {int Act[13]={
FANN_LINEAR,
FANN_SIGMOID,
FANN_SIGMOID_STEPWISE,
FANN_SIGMOID_SYMMETRIC,
FANN_SIGMOID_SYMMETRIC_STEPWISE,
FANN_GAUSSIAN,
FANN_GAUSSIAN_SYMMETRIC,
FANN_ELLIOT,
FANN_ELLIOT_SYMMETRIC,
FANN_LINEAR_PIECE,
FANN_LINEAR_PIECE_SYMMETRIC,
FANN_SIN_SYMMETRIC,
FANN_COS_SYMMETRIC
};} {private local
}
decl {int Line;} {private local
}
comment {MinMSE and MinANN
Min Training MSE
Min Testing MSE
Min OPS MSE
Latest MSE
both Training and Testing MSE
} {in_source not_in_header
}
decl {struct fann* MinANN[4];} {private local
}
decl {double MinTrainingMSE[4];} {private local
}
decl {double MinTestingMSE[4];} {private local
}
decl {FannTool ft;} {private local
}
decl {bool cascadeFirst;} {private local
}
decl {DataProcess *rdp;} {private local
}
decl {TimeSeri *tdp;} {private local
}
decl {DataItem *itmp;} {private local
}
decl {std::deque<float> cX;} {private local
}
decl {std::deque<float> cY;} {private local
}
decl {char fNameBuf[2048];} {private local
}
decl {enum SelectType {Open,Save};} {public global
}
decl {enum FileType {Data,Log,RawData,Network};} {public global
}
Function {} {} {
code {splashScreen(600);} {}
Fl_Window window_main {
label {FANN Tool 1.2} open
xywh {310 33 775 684} type Double box PLASTIC_DOWN_BOX color 21 labelcolor 1 align 80 resizable
code0 {Fl::visual(FL_DOUBLE|FL_INDEX);}
code1 {if((window_main->w()> Fl::w())||(window_main->h()> Fl::h())){ window_main->resizable(window_main); window_main->resize(window_main->x(),window_main->y(),Fl::w(),Fl::h());}}
code2 {window_main->callback(Exit_CB);} visible
} {
Fl_Menu_Bar {} {
xywh {0 0 777 35} box GTK_UP_BOX color 29
} {
Submenu {} {
label File
xywh {0 0 62 20}
} {
MenuItem {} {
label {Open Training Data}
callback {ft.LoadTrainData();}
xywh {0 0 30 20}
}
MenuItem {} {
label {Open Test Data}
callback {ft.LoadTestData();}
xywh {10 10 30 20}
}
MenuItem {} {
label {Open Log}
callback {ft.LoadLog();}
xywh {0 0 30 20}
}
MenuItem {} {
label {Save Log}
callback {ft.SaveLog();}
xywh {10 10 30 20}
}
MenuItem {} {
label {Clear Log}
callback {ft.ClearLog();}
xywh {20 20 30 20}
}
MenuItem {} {
label Exit
callback {Exit_CB(0,0);
//exit(0);}
xywh {30 30 30 20}
}
}
Submenu {} {
label {Neural Network}
xywh {0 0 62 20}
} {
Submenu {} {
label Detect
xywh {0 0 62 20}
} {
MenuItem {} {
label {Optimum Training Algorithm}
callback {ft.OptimumAlgorithm();}
xywh {10 10 30 20}
}
MenuItem {} {
label {Optimum Activation Functions}
callback {ft.OptimumActivations();}
xywh {20 20 30 20}
}
}
Submenu {} {
label Train
xywh {0 0 62 20}
} {
MenuItem {} {
label Normal
callback {ft.TrainNormal();}
xywh {0 0 30 20}
}
MenuItem {} {
label Cascade
callback {ft.TrainCascade();}
xywh {10 10 30 20}
}
}
MenuItem {} {
label Test
callback {ft.Test();}
xywh {10 10 30 20}
}
Submenu {} {
label Run
xywh {10 10 62 20}
} {
MenuItem {} {
label Normal
callback {ft.RunNormal();}
xywh {10 10 30 20}
}
MenuItem {} {
label {with File}
callback {ft.RunwithFile();}
xywh {20 20 30 20}
}
MenuItem {} {
label {as a Time Series}
callback {ft.RunAsTS();}
xywh {30 30 30 20}
}
MenuItem {} {
label {as a Classifier}
callback {ft.RunAsClassifier();}
xywh {40 40 30 20}
}
}
MenuItem {} {
label Info
callback {ft.NeuralNetworkInfo();}
xywh {20 20 30 20}
}
}
MenuItem {} {
label {Data Processing}
callback {ft.DataProcessing();}
xywh {0 0 30 20}
}
Submenu {} {
label Help
xywh {5 5 62 20}
} {
MenuItem {} {
label {About FannTool}
callback {ft.About();}
xywh {0 0 30 20}
}
}
}
Fl_Group {} {open
xywh {5 91 765 229}
} {
Fl_Group {} {
xywh {145 106 595 60}
} {
Fl_Input DataFile {
label {Training Data File }
xywh {145 108 420 23}
}
Fl_Input TestFile {
label {Test Data File }
xywh {145 143 420 23}
}
Fl_Repeat_Button {} {
label {...}
callback {// GetTrainData
ft.LoadTrainData();}
xywh {575 106 20 25} box PLASTIC_UP_BOX color 4 labeltype ENGRAVED_LABEL
}
Fl_Repeat_Button {} {
label {...}
callback {// GetTestData
ft.LoadTestData();}
xywh {575 141 20 25} box PLASTIC_UP_BOX color 4 labeltype ENGRAVED_LABEL
}
Fl_Value_Output Input {
label {Input dim.:}
xywh {690 107 50 24}
}
Fl_Value_Output Output {
label {Output dim.:}
xywh {690 142 50 24}
}
}
Fl_Group {} {open
xywh {293 181 477 129}
} {
Fl_Spinner Layer {
label {\# of Layers}
callback {if(Layer->value()==3){
Hid2->deactivate();
Hid3->deactivate();
}
else if(Layer->value()==4){
Hid2->activate();
Hid3->deactivate();
}
else if(Layer->value()==5){
Hid2->activate();
Hid3->activate();
}
SetHiddens();}
xywh {293 182 37 24} color 7 when 1
code0 {o->value(3);}
code1 {o->maximum(5);}
code2 {o->minimum(3);}
}
Fl_Spinner Hid1 {
label {Hid. Layer 1 :}
xywh {432 182 45 24} maximum 999
code0 {o->value(0);}
}
Fl_Spinner Hid2 {
label {Hid. Layer 2 :}
xywh {575 182 45 24} maximum 999 deactivate
code0 {o->value(0);}
}
Fl_Spinner Hid3 {
label {Hid. Layer 3 :}
xywh {715 182 45 24} maximum 999 deactivate
code0 {o->value(0);}
}
Fl_Choice Method {
label {Training Method :} open
xywh {430 215 320 25} down_box BORDER_BOX
code0 {FillMethods();}
code1 {o->value(2);}
} {}
Fl_Choice HiddenActivationF {
label {Activation Function (Hidden) :} open
xywh {430 250 320 25} down_box BORDER_BOX
} {}
Fl_Choice OutputActivationF {
label {Activation Function (Output) :} open
xywh {430 285 320 25} down_box BORDER_BOX
code0 {FillActivationF();}
code1 {o->value(3);}
code2 {HiddenActivationF->value(3);}
} {}
}
Fl_Group {} {
xywh {10 176 205 144} box EMBOSSED_FRAME align 0
} {
Fl_Choice StopFunction {
label {Stop Function} open
xywh {20 196 190 22} down_box BORDER_BOX align 5
code0 {StopFunction->add("FANN_STOPFUNC_MSE");}
code1 {StopFunction->add("FANN_STOPFUNC_BIT");}
code2 {StopFunction->value(0);}
} {}
Fl_Value_Input EReports {
label {Epochs Between Reports}
xywh {20 242 55 23} align 5 minimum 1 maximum 50000 step 10 value 1000
}
Fl_Value_Input MaxEpoch {
label {Max \# of Epochs : }
callback {/*
if(MaxEpoch->value()>=1000)
MaxEpoch->step(100);
if(MaxEpoch->value()>=10000)
MaxEpoch->step(1000);
if(MaxEpoch->value()>=100000)
MaxEpoch->step(10000);
*/}
xywh {20 286 60 24} align 5 minimum 1000 maximum 1e+006 step 1000 value 500000
}
}
}
Fl_Tabs Tabs {
xywh {0 324 776 381} box GTK_UP_FRAME color 21
code0 {o->value(LogG);}
} {
Fl_Group LogG {
label Log open
xywh {5 367 760 338}
} {
Fl_Browser Out {
xywh {10 372 755 301} type Hold box GTK_DOWN_BOX color 31 labelcolor 2
}
}
Fl_Group GraphG {
label Graphic open
xywh {1 365 775 340} hide
} {
Fl_Box Graph {
tooltip {MSE vs Epoch} xywh {11 371 746 273} box GTK_DOWN_BOX color 16
code0 {Line=Graph->newline();}
code1 {Graph->scalemode(Line,FL_PLOTXY_AUTO);}
code2 {Graph->linecolor(Line,FL_BLUE);}
class Fl_PlotXY
}
Fl_Value_Output Ep {
label {Epoch :}
xywh {63 651 60 24} labelcolor 4
}
Fl_Value_Output Mse {
label {MSE :}
xywh {174 651 110 24} labelcolor 4
}
Fl_Spinner nVData {
label {\# of Visible Data :}
xywh {712 651 48 24} labelcolor 4 minimum 20 maximum 500 value 500
}
Fl_Value_Output BitFailOut {
label {Bit Fail :}
xywh {549 651 44 24} labelcolor 4
}
Fl_Value_Output TestMse {
label {Test MSE :}
tooltip {Test Data MSE} xywh {375 651 110 24} labelcolor 1 deactivate
}
}
Fl_Group {} {
label {Fine Tuning} open
xywh {10 370 755 335} hide
} {
Fl_Value_Input DesiredError {
label {Desired Error (MSE) :}
xywh {169 401 72 24} maximum 0.1 step 1e-005 value 0.0001
}
Fl_Value_Input BitFail {
label {Bit Fail Limit :}
xywh {170 439 72 24} maximum 0.1 step 1e-005 value 0.035
}
Fl_Choice ErrorFunction {
label {Error Function} open
xywh {331 398 225 24} down_box BORDER_BOX align 5
code0 {ErrorFunction->add("FANN_ERRORFUNC_LINEAR");}
code1 {ErrorFunction->add("FANN_ERRORFUNC_TANH");}
code2 {ErrorFunction->value(0);}
} {}
Fl_Value_Input HiddenStepness {
label {Hidden Activation Steepness }
xywh {335 443 67 22} align 5 maximum 0 value 0.5
}
Fl_Value_Input OutputStepness {
label {Output Activation Steepness }
xywh {335 491 67 24} align 5 maximum 0 value 0.5
}
Fl_Value_Input DecayFactor {
label {Quickprop Decay Factor}
xywh {584 398 67 24} align 5 minimum -0.2 maximum 0 value -0.0001
}
Fl_Value_Input MuFactor {
label {Quickprop Mu Factor}
xywh {584 441 70 24} align 5 minimum 1 maximum 3 value 1.75
}
Fl_Value_Input IncreaseFactor {
label {RPROP Increase Factor }
xywh {584 491 70 24} align 5 minimum 1 maximum 3 value 1.2
}
Fl_Value_Input DecreaseFactor {
label {RPROP Decrease Factor }
xywh {584 541 70 24} align 5 value 0.5
}
Fl_Value_Input DeltaMin {
label {RPROP Minimum Step-Size}
xywh {584 596 70 24} align 5 maximum 3
}
Fl_Value_Input DeltaMax {
label {RPROP Maximum Step-Size}
xywh {584 646 70 24} align 5 minimum 1 maximum 100 value 50
}
Fl_Counter ConnectionRate {
label {Connection Rate}
xywh {135 489 142 24} align 4 minimum 0.1 maximum 1 value 1
}
Fl_Counter Momentum {
label {Momentum :}
xywh {415 526 140 25} align 4 minimum 0 maximum 1
}
Fl_Check_Button Shuffle {
label {Shuffle Train Data}
xywh {453 556 26 25} down_box DOWN_BOX align 4
}
Fl_Check_Button InitWghts {
label {Initialize the weights ( Widrow + Nguyen Alg.)}
xywh {300 557 19 24} down_box DOWN_BOX align 4
}
Fl_Check_Button OverTraining {
label {Overtraining Caution System}
callback {if(OverTraining->value()){
ft.overtraining=true;
TestMse->activate();
}
else{
ft.overtraining=false;
TestMse->value(0);
TestMse->deactivate();
}}
xywh {300 591 19 24} down_box DOWN_BOX align 4 deactivate
}
Fl_Spinner LearningRate {
label {Learning Rate}
xywh {140 526 80 24} type Float minimum 0.001 maximum 1 step 0.1 value 0.7
}
}
Fl_Group {} {
label {Cascade Tuning}
xywh {7 370 750 335} hide
} {
Fl_Value_Input OutputChange {
label {Output Change Fraction:}
xywh {51 476 93 24} align 5 value 0.01
}
Fl_Value_Input OutputStag {
label {Output Stagnation Epochs}
xywh {51 526 93 24} align 5 maximum 0 value 12
}
Fl_Value_Input CandidateChange {
label {Candidate Change Fraction:}
xywh {51 576 93 24} align 5 value 0.01
}
Fl_Value_Input CandidateStag {
label {Candidate Stagnation Epochs}
xywh {51 626 93 24} align 5 maximum 0 value 12
}
Fl_Value_Input WeighMultiplier {
label {Weight Multiplier}
xywh {301 421 93 24} align 5 value 0.4
}
Fl_Value_Input CandidateLimit {
label {Candidate Limit}
xywh {301 471 93 24} align 5 maximum 2000 value 1000
}
Fl_Value_Input MaxOutEpoch {
label {Maximum Out Epochs}
xywh {301 521 93 24} align 5 maximum 500 value 150
}
Fl_Value_Input MaxCasndidatetEpoch {
label {Maximum Candidate Epochs}
xywh {301 571 93 24} align 5 maximum 500 value 150
}
Fl_Value_Input NumCandidateGroups {
label {Number of Candidate Groups}
xywh {301 616 93 24} align 5 maximum 0 value 2
}
Fl_Value_Input MaxCascade {
label {Maximum Number of Neurons}
xywh {51 426 93 24} align 5 minimum 1 maximum 0 value 10
}
}
}
Fl_Group {} {open
xywh {10 42 494 56} box EMBOSSED_FRAME
} {
Fl_Button But_Alg {
callback {ft.OptimumAlgorithm();}
tooltip {Detect Optimum Training Algorithm} image {img/alg.png} xywh {20 56 32 32} box PLASTIC_UP_BOX down_box FLAT_BOX color 4 align 128 deactivate
code0 {InactImg(o);}
}
Fl_Button But_Act {
callback {ft.OptimumActivations();}
tooltip {Detect Optimum Activation Functions} image {img/act.png} xywh {60 56 32 32} box PLASTIC_UP_BOX color 4 align 128 deactivate
code0 {InactImg(o);}
}
Fl_Menu_Button But_Trn {
callback {if(But_Trn->value()==0)
ft.TrainNormal();
else if(But_Trn->value()==1)
ft.TrainCascade();} open
tooltip {Train ANN} image {img/train.png} xywh {100 56 32 32} box PLASTIC_UP_BOX color 4 deactivate
code0 {o->add("Normal");}
code1 {o->add("Cascade");}
code2 {InactImg(o);}
} {}
Fl_Button But_Test {
callback {ft.Test();}
tooltip {Test ANN} image {img/test.png} xywh {140 56 32 32} box PLASTIC_UP_BOX color 4 align 128 deactivate
code0 {InactImg(o);}
}
Fl_Menu_Button But_Run {
callback {if(But_Run->value()==0)
ft.RunNormal();
else if(But_Run->value()==1)
ft.RunwithFile();
else if(But_Run->value()==2)
ft.RunAsTS();
else
ft.RunAsClassifier();}
tooltip {Run ANN} image {img/Run.png} xywh {180 56 32 32} box PLASTIC_UP_BOX color 4
code0 {o->add("Normal");}
code1 {o->add("with File");o->add("As a Time Series");o->add("As a Classifier");}
code2 {InactImg(o);}
} {}
Fl_Button {} {
callback {ft.ClearLog();}
tooltip {Clear Log} image {img/clear.png} xywh {220 56 32 32} box PLASTIC_UP_BOX color 4 align 128
code0 {InactImg(o);}
}
Fl_Button {} {
callback {ft.SaveLog();}
tooltip {Save Log} image {img/save-2.png} xywh {260 56 32 32} box PLASTIC_UP_BOX color 4 align 128
code0 {InactImg(o);}
}
Fl_Button Stop {
callback {ft.StopProcess();}
tooltip {Stop Process} image {img/stop.png} xywh {300 56 32 32} box PLASTIC_UP_BOX color 4 labelcolor 1 align 128 deactivate
code0 {InactImg(o);}
}
Fl_Button {} {
callback {ft.LoadLog();}
tooltip {Load Log} image {img/load.png} xywh {340 56 32 32} box PLASTIC_UP_BOX color 4 align 128
code0 {InactImg(o);}
}
Fl_Button {} {
callback {ft.About();}
tooltip Help image {img/Help.png} xywh {380 56 32 32} box PLASTIC_UP_BOX color 4 align 128
code0 {InactImg(o);}
}
Fl_Button {} {
callback {ft.DataProcessing();}
tooltip {Data Processing} image {img/Data.png} xywh {420 56 32 32} box PLASTIC_UP_BOX color 4 align 128
code0 {InactImg(o);}
}
Fl_Button {} {
callback {ft.NeuralNetworkInfo();}
tooltip {Neural Network Information} image {img/Information.png} xywh {462 56 32 32} box PLASTIC_UP_BOX color 4 align 128
code0 {InactImg(o);}
}
}
}
code {\#ifdef WIN32
window_main->icon((char *)LoadIcon(fl_display, MAKEINTRESOURCE(IDI_ICON)));
\#elif !defined(__APPLE__)
Pixmap p, mask;
XpmCreatePixmapFromData(fl_display, DefaultRootWindow(fl_display),fanntool_icon_xpm, &p, &mask, NULL);
window_main->icon((char *)p);
\#endif // WIN32} {}
}
Function {cb_Ok(Fl_Return_Button*o, void*w)} {} {
code {((Fl_Window *)(o->parent()))->hide();} {}
}
Function {Refresh()} {return_type {inline void}
} {
code {Out->bottomline(Out->size());
Out->redraw();
Graph->redraw();
Ep->redraw();
Mse->redraw();
Fl::wait(0);} {}
}
Function {FillMethods()} {} {
code {/*
FANN_TRAIN_INCREMENTAL = 0,
FANN_TRAIN_BATCH,
FANN_TRAIN_RPROP,
FANN_TRAIN_QUICKPROP
FANN_TRAIN_SARPROP
*/
Method->add("FANN_TRAIN_INCREMENTAL");
Method->add("FANN_TRAIN_BATCH");
Method->add("FANN_TRAIN_RPROP");
Method->add("FANN_TRAIN_QUICKPROP");
Method->add("FANN_TRAIN_SARPROP");} {}
}
Function {FillActivationF()} {} {
code {char *ActF[13]={
"FANN_LINEAR",
"FANN_SIGMOID",
"FANN_SIGMOID_STEPWISE",
"FANN_SIGMOID_SYMMETRIC",
"FANN_SIGMOID_SYMMETRIC_STEPWISE",
"FANN_GAUSSIAN",
"FANN_GAUSSIAN_SYMMETRIC",
"FANN_ELLIOT",
"FANN_ELLIOT_SYMMETRIC",
"FANN_LINEAR_PIECE",
"FANN_LINEAR_PIECE_SYMMETRIC",
"FANN_SIN_SYMMETRIC",
"FANN_COS_SYMMETRIC"
};
for(int i=0;i<13;i++){
HiddenActivationF->add(ActF[i]);
OutputActivationF->add(ActF[i]);
}} {}
}
Function {GetWeigths(struct fann *ann)} {return_type {fann_type *}
} {
code {fann_type *w;
w=(fann_type *)malloc(ann->total_connections*sizeof(fann_type));
for (unsigned int i=0; i < ann->total_connections; i++)
w[i] = ann->weights[i];
return w;} {}
}
Function {SetWeights(struct fann *ann,fann_type *w)} {return_type void
} {
code {for (unsigned int i=0; i < ann->total_connections; i++)
ann->weights[i]=w[i];} {}
}
Function {ExamineTrain(struct fann *ann,fann_train_enum tal,fann_activationfunc_enum hact,fann_activationfunc_enum oact,fann_train_data *TrainData)} {return_type fann_type
} {
code {fann_set_training_algorithm(ann,tal);
fann_set_activation_function_hidden(ann, hact);
fann_set_activation_function_output(ann, oact);
fann_set_callback(ann, LogOut );
// inith Graph
cX.clear();
cY.clear();
//
fann_train_on_data(ann, TrainData, 2000, 250, 0.0);
double trainMSE=fann_get_MSE(ann);
double testMSE=-1;
if(ft.TestData && ft.overtraining){
fann_reset_MSE(ann);
fann_test_data(ann,ft.TestData);
testMSE=fann_get_MSE(ann);
return (trainMSE+testMSE)/2;
}
else
return trainMSE;} {}
}
Function {LogOut(struct fann *ann, struct fann_train_data *train,unsigned int max_epochs, unsigned int epochs_between_reports,float desired_error, unsigned int epochs)} {return_type {int FANN_API}
} {
code {char Buf[512];
double trainMSE=fann_get_MSE(ann);
double testMSE=-1;
unsigned int newBitFail=fann_get_bit_fail(ann);
if(ft.TestData && ft.overtraining){
fann_reset_MSE(ann);
fann_test_data(ann,ft.TestData);
testMSE=fann_get_MSE(ann);
fann_test_data(ann,ft.TrainData);
sprintf(Buf,"%08d : %f : %f : %d ", epochs,trainMSE ,testMSE,newBitFail);
}
else
sprintf(Buf,"%08d : %f : %d ", epochs,trainMSE , newBitFail);
Out->add(Buf);
// Memorizing Begin
if(epochs==1){
for(int i=0;i<3;i++) {
MinTrainingMSE[i]=trainMSE;
MinANN[i]=fann_copy(ann);
if(ft.TestData && ft.overtraining)
MinTestingMSE[i]=testMSE;
}
MinANN[3]=ann;
}
// Latest
MinTrainingMSE[3]= trainMSE;
MinTestingMSE[3]= testMSE;
// if( MinANN[3]) fann_destroy( MinANN[3]);
// MinANN[3]=fann_copy(ann);
// Minimum Training MSE
if(MinTrainingMSE[0]> trainMSE ){
if( MinANN[0]) fann_destroy( MinANN[0]);
MinANN[0]=fann_copy(ann);
MinTrainingMSE[0]=trainMSE;
if(ft.TestData && ft.overtraining)
MinTestingMSE[0]=testMSE;
}
if(ft.TestData && ft.overtraining){
// Minimum Testing MSE
if(MinTestingMSE[1]> testMSE ){
if( MinANN[1]) fann_destroy( MinANN[1]);
MinANN[1]=fann_copy(ann);
MinTrainingMSE[1]=trainMSE;
MinTestingMSE[1]=testMSE;
}
// Minimum (Training MSE + Testing MSE )/2
if((MinTestingMSE[2]+ MinTrainingMSE[2])> (trainMSE + testMSE) ){
if( MinANN[2]) fann_destroy( MinANN[2]);
MinANN[2]=fann_copy(ann);
MinTrainingMSE[2]=trainMSE;
MinTestingMSE[2]=testMSE;
}
}
// Memorizing End
DrawGraph(epochs,trainMSE,testMSE,newBitFail);
Refresh();
if(ft.stop)
return -1;
return 1;} {}
}
Function {CascadeLogOut(struct fann *ann, struct fann_train_data *train,unsigned int max_epochs, unsigned int epochs_between_reports,float desired_error, unsigned int epochs)} {return_type {int FANN_API}
} {
code {char Buf[512];
double trainMSE=fann_get_MSE(ann);
double testMSE=-1;
unsigned int newBitFail=fann_get_bit_fail(ann);
if(ft.TestData && ft.overtraining){
fann_reset_MSE(ann);
fann_test_data(ann,ft.TestData);
testMSE=fann_get_MSE(ann);
fann_test_data(ann,ft.TrainData);
sprintf(Buf,"%08d : %f : %f : %d ", epochs,trainMSE ,testMSE ,newBitFail);
}
else
sprintf(Buf,"%08d : %f : %d ", epochs,trainMSE , newBitFail);
/*
sprintf(Buf,"Current error: %.6f. Total error:%8.4f. Epochs %5d. Bit fail %3d",
newMSE, ann->MSE_value, epochs, ann->num_bit_fail);
*/
Out->add(Buf);
if((ann->last_layer-2) != ann->first_layer)
{
sprintf(Buf,"@C4Candidate steepness %.2f. function %s",
(ann->last_layer-2)->first_neuron->activation_steepness,
FANN_ACTIVATIONFUNC_NAMES[(ann->last_layer-2)->first_neuron->activation_function]);
Out->add(Buf);
}
// Memorizing Begin
if(cascadeFirst){
for(int i=0;i<3;i++) {
MinTrainingMSE[i]=trainMSE;
MinANN[i]=fann_copy(ann);
if(ft.TestData && ft.overtraining)
MinTestingMSE[i]=testMSE;
}
MinANN[3]=ann;
cascadeFirst=false;
}
// Latest
MinTrainingMSE[3]= trainMSE;
MinTestingMSE[3]= testMSE;
// if( MinANN[3]) fann_destroy( MinANN[3]);
// MinANN[3]=fann_copy(ann);
// Minimum Training MSE
if(MinTrainingMSE[0]> trainMSE ){
if( MinANN[0]) fann_destroy( MinANN[0]);
MinANN[0]=fann_copy(ann);
MinTrainingMSE[0]=trainMSE;
if(ft.TestData && ft.overtraining)
MinTestingMSE[0]=testMSE;
}
if(ft.TestData && ft.overtraining){
// Minimum Testing MSE
if(MinTestingMSE[1]> testMSE ){
if( MinANN[1]) fann_destroy( MinANN[1]);
MinANN[1]=fann_copy(ann);
MinTrainingMSE[1]=trainMSE;
MinTestingMSE[1]=testMSE;
}
// Minimum (Training MSE + Testing MSE )/2
if((MinTestingMSE[2]+ MinTrainingMSE[2])> (trainMSE + testMSE) ){
if( MinANN[2]) fann_destroy( MinANN[2]);
MinANN[2]=fann_copy(ann);
MinTrainingMSE[2]=trainMSE;
MinTestingMSE[2]=testMSE;
}
}
// Memorizing End
DrawGraph(epochs,trainMSE,testMSE,ann->num_bit_fail);
Refresh();
if(ft.stop)
return -1;
return 1;} {}
}
Function {DrawGraph(float epochs, float TrainMSE, float TestMSE,unsigned int newBitFail)} {return_type {int FANN_API}
} {
code {if(epochs < 2){
cX.clear();
cY.clear();
}
Graph->clear(Line);
cX.push_back(epochs);
if(TestMSE==-1)
cY.push_back(TrainMSE);
else
cY.push_back((TrainMSE+TestMSE)/2);
while(cX.size()>=(int)nVData->value()){
cX.pop_front();
cY.pop_front();
}
for (int i=1; i<cX.size(); ++i) {
Graph->add(Line,cX[i],cY[i]);
}
Graph->redraw();
Ep->value(epochs);
Mse->value(TrainMSE);
if(TestMSE!=-1)
TestMse->value(TestMSE);
BitFailOut->value(newBitFail);} {}
}
Function {SetHiddens()} {return_type void
} {
code {int tmp,fark;
fark=(int )(Input->value()-Output->value());
if(fark > 0 ) {
if(Layer->value()==3){
tmp=fark/2;
Hid1->value(tmp);
Hid2->value(0);
Hid3->value(0);
}
else if(Layer->value()==4){
tmp=fark/3;
Hid1->value(Input->value()-tmp);
Hid2->value(Hid1->value()-tmp);
Hid3->value(0);
}
else if(Layer->value()==5){
tmp=fark/4;
Hid1->value(Input->value()-tmp);
Hid2->value(Hid1->value()-tmp);
Hid3->value(Hid2->value()-tmp);
}
if(Hid1->value()==0) Hid1->value(1);
if(Hid2->value()==0) Hid2->value(1);