#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #include ; for _FileCreate ed. #include ; also for multiping #include #include #include #include #include #include Global $array_display = False Global $GUI = True Global $may_update_GUIdata = False Global $console_wright = True Global $normelize = True Global $feed_backward = False Global $feed_forward = False Global $feed_gui_settings = True Global $raw_data_loaded = False Global $settings_loaded = False Global $raw_target_loaded = False Global $raw_input_loaded = False Global $treshold_time = 100 Global $treshold_counter_max = 1000 Global $feed_times = 60 Global $max_weight = 1 Global $min_weight = -1 Global $max_bias = 1 Global $min_bias = -1 If $GUI Then Globals_GUI() GUI() Globals_settings() Globals_forward() Globals_backward() rap_rebuild_global(0) If $settings[0][1] < 3 OR $settings[1][1] < 3 OR $settings[2][1] < 3 OR $settings[3][1] < 3 Then $may_update_GUIdata = False Else $may_update_GUIdata = True EndIf GUI_set_data() GUI_load_settings() ;~ GUI_set_settings() while_loop() Else cw("GUI not set") EndIf Func GUI() $GUI_form = GUICreate("Form1", 1261, 549, 179, 115) $GUI_btn_tst1 = GUICtrlCreateButton("test 1", 216, 495, 75, 25) $GUI_btn_tst2 = GUICtrlCreateButton("test 2", 296, 495, 75, 25) $GUI_inp_1 = GUICtrlCreateInput("GUI_inp_1", 216, 80, 73, 21) $GUI_inp_2 = GUICtrlCreateInput("GUI_inp_2", 216, 216, 73, 21) $GUI_inp_3 = GUICtrlCreateInput("GUI_inp_3", 216, 360, 65, 21) $GUI_inp_norm1 = GUICtrlCreateInput("GUI_inp_norm1", 304, 80, 73, 21) $GUI_inp_norm2 = GUICtrlCreateInput("GUI_inp_norm2", 304, 216, 73, 21) $GUI_inp_norm3 = GUICtrlCreateInput("GUI_inp_norm3", 304, 360, 73, 21) $GUI_inp_w11 = GUICtrlCreateInput("GUI_inp_w11", 408, 40, 73, 21) $GUI_inp_w12 = GUICtrlCreateInput("GUI_inp_w12", 408, 80, 73, 21) $GUI_inp_w13 = GUICtrlCreateInput("GUI_inp_w13", 408, 120, 73, 21) $GUI_inp_w21 = GUICtrlCreateInput("GUI_inp_w21", 408, 176, 73, 21) $GUI_inp_w22 = GUICtrlCreateInput("GUI_inp_w22", 408, 216, 73, 21) $GUI_inp_w23 = GUICtrlCreateInput("GUI_inp_w23", 408, 256, 73, 21) $GUI_inp_w31 = GUICtrlCreateInput("GUI_inp_w31", 408, 320, 73, 21) $GUI_inp_w32 = GUICtrlCreateInput("GUI_inp_w32", 408, 360, 73, 21) $GUI_inp_w33 = GUICtrlCreateInput("GUI_inp_w33", 408, 400, 73, 21) $GUI_h1_w11 = GUICtrlCreateInput("GUI_h1_w11", 672, 40, 73, 21) $GUI_h1_w12 = GUICtrlCreateInput("GUI_h1_w12", 672, 80, 73, 21) $GUI_h1_w13 = GUICtrlCreateInput("GUI_h1_w13", 672, 120, 73, 21) $GUI_h1_w21 = GUICtrlCreateInput("GUI_h1_w21", 672, 176, 73, 21) $GUI_h1_w22 = GUICtrlCreateInput("GUI_h1_w22", 672, 216, 73, 21) $GUI_h1_w23 = GUICtrlCreateInput("GUI_h1_w23", 672, 256, 73, 21) $GUI_h1_w31 = GUICtrlCreateInput("GUI_h1_w31", 672, 320, 73, 21) $GUI_h1_w32 = GUICtrlCreateInput("GUI_h1_w32", 672, 360, 73, 21) $GUI_h1_w33 = GUICtrlCreateInput("GUI_h1_w33", 672, 400, 73, 21) $GUI_h2_w11 = GUICtrlCreateInput("GUI_h2_w11", 952, 32, 73, 21) $GUI_h2_w12 = GUICtrlCreateInput("GUI_h2_w12", 952, 72, 73, 21) $GUI_h2_w13 = GUICtrlCreateInput("GUI_h2_w13", 952, 112, 73, 21) $GUI_h2_w21 = GUICtrlCreateInput("GUI_h2_w21", 952, 168, 73, 21) $GUI_h2_w22 = GUICtrlCreateInput("GUI_h2_w22", 952, 208, 73, 21) $GUI_h2_w23 = GUICtrlCreateInput("GUI_h2_w23", 952, 248, 73, 21) $GUI_h2_w31 = GUICtrlCreateInput("GUI_h2_w31", 952, 312, 73, 21) $GUI_h2_w32 = GUICtrlCreateInput("GUI_h2_w32", 952, 352, 73, 21) $GUI_h2_w33 = GUICtrlCreateInput("GUI_h2_w33", 952, 392, 73, 21) $GUI_h1_b1 = GUICtrlCreateInput("GUI_h1_b1", 536, 56, 81, 21) $GUI_h1_b2 = GUICtrlCreateInput("GUI_h1_b2", 536, 192, 81, 21) $GUI_h1_b3 = GUICtrlCreateInput("GUI_h1_b3", 536, 344, 81, 21) $GUI_h2_b1 = GUICtrlCreateInput("GUI_h2_b1", 800, 56, 81, 21) $GUI_h2_b2 = GUICtrlCreateInput("GUI_h2_b2", 800, 192, 81, 21) $GUI_h2_b3 = GUICtrlCreateInput("GUI_h2_b3", 800, 336, 81, 21) $GUI_o_b1 = GUICtrlCreateInput("GUI_o_b1", 1080, 56, 81, 21) $GUI_o_b2 = GUICtrlCreateInput("GUI_o_b2", 1080, 184, 81, 21) $GUI_o_b3 = GUICtrlCreateInput("GUI_o_b3", 1080, 336, 81, 21) $GUI_h1_o1 = GUICtrlCreateInput("GUI_h1_o1", 536, 104, 81, 21) $GUI_h1_o2 = GUICtrlCreateInput("GUI_h1_o2", 536, 232, 81, 21) $GUI_h1_o3 = GUICtrlCreateInput("GUI_h1_o3", 536, 384, 81, 21) $GUI_h2_o1 = GUICtrlCreateInput("GUI_h2_o1", 800, 104, 81, 21) $GUI_h2_o2 = GUICtrlCreateInput("GUI_h2_o2", 800, 232, 81, 21) $GUI_h2_o3 = GUICtrlCreateInput("GUI_h2_o3", 800, 376, 81, 21) $GUI_o_o1 = GUICtrlCreateInput("GUI_o_o1", 1080, 104, 81, 21) $GUI_o_o2 = GUICtrlCreateInput("GUI_o_o2", 1080, 224, 81, 21) $GUI_o_o3 = GUICtrlCreateInput("GUI_o_o3", 1080, 376, 81, 21) $GUI_o_t1 = GUICtrlCreateInput("GUI_o_t1", 1168, 96, 65, 21) $GUI_o_t2 = GUICtrlCreateInput("GUI_o_t2", 1168, 224, 65, 21) $GUI_o_t3 = GUICtrlCreateInput("GUI_o_t3", 1168, 376, 65, 21) $GUI_h1_e1 = GUICtrlCreateInput("GUI_h1_e1", 432, 432, 73, 21) $GUI_h1_e2 = GUICtrlCreateInput("GUI_h1_e2", 512, 432, 73, 21) $GUI_h1_e3 = GUICtrlCreateInput("GUI_h1_e3", 592, 432, 73, 21) $GUI_h2_e1 = GUICtrlCreateInput("GUI_h2_e1", 720, 432, 73, 21) $GUI_h2_e2 = GUICtrlCreateInput("GUI_h2_e2", 800, 432, 73, 21) $GUI_h2_e3 = GUICtrlCreateInput("GUI_h2_e3", 880, 432, 73, 21) $GUI_o_e1 = GUICtrlCreateInput("GUI_o_e1", 1008, 432, 73, 21) $GUI_o_e2 = GUICtrlCreateInput("GUI_o_e2", 1088, 432, 73, 21) $GUI_o_e3 = GUICtrlCreateInput("GUI_o_e3", 1168, 432, 73, 21) $GUI_h1_d1 = GUICtrlCreateInput("GUI_h1_d1", 432, 456, 73, 21) $GUI_h1_d2 = GUICtrlCreateInput("GUI_h1_d2", 512, 456, 73, 21) $GUI_h1_d3 = GUICtrlCreateInput("GUI_h1_d3", 592, 456, 73, 21) $GUI_h2_d1 = GUICtrlCreateInput("GUI_h2_d1", 720, 456, 73, 21) $GUI_h2_d2 = GUICtrlCreateInput("GUI_h2_d2", 800, 456, 73, 21) $GUI_h2_d3 = GUICtrlCreateInput("GUI_h2_d3", 880, 456, 73, 21) $GUI_o_d1 = GUICtrlCreateInput("GUI_o_d1", 1008, 456, 73, 21) $GUI_o_d2 = GUICtrlCreateInput("GUI_o_d2", 1088, 456, 73, 21) $GUI_o_d3 = GUICtrlCreateInput("GUI_o_d3", 1168, 456, 73, 21) $GUI_h1_g1 = GUICtrlCreateInput("GUI_h1_g1", 432, 480, 73, 21) $GUI_h1_g2 = GUICtrlCreateInput("GUI_h1_g2", 512, 480, 73, 21) $GUI_h1_g3 = GUICtrlCreateInput("GUI_h1_g3", 592, 480, 73, 21) $GUI_h2_g1 = GUICtrlCreateInput("GUI_h2_g1", 720, 480, 73, 21) $GUI_h2_g2 = GUICtrlCreateInput("GUI_h2_g2", 800, 480, 73, 21) $GUI_h2_g3 = GUICtrlCreateInput("GUI_h2_g3", 880, 480, 73, 21) $GUI_o_g1 = GUICtrlCreateInput("GUI_o_g1", 1008, 480, 73, 21) $GUI_o_g2 = GUICtrlCreateInput("GUI_o_g2", 1088, 480, 73, 21) $GUI_o_g3 = GUICtrlCreateInput("GUI_o_g3", 1168, 480, 73, 21) $GUI_h1_delt1 = GUICtrlCreateInput("GUI_h1_delt1", 432, 504, 73, 21) $GUI_h1_delt2 = GUICtrlCreateInput("GUI_h1_delt2", 512, 504, 73, 21) $GUI_h1_delt3 = GUICtrlCreateInput("GUI_h1_delt3", 592, 504, 73, 21) $GUI_h2_delt1 = GUICtrlCreateInput("GUI_h2_delt1", 720, 504, 73, 21) $GUI_h2_delt2 = GUICtrlCreateInput("GUI_h2_delt2", 800, 504, 73, 21) $GUI_h2_delt3 = GUICtrlCreateInput("GUI_h2_delt3", 880, 504, 73, 21) $GUI_o_delt1 = GUICtrlCreateInput("GUI_o_delt1", 1008, 504, 73, 21) $GUI_o_delt2 = GUICtrlCreateInput("GUI_o_delt2", 1088, 504, 73, 21) $GUI_o_delt3 = GUICtrlCreateInput("GUI_o_delt3", 1168, 504, 73, 21) $GUI_lbl_in = GUICtrlCreateLabel("Input", 216, 56, 28, 17) $GUI_lbl_inn = GUICtrlCreateLabel("nomelized input", 304, 56, 77, 17) $GUI_lbl_1w = GUICtrlCreateLabel("Weights1", 408, 16, 43, 17) $GUI_lbl_1b = GUICtrlCreateLabel("Bias", 536, 32, 40, 17) $GUI_lbl_1o = GUICtrlCreateLabel("output", 536, 80, 50, 17) $GUI_lbl_2w = GUICtrlCreateLabel("Weight", 672, 16, 43, 17) $GUI_lbl_2b = GUICtrlCreateLabel("Bias", 800, 32, 32, 17) $GUI_lbl_2o = GUICtrlCreateLabel("output", 800, 80, 50, 17) $GUI_lbl_ow = GUICtrlCreateLabel("Weights", 952, 8, 43, 17) $GUI_lbl_ob = GUICtrlCreateLabel("Bias", 1080, 32, 32, 17) $GUI_lbl_oo = GUICtrlCreateLabel("output", 1080, 80, 34, 17) $GUI_lbl_tar = GUICtrlCreateLabel("Target", 1168, 80, 34, 15) $Group2 = GUICtrlCreateGroup("files", 16, 352, 193, 185) $GUI_btn_9 = GUICtrlCreateButton("save brain", 32, 392, 75, 25) $GUI_btn_10 = GUICtrlCreateButton("load brain", 120, 392, 75, 25) $GUI_btn_11 = GUICtrlCreateButton("read targets", 32, 448, 163, 25) $GUI_btn_12 = GUICtrlCreateButton("read inputs", 32, 504, 163, 25) $GUI_set_loc = GUICtrlCreateInput(@ScriptDir & "\Base\settings.set", 32, 368, 161, 21) $GUI_targets = GUICtrlCreateInput(@ScriptDir & "\Base\t10k-labels.idx1-ubyte", 32, 424, 161, 21) $GUI_inputs = GUICtrlCreateInput(@ScriptDir & "\Base\t10k-images.idx3-ubyte", 32, 480, 161, 21) GUICtrlCreateGroup("", -99, -99, 1, 1) $GUI_lbl_errh1 = GUICtrlCreateLabel("error", 384, 440, 25, 17) $GUI_lbl_dsigh1 = GUICtrlCreateLabel("dsig out", 384, 456, 41, 17) $GUI_lbl_gradh1 = GUICtrlCreateLabel("gradient", 384, 480, 42, 17) $GUI_lbl_delh1 = GUICtrlCreateLabel("delta", 384, 504, 27, 17) $GUI_lbl_errh2 = GUICtrlCreateLabel("error", 672, 432, 25, 17) $GUI_lbl_dsigh2 = GUICtrlCreateLabel("dsig out", 672, 456, 41, 17) $GUI_lbl_gradh2 = GUICtrlCreateLabel("gradient", 672, 480, 42, 17) $GUI_lbl_delh2 = GUICtrlCreateLabel("delta", 672, 504, 27, 17) $GUI_lbl_erro = GUICtrlCreateLabel("error", 960, 432, 25, 17) $GUI_lbl_dsigo = GUICtrlCreateLabel("dsig out", 960, 456, 41, 17) $GUI_lbl_grado = GUICtrlCreateLabel("gradient", 960, 480, 42, 17) $GUI_lbl_delo = GUICtrlCreateLabel("delta", 960, 504, 27, 17) $Group1 = GUICtrlCreateGroup("Group1", 16, 8, 193, 345) $GUI_btn_1 = GUICtrlCreateButton("reset weights", 24, 304, 75, 25) $GUI_btn_2 = GUICtrlCreateButton("feed >>", 128, 280, 75, 25) $GUI_btn_3 = GUICtrlCreateButton("set data", 128, 304, 75, 25) $GUI_btn_4 = GUICtrlCreateButton("feed <<", 24, 280, 75, 25) $GUI_btn_5 = GUICtrlCreateButton("set 3 3 3 3", 128, 56, 75, 25) $GUI_btn_6 = GUICtrlCreateButton("<< train >>", 24, 256, 75, 25) $GUI_btn_7 = GUICtrlCreateButton("set x x x x", 24, 56, 75, 25) $GUI_btn_8 = GUICtrlCreateButton(">> train >>", 128, 256, 75, 25) $GUI_set0 = GUICtrlCreateInput("784", 40, 24, 25, 21) $GUI_set1 = GUICtrlCreateInput("16", 88, 24, 25, 21) $GUI_set2 = GUICtrlCreateInput("16", 136, 24, 25, 21) $GUI_set3 = GUICtrlCreateInput("10", 176, 24, 25, 21) $GUI_lbl_inp = GUICtrlCreateLabel("IN", 24, 32, 16, 22) $GUI_lbl_hid1 = GUICtrlCreateLabel("H1", 72, 32, 16, 22) $GUI_lbl_hid2 = GUICtrlCreateLabel("H2", 120, 32, 16, 22) $GUI_lbl_o = GUICtrlCreateLabel("O", 168, 32, 8, 22) $GUI_inp_correctT = GUICtrlCreateInput("0", 160, 88, 41, 21) $GUI_inp_wrongT = GUICtrlCreateInput("0", 160, 112, 41, 21) $Label23 = GUICtrlCreateLabel("Wrong", 64, 120, 36, 17) $Label24 = GUICtrlCreateLabel("Correct", 64, 96, 38, 17) $GUI_inp_total_runs = GUICtrlCreateInput("190", 160, 136, 41, 21) $Label25 = GUICtrlCreateLabel("run times", 61, 144, 51, 17) $GUI_inp_correct = GUICtrlCreateInput("0", 112, 88, 41, 21) $GUI_inp_wrong = GUICtrlCreateInput("0", 112, 112, 41, 21) $GUI_chk_data = GUICtrlCreateCheckbox("Show data", 32, 328, 81, 17) $GUI_inp_runcount = GUICtrlCreateInput("20", 112, 136, 41, 21) $GUI_chk_settings = GUICtrlCreateCheckbox("Show settings", 120, 328, 89, 17) $GUI_inp_sleep = GUICtrlCreateInput("1", 112, 184, 41, 21) $GUI_inp_sleepcount = GUICtrlCreateInput("2", 160, 184, 41, 21) $Label1 = GUICtrlCreateLabel("sleep / feed", 40, 192, 59, 17) $GUI_inp_run_percent = GUICtrlCreateInput("3", 112, 160, 41, 21) $GUI_inp_res_total = GUICtrlCreateInput("44", 160, 160, 41, 21) $GUI_inp_learningrate = GUICtrlCreateInput("0.01", 112, 208, 41, 21) $Label3 = GUICtrlCreateLabel("learning rate", 48, 216, 62, 17) $GUI_inp_current_result = GUICtrlCreateInput("0", 112, 232, 41, 21) GUICtrlCreateGroup("", -99, -99, 1, 1) $GUI_lbl_raw_inp = GUICtrlCreateLabel("Raw input", 216, 32, 55, 17) $GUI_lbl_raw_target = GUICtrlCreateLabel("Raw Target", 1168, 56, 60, 17) $GUI_lbl_result = GUICtrlCreateLabel("% res cur / total", 24, 168, 78, 17) GUISetState(@SW_SHOW) EndFunc Func tst1() copy_brain() ;~ Global $settings_copy = $settings ;~ Global $results_copy = $results ;~ Global $weights_ih1_copy = $weights_ih1 ;~ Global $weights_h1h2_copy = $weights_h1h2 ;~ Global $weights_h2o_copy = $weights_h2o ;~ Global $bias_h1_copy = $bias_h1 ;~ Global $bias_h2_copy = $bias_h2 ;~ Global $bias_o_copy = $bias_o Local $Holder[2][2] _ArrayDisplay($Holder) $Holder[1][1] = $weights_ih1_copy _ArrayDisplay($Holder) Local $get_array = $Holder[1][1] _ArrayDisplay($get_array) EndFunc Func tst2() EndFunc Func While_loop() While 1 $nMsg = GUIGetMsg(1) Switch $nMsg[1] Case $GUI_form Switch $nMsg[0] Case $GUI_EVENT_CLOSE Exit Case $GUI_btn_tst1 tst1() Case $GUI_btn_tst2 tst2() Case $GUI_chk_settings If GUICtrlRead($GUI_chk_settings) = $GUI_CHECKED Then $feed_gui_settings = True Else $feed_gui_settings = False EndIf Case $GUI_chk_data If GUICtrlRead($GUI_chk_data) = $GUI_CHECKED Then $may_update_GUIdata = True Else $may_update_GUIdata = False EndIf Case $GUI_lbl_raw_inp If IsDeclared("raw_input") Then ad($raw_input,"$raw_input",True) Case $GUI_lbl_raw_target If IsDeclared("raw_target") Then ad($raw_target,"$raw_target",True) Case $GUI_lbl_in ad($inputs,"$inputs",True) Case $GUI_lbl_result ;$GUI_inp_current_result ad($results,"$results",True) Case $GUI_lbl_inn gui_iputfield() Case $GUI_lbl_1w ad($weights_ih1,"$weights_ih1",True) Case $GUI_lbl_1b ad($bias_h1,"$bias_h1", True) Case $GUI_lbl_1o ad($outputs_h1,"$outputs_h1", True) Case $GUI_lbl_2w ad($weights_h1h2,"$weights_h1h2",True) Case $GUI_lbl_2b ad($bias_h2,"$bias_h2", True) Case $GUI_lbl_2o ad($outputs_h2,"$outputs_h2", True) Case $GUI_lbl_ow ad($weights_h2o,"$weights_h2o",True) Case $GUI_lbl_ob ad($bias_o,"$bias_o", True) Case $GUI_lbl_oo ad($outputs_o,"$outputs_o", True) Case $GUI_lbl_tar ad($target_o,"$target_o",True) Case $GUI_lbl_errh1 ad($error_h1,"$error_h1",True) Case $GUI_lbl_dsigh1 ad($dsig_h1,"$dsig_h1",True) Case $GUI_lbl_gradh1 ad($grad_h1,"$grad_h1",True) Case $GUI_lbl_delh1 ad($delta_h1,"$delta_h1",True) Case $GUI_lbl_errh2 ad($error_h2,"$error_h2",True) Case $GUI_lbl_dsigh2 ad($dsig_h2,"$dsig_h2",True) Case $GUI_lbl_gradh2 ad($grad_h2,"$grad_h2",True) Case $GUI_lbl_delh2 ad($delta_h2,"$delta_h2",True) Case $GUI_lbl_erro ad($error_o,"$error_o",True) Case $GUI_lbl_dsigo ad($dsig_o,"$dsig_o",True) Case $GUI_lbl_grado ad($grad_o,"$grad_o",True) Case $GUI_lbl_delo ad($delta_o,"$delta_o",True) Case $GUI_lbl_inp ad($settings,"$settings",True) Case $GUI_lbl_hid1 ad($settings,"$settings",True) Case $GUI_lbl_hid2 ad($settings,"$settings",True) Case $GUI_lbl_o ad($settings,"$settings",True) Case $GUI_btn_1 reset_weights() Case $GUI_btn_2 feed_forward() Case $GUI_btn_3 set_new_input() Case $GUI_btn_4 Feed_backward() Case $GUI_btn_5 ;~ ad($weights_ih1,"$weights_ih1",True) rebuild_settings(3,3,3,3) Case $GUI_btn_6 feed(GUICtrlRead($GUI_inp_runcount),True) ;~ train_backward(GUICtrlRead($GUI_runtimes)) Case $GUI_btn_7 rebuild_settings(GUICtrlRead($GUI_set0),GUICtrlRead($GUI_set1),GUICtrlRead($GUI_set2),GUICtrlRead($GUI_set3)) Case $GUI_btn_8 feed(GUICtrlRead($GUI_runtimes)) ;~ train_forward(GUICtrlRead($GUI_runtimes)) Case $GUI_btn_9 save_brain() Case $GUI_btn_10 If load_brain(GUICtrlRead($GUI_set_loc)) Then cw("loaded brain") Case $GUI_btn_11 read_target_data(GUICtrlRead($GUI_targets)) ad($raw_target,"$raw_target",True) Case $GUI_btn_12 read_input_data(GUICtrlRead($GUI_inputs)) ad($raw_input,"$raw_input",True) EndSwitch Case $guifield Switch $nMsg[0] Case $GUI_EVENT_CLOSE GUIDelete($guifield) Case $button1_1 ;~ GUICtrlSetState($Checkbox[1], $GUI_CHECKED) ;~ GUICtrlSetState($Checkbox[2], $GUI_CHECKED) ;~ GUICtrlSetState($Checkbox[27], $GUI_CHECKED) For $x = 1 To UBound($inputs , 1 ) - 1 If $inputs[$x][1] <> 0 Then GUICtrlSetState($Checkbox[$x - 1], $GUI_CHECKED) EndIf Next EndSwitch EndSwitch WEnd EndFunc Func GUI_set_data() If $may_update_GUIdata Then ;~ If $feed_gui_settings Then ;~ GuiCtrlSetData($GUI_runtime , $feed_times ) ;~ GuiCtrlSetData($GUI_runtimes , $settings[23][1]) ;~ EndIf ;~ Local $input_nodes = $settings[0][1] ;~ Local $hid1_nodes = $settings[1][1] ;~ Local $hid2_nodes = $settings[2][1] ;~ Local $out_nodes = $settings[3][1] ;~ If $input_nodes >= 1 Then ;~ If $input_nodes >= 2 Then ;~ If $input_nodes >= 2 Then GuiCtrlSetData($GUI_inp_1 , $inputs[1][1]) GuiCtrlSetData($GUI_inp_2 , $inputs[2][1]) GuiCtrlSetData($GUI_inp_3 , $inputs[3][1]) GuiCtrlSetData($GUI_inp_norm1 , $inputs[1][2]) GuiCtrlSetData($GUI_inp_norm2 , $inputs[2][2]) GuiCtrlSetData($GUI_inp_norm3 , $inputs[3][2]) GuiCtrlSetData($GUI_inp_w11 , $weights_ih1[1][1]) GuiCtrlSetData($GUI_inp_w12 , $weights_ih1[2][1]) GuiCtrlSetData($GUI_inp_w13 , $weights_ih1[3][1]) GuiCtrlSetData($GUI_inp_w21 , $weights_ih1[1][2]) GuiCtrlSetData($GUI_inp_w22 , $weights_ih1[2][2]) GuiCtrlSetData($GUI_inp_w23 , $weights_ih1[3][2]) GuiCtrlSetData($GUI_inp_w31 , $weights_ih1[1][3]) GuiCtrlSetData($GUI_inp_w32 , $weights_ih1[2][3]) GuiCtrlSetData($GUI_inp_w33 , $weights_ih1[3][3]) GuiCtrlSetData($GUI_h1_w11 , $weights_h1h2[1][1]) GuiCtrlSetData($GUI_h1_w12 , $weights_h1h2[2][1]) GuiCtrlSetData($GUI_h1_w13 , $weights_h1h2[3][1]) GuiCtrlSetData($GUI_h1_w21 , $weights_h1h2[1][2]) GuiCtrlSetData($GUI_h1_w22 , $weights_h1h2[2][2]) GuiCtrlSetData($GUI_h1_w23 , $weights_h1h2[3][2]) GuiCtrlSetData($GUI_h1_w31 , $weights_h1h2[1][3]) GuiCtrlSetData($GUI_h1_w32 , $weights_h1h2[2][3]) GuiCtrlSetData($GUI_h1_w33 , $weights_h1h2[3][3]) GuiCtrlSetData($GUI_h2_w11 , $weights_h2o[1][1]) GuiCtrlSetData($GUI_h2_w12 , $weights_h2o[2][1]) GuiCtrlSetData($GUI_h2_w13 , $weights_h2o[3][1]) GuiCtrlSetData($GUI_h2_w21 , $weights_h2o[1][2]) GuiCtrlSetData($GUI_h2_w22 , $weights_h2o[2][2]) GuiCtrlSetData($GUI_h2_w23 , $weights_h2o[3][2]) GuiCtrlSetData($GUI_h2_w31 , $weights_h2o[1][3]) GuiCtrlSetData($GUI_h2_w32 , $weights_h2o[2][3]) GuiCtrlSetData($GUI_h2_w33 , $weights_h2o[3][3]) GuiCtrlSetData($GUI_h1_b1 , $bias_h1[1][1]) GuiCtrlSetData($GUI_h1_b2 , $bias_h1[2][1]) GuiCtrlSetData($GUI_h1_b3 , $bias_h1[3][1]) GuiCtrlSetData($GUI_h2_b1 , $bias_h2[1][1]) GuiCtrlSetData($GUI_h2_b2 , $bias_h2[2][1]) GuiCtrlSetData($GUI_h2_b3 , $bias_h2[3][1]) GuiCtrlSetData($GUI_o_b1 , $bias_o[1][1]) GuiCtrlSetData($GUI_o_b2 , $bias_o[2][1]) GuiCtrlSetData($GUI_o_b3 , $bias_o[3][1]) GuiCtrlSetData($GUI_h1_o1 , $outputs_h1[1][1]) GuiCtrlSetData($GUI_h1_o2 , $outputs_h1[2][1]) GuiCtrlSetData($GUI_h1_o3 , $outputs_h1[3][1]) GuiCtrlSetData($GUI_h2_o1 , $outputs_h2[1][1]) GuiCtrlSetData($GUI_h2_o2 , $outputs_h2[2][1]) GuiCtrlSetData($GUI_h2_o3 , $outputs_h2[3][1]) GuiCtrlSetData($GUI_o_o1 , $outputs_o[1][1]) GuiCtrlSetData($GUI_o_o2 , $outputs_o[2][1]) GuiCtrlSetData($GUI_o_o3 , $outputs_o[3][1]) GuiCtrlSetData($GUI_o_t1 , $target_o[1][1]) GuiCtrlSetData($GUI_o_t2 , $target_o[2][1]) GuiCtrlSetData($GUI_o_t3 , $target_o[3][1]) GuiCtrlSetData($GUI_h1_e1 , $error_h1[1][1]) GuiCtrlSetData($GUI_h1_e2 , $error_h1[2][1]) GuiCtrlSetData($GUI_h1_e3 , $error_h1[3][1]) GuiCtrlSetData($GUI_h2_e1 , $error_h2[1][1]) GuiCtrlSetData($GUI_h2_e2 , $error_h2[2][1]) GuiCtrlSetData($GUI_h2_e3 , $error_h2[3][1]) GuiCtrlSetData($GUI_o_e1 , $error_o[1][1]) GuiCtrlSetData($GUI_o_e2 , $error_o[2][1]) GuiCtrlSetData($GUI_o_e3 , $error_o[3][1]) GuiCtrlSetData($GUI_h1_d1 , $dsig_h1[1][1]) GuiCtrlSetData($GUI_h1_d2 , $dsig_h1[2][1]) GuiCtrlSetData($GUI_h1_d3 , $dsig_h1[3][1]) GuiCtrlSetData($GUI_h2_d1 , $dsig_h2[1][1]) GuiCtrlSetData($GUI_h2_d2 , $dsig_h2[2][1]) GuiCtrlSetData($GUI_h2_d3 , $dsig_h2[3][1]) GuiCtrlSetData($GUI_o_d1 , $dsig_o[1][1]) GuiCtrlSetData($GUI_o_d2 , $dsig_o[2][1]) GuiCtrlSetData($GUI_o_d3 , $dsig_o[3][1]) GuiCtrlSetData($GUI_h1_g1 , $grad_h1[1][1]) GuiCtrlSetData($GUI_h1_g2 , $grad_h1[2][1]) GuiCtrlSetData($GUI_h1_g3 , $grad_h1[3][1]) GuiCtrlSetData($GUI_h2_g1 , $grad_h2[1][1]) GuiCtrlSetData($GUI_h2_g2 , $grad_h2[2][1]) GuiCtrlSetData($GUI_h2_g3 , $grad_h2[3][1]) GuiCtrlSetData($GUI_o_g1 , $grad_o[1][1]) GuiCtrlSetData($GUI_o_g2 , $grad_o[2][1]) GuiCtrlSetData($GUI_o_g3 , $grad_o[3][1]) GuiCtrlSetData($GUI_h1_delt1 , $delta_h1[1][1]) GuiCtrlSetData($GUI_h1_delt2 , $delta_h1[2][1]) GuiCtrlSetData($GUI_h1_delt3 , $delta_h1[3][1]) GuiCtrlSetData($GUI_h2_delt1 , $delta_h2[1][1]) GuiCtrlSetData($GUI_h2_delt2 , $delta_h2[2][1]) GuiCtrlSetData($GUI_h2_delt3 , $delta_h2[3][1]) GuiCtrlSetData($GUI_o_delt1 , $delta_o[1][1]) GuiCtrlSetData($GUI_o_delt2 , $delta_o[2][1]) GuiCtrlSetData($GUI_o_delt3 , $delta_o[3][1]) EndIf EndFunc Func GUI_load_settings() If $GUI Then GuiCtrlSetData($GUI_set0 , $settings[0][1]) GuiCtrlSetData($GUI_set1 , $settings[1][1]) GuiCtrlSetData($GUI_set2 , $settings[2][1]) GuiCtrlSetData($GUI_set3 , $settings[3][1]) GuiCtrlSetData($GUI_inp_correctT , $settings[7][1] ) GuiCtrlSetData($GUI_inp_wrongT , $settings[8][1] ) GuiCtrlSetData($GUI_set_loc , $settings[9][1] ) GuiCtrlSetData($GUI_targets , $settings[18][1] ) GuiCtrlSetData($GUI_inputs , $settings[17][1] ) GuiCtrlSetData($GUI_inp_sleep , $treshold_time ) GuiCtrlSetData($GUI_inp_sleepcount , $treshold_counter_max ) GuiCtrlSetData($GUI_inp_learningrate , $settings[6][1] ) GuiCtrlSetData($GUI_inp_runcount , $feed_times ) GuiCtrlSetData($GUI_inp_total_runs , $settings[23][1]) GuiCtrlSetData($GUI_inp_res_total , $settings[22][1] ) GuiCtrlSetData($GUI_inp_run_percent , $settings[21][1] ) If $may_update_GUIdata Then GUICtrlSetState($GUI_chk_data, $GUI_CHECKED) Else GUICtrlSetState($GUI_chk_data, $GUI_UNCHECKED) EndIf If $feed_gui_settings Then GUICtrlSetState($GUI_chk_settings, $GUI_CHECKED) Else GUICtrlSetState($GUI_chk_settings, $GUI_UNCHECKED) EndIf EndIf EndFunc Func GUI_reset_settings() If $GUI Then GuiCtrlSetData($GUI_set0 , $settings[0][1]) GuiCtrlSetData($GUI_set1 , $settings[1][1]) GuiCtrlSetData($GUI_set2 , $settings[2][1]) GuiCtrlSetData($GUI_set3 , $settings[3][1]) GuiCtrlSetData($GUI_inp_correctT , $settings[7][1] ) GuiCtrlSetData($GUI_inp_wrongT , $settings[8][1] ) GuiCtrlSetData($GUI_set_loc , $settings[9][1] ) GuiCtrlSetData($GUI_targets , $settings[18][1] ) GuiCtrlSetData($GUI_inputs , $settings[17][1] ) GuiCtrlSetData($GUI_inp_sleep , $treshold_time ) GuiCtrlSetData($GUI_inp_sleepcount , $treshold_counter_max ) GuiCtrlSetData($GUI_inp_learningrate , $settings[6][1] ) GuiCtrlSetData($GUI_inp_runcount , $feed_times ) GuiCtrlSetData($GUI_inp_total_runs , $settings[23][1]) GuiCtrlSetData($GUI_inp_res_total , $settings[22][1] ) ;~ If $may_update_GUIdata Then ;~ GUICtrlSetState($GUI_chk_data, $GUI_CHECKED) ;~ Else ;~ GUICtrlSetState($GUI_chk_data, $GUI_UNCHECKED) ;~ EndIf ;~ If $feed_gui_settings Then ;~ GUICtrlSetState($GUI_chk_settings, $GUI_CHECKED) ;~ Else ;~ GUICtrlSetState($GUI_chk_settings, $GUI_UNCHECKED) ;~ EndIf EndIf EndFunc Func GUI_set_settings1() GuiCtrlSetData($GUI_set0 , $settings[0][1]) GuiCtrlSetData($GUI_set1 , $settings[1][1]) GuiCtrlSetData($GUI_set2 , $settings[2][1]) GuiCtrlSetData($GUI_set3 , $settings[3][1]) GuiCtrlSetData($GUI_inp_correctT , $settings[7][1] ) GuiCtrlSetData($GUI_inp_wrongT , $settings[8][1] ) GuiCtrlSetData($GUI_set_loc , $settings[9][1] ) GuiCtrlSetData($GUI_targets , $settings[18][1] ) GuiCtrlSetData($GUI_inputs , $settings[17][1] ) GuiCtrlSetData($GUI_inp_runcount , $train_counter ) GuiCtrlSetData($GUI_runtimes , $settings[23][1]) GuiCtrlSetData($GUI_inp_sleep , $treshold_time ) GuiCtrlSetData($GUI_inp_sleepcount , $treshold_counter_max ) ;~ GuiCtrlSetData($GUI_inp_run_percent , $settings[21][1] ) ;~ GuiCtrlSetData($GUI_inp_lastbest , $settings[22][1] ) GuiCtrlSetData($GUI_inp_learningrate , $settings[6][1] ) If $GUI Then GUICtrlSetState($GUI_chk_data, $GUI_CHECKED) Else GUICtrlSetState($GUI_chk_data, $GUI_UNCHECKED) EndIf If $feed_gui_settings Then GUICtrlSetState($GUI_chk_settings, $GUI_CHECKED) Else GUICtrlSetState($GUI_chk_settings, $GUI_UNCHECKED) EndIf EndFunc ;================================== read raw data Func read_target_data($file = $settings[18][1]) ;~ t10k-images.idx3-ubyte 16 ;~ t10k-labels.idx1-ubyte 8 ;~ train-images.idx3-ubyte 16 ;~ train-labels.idx1-ubyte 8 ;~ TEST_labels.idx1-ubyte $raw_target_loaded = False Local $sfile = FileRead($file );47040008 Local $afile = StringRegExp($sfile, '.{2}', 3) ;~ cw("ubound($afile)" & ubound($afile),True) ReDim $raw_target[ubound($afile) - 8 ][2] $raw_target[0][0] = "id" $raw_target[0][1] = "label" ;~ cw(ubound($test_labels)) for $x = 1 to ubound($raw_target) - 1 $raw_target[$x][0] = $x $raw_target[$x][1] = Dec($afile[$x + 8],2) Next $raw_target_loaded = True ;~ _ArrayDisplay($test_labels) EndFunc Func read_input_data1($file = $settings[17][1] ) $raw_input_loaded = False Global $raw_input[1000][2] $raw_input[0][0] = "id" $raw_input[0][1] = "input" ;~ cw(ubound($test_images)) for $x = 1 to ubound($raw_input) - 1 $raw_input[$x][0] = $x $raw_input[$x][1] = Random(1,255,1) Next $raw_input_loaded = True Return True ;~ _ArrayDisplay($test_images) EndFunc Func read_input_data($file = $settings[17][1] ) $raw_input_loaded = False Local $rfile = FileRead($file) Local $stfile = StringRegExp($rfile, '.{2}', 3) ReDim $raw_input[ubound($stfile) - 16][2] $raw_input[0][0] = "id" $raw_input[0][1] = "input" ;~ cw(ubound($test_images)) for $x = 1 to ubound($raw_input) - 1 $raw_input[$x][0] = $x $raw_input[$x][1] = Dec($stfile[$x + 16],2) Next $raw_input_loaded = True Return $raw_input_loaded ;~ _ArrayDisplay($test_images) EndFunc ;================================== evolution Func copy_brain() Global $settings_copy = $settings Global $results_copy = $results Global $weights_ih1_copy = $weights_ih1 Global $weights_h1h2_copy = $weights_h1h2 Global $weights_h2o_copy = $weights_h2o Global $bias_h1_copy = $bias_h1 Global $bias_h2_copy = $bias_h2 Global $bias_o_copy = $bias_o Return True EndFunc Func mutate_brain_perc($percentage = $settings[26][1]) copy_brain() For $x = 1 To UBound($weights_ih1_copy, 1) - 1 For $y = 1 To UBound($weights_ih1_copy, 2) - 1 $weights_ih1_copy[$x][$y] = ((Random(0, 1) < $percentage) ? (Round(Random(-1,1),4)) : ($weights_ih1_copy[$x][$y])) Next Next For $x = 1 To UBound($weights_h1h2_copy, 1) - 1 For $y = 1 To UBound($weights_h1h2_copy, 2) - 1 $weights_h1h2_copy[$x][$y] = ((Random(0, 1) < $percentage) ? (Round(Random(-1,1),4)) : ($weights_h1h2_copy[$x][$y])) Next Next For $x = 1 To UBound($weights_h2o_copy, 1) - 1 For $y = 1 To UBound($weights_h2o_copy, 2) - 1 $weights_h2o_copy[$x][$y] = ((Random(0, 1) < $percentage) ? (Round(Random(-1,1),4)) : ($weights_h2o_copy[$x][$y])) Next Next For $x = 1 To UBound($bias_h1_copy, 1) - 1 $bias_h1_copy[$x][1] = ((Random(0, 1) < $percentage) ? (1) : ($bias_h1_copy[$x][1])) Next For $x = 1 To UBound($bias_h2_copy, 1) - 1 $bias_h2_copy[$x][1] = ((Random(0, 1) < $percentage) ? (1) : ($bias_h2_copy[$x][1])) Next For $x = 1 To UBound($bias_o_copy, 1) - 1 $bias_o_copy[$x][1] = ((Random(0, 1) < $percentage) ? (1) : ($bias_o_copy[$x][1])) Next EndFunc Func save_brain() copy_brain() _FileWriteFromArray($settings[9][1], $settings_copy, Default, default ,"|") _FileWriteFromArray($settings[10][1], $results_copy, Default, default ,"|") _FileWriteFromArray($settings[11][1], $weights_ih1_copy, Default, default ,"|") _FileWriteFromArray($settings[12][1], $weights_h1h2_copy, Default, default ,"|") _FileWriteFromArray($settings[13][1], $weights_h2o_copy, Default, default ,"|") _FileWriteFromArray($settings[14][1], $bias_h1_copy, Default, default ,"|") _FileWriteFromArray($settings[15][1], $bias_h2_copy, Default, default ,"|") _FileWriteFromArray($settings[16][1], $bias_o_copy, Default, default ,"|") EndFunc Func load_brain($file = @ScriptDir & "\Base\settings.set") If load_settings($file) Then Globals_forward() Globals_backward() rap_rebuild_global(2) Local $filecount = 0 For $x = 10 To 16 If FileExists($settings[$x][1]) Then $filecount += 1 Next cw("find files = " & $filecount) If $filecount = 16 - 10 + 1 Then $filecount = 0 ;~ If _FileReadToArray($settings[9][1], $settings, 0, "|") Then $filecount += 1 If _FileReadToArray($settings[10][1], $results, 0, "|") Then $filecount += 1 If _FileReadToArray($settings[11][1], $weights_ih1, 0, "|") Then $filecount += 1 If _FileReadToArray($settings[12][1], $weights_h1h2, 0, "|") Then $filecount += 1 If _FileReadToArray($settings[13][1], $weights_h2o, 0, "|") Then $filecount += 1 If _FileReadToArray($settings[14][1], $bias_h1, 0, "|") Then $filecount += 1 If _FileReadToArray($settings[15][1], $bias_h2, 0, "|") Then $filecount += 1 If _FileReadToArray($settings[16][1], $bias_o, 0, "|") Then $filecount += 1 If $filecount = 16 - 10 + 1 Then GUI_set_data() GUI_reset_settings() Return True Else Return False EndIf EndIf EndIf EndFunc func load_settings($file = @ScriptDir & "\Base\settings.set") ;~ ad($settings,"$settings",True) ;~ Local $file = @ScriptDir & "\test\settings.set" $settings_loaded = False Local $row = UBound($settings,1) Local $col = UBound($settings,2) If IsDeclared("settings") Then $settings = 0 Global $settings[$row][$col] If NOT _FileReadToArray($file, $settings, 0, "|") Then Return False Else $settings_loaded = True Return True EndIf ;~ ad($settings,"$settings",True) EndFunc ;================================== math Func feed($runtimes = 10 , $backward = False) $feed_forward = True rap_rebuild_global($runtimes) If $backward Then $feed_backward = True If $GUI Then If $may_update_GUIdata Then GuiCtrlSetData($GUI_inp_correct , 0 ) GuiCtrlSetData($GUI_inp_wrong , 0 ) EndIf EndIf Local $treshold_counter = 0 For $x = 1 To $runtimes If $backward Then $settings[24][1] += 1 $settings[23][1] += 1 ;~ cw("$settings[23][1] = " & $settings[23][1]) If $settings[23][1] > UBound($raw_target,1) - 1 Then $settings[23][1] = 1 If $GUI And $feed_gui_settings Then GuiCtrlSetData($GUI_inp_total_runs , $settings[23][1] ) $treshold_counter += 1 If $treshold_counter > $treshold_counter_max Then $treshold_counter = 0 Sleep($treshold_time) EndIf set_new_input() feed_forward() rap_report($x) If $backward Then feed_backward() Next $feed_forward = False $feed_backward = False rap_calculate($runtimes) ad($results,"$results" ,True) EndFunc Func train_forward($times = 10);$treshold_counter_max $feed_forward = True rap_rebuild_global($times) ad($results,"$results" ,False) Local $treshold_counter = 0 For $x = 1 To $times $treshold_counter += 1 $train_counter += 1 If $treshold_counter > $treshold_counter_max Then $treshold_counter = 0 Sleep($treshold_time) EndIf set_new_input() feed_forward() rap_report($x) Next $feed_forward = False $train_counter = 0 rap_calculate($times) ad($results,"$results" ,True) ;~ ad($settings,"$settings" ,True) EndFunc Func train_backward($times = 10) $feed_forward = True $feed_backward = True rap_rebuild_global($times) ad($results,"$results" ,False) GuiCtrlSetData($GUI_inp_correct , 0 ) GuiCtrlSetData($GUI_inp_wrong , 0 ) Local $treshold_counter = 0 For $x = 1 To $times $train_counter += 1 $treshold_counter += 1 If $treshold_counter > $treshold_counter_max Then $treshold_counter = 0 Sleep($treshold_time) EndIf set_new_input() feed_forward() rap_report($x) feed_backward() Next $feed_forward = False $feed_backward = False $train_counter = 0 rap_calculate($times) ad($results,"$results" ,True) ;~ ad($settings,"$settings" ,True) EndFunc Func set_new_input() Local $LC_target_set = $settings[23][1] If $raw_input_loaded Then $LC_set = UBound($inputs,1) - 1 ;============================================== Local $aExtract = _ArrayExtract($raw_input, (($LC_target_set * $LC_set) - $LC_set) + 1 , $LC_target_set * $LC_set , 1, 1) For $x = 1 To UBound($inputs,1) - 1 $inputs[$x][1] = $aExtract[$x - 1] Next Else For $x = 1 To UBound($inputs,1) - 1 $inputs[$x][1] = Random(1,255,1) Next EndIf If $raw_target_loaded Then For $y = 1 To UBound($target_o,1) - 1 $target_o[$y][1] = 0 Next;$raw_target[$x][1] $target_o[$raw_target[$LC_target_set][1] + 1][1] = 1 Else For $x = 1 To UBound($target_o,1) - 1 $target_o[$x][0] = $x $target_o[$x][1] = 0 Next $target_o[Random(1 , UBound($target_o,1) - 1 , 1)][1] = 1 EndIf GUI_set_data() EndFunc Func feed_forward() ;normelizing data For $i = 1 To UBound($inputs,1) - 1 $inputs[$i][2] = round(($inputs[$i][1] - $settings[4][1]) / ($settings[5][1] - $settings[4][1]),4) Next ad($inputs,"$inputs",False) ;calculate output for hidden 1 Local $temp = 0 For $x = 1 To UBound($outputs_h1,1) - 1 $temp = 0 For $y = 1 To UBound($inputs,1) - 1 $temp = ($inputs[$y][2] * $weights_ih1[$y][$x]) + $temp Next $temp = $temp + $bias_h1[$x][1] $temp = sig($temp) $temp = normelize($temp) $outputs_h1[$x][1] = $temp Next ad($outputs_h1,"$outputs_h1",False) ;calculate output for hidden 2 For $x = 1 To UBound($outputs_h2,1) - 1 $temp = 0 For $y = 1 To UBound($outputs_h1,1) - 1 $temp = ($outputs_h1[$y][1] * $weights_h1h2[$y][$x]) + $temp Next $temp = $temp + $bias_h2[$x][1] $temp = sig($temp) $temp = normelize($temp) $outputs_h2[$x][1] = $temp Next ad($outputs_h2,"$outputs_h2",False) ;calculate output for output For $x = 1 To UBound($outputs_o,1) - 1 $temp = 0 For $y = 1 To UBound($outputs_h2,1) - 1 $temp = ($outputs_h2[$y][1] * $weights_h2o[$y][$x]) + $temp Next $temp = $temp + $bias_o[$x][1] $temp = sig($temp) $temp = normelize($temp) $outputs_o[$x][1] = $temp Next ad($outputs_o,"$outputs_o",False) GUI_set_data() EndFunc Func feed_backward() Local $temp = 0 Local $learning_rate = $settings[6][1] ;###################################################################################### calc delta & gradient | hidden2 -> out For $k = 1 To UBound($error_o,1) -1 $error_o[$k][1] = normelize($target_o[$k][1] - $outputs_o[$k][1]) $dsig_o[$k][1] = normelize(dsig($outputs_o[$k][1])) $grad_o[$k][1] = normelize((($dsig_o[$k][1] * $error_o[$k][1]) * $learning_rate)) $delta_o[$k][1] = normelize($grad_o[$k][1] * $outputs_o[$k][1]) Next ;###################################################################################### >> set new weigts/bias | hidden2 -> out ;== set new weight from delta For $x = 1 To UBound($weights_h2o,1) - 1 For $y = 1 To UBound($delta_o,1) - 1 $temp = normelize($weights_h2o[$x][$y] + $delta_o[$y][1]) If $temp > $max_weight Then $temp = $max_weight If $temp < $min_weight Then $temp = $min_weight $weights_h2o[$x][$y] = $temp Next Next ;== set new bias from gradient For $x = 1 To UBound($bias_o,1) -1 $temp = normelize($bias_o[$x][1] + $grad_o[$x][1]) If $temp > $max_bias Then $temp = $max_bias If $temp < $min_bias Then $temp = $min_bias $bias_o[$x][1] = $temp Next ;###################################################################################### calc delta & gradient | hidden1 -> hidden2 For $m = 1 To UBound($error_h2,1) -1 $temp = 0 For $k = 1 To UBound($weights_h2o,2) -1 $temp = ($weights_h2o[$m][$k] * $error_o[$k][1] ) + $temp Next $error_h2[$m][1] = normelize($temp) $dsig_h2[$m][1] = normelize(dsig($outputs_h2[$m][1])) $grad_h2[$m][1] = normelize(($dsig_h2[$m][1] * $error_h2[$m][1]) * $learning_rate) $delta_h2[$m][1] = normelize($grad_h2[$m][1] * $outputs_h2[$m][1]) Next ;###################################################################################### >> set new weigts/bias | hidden1 -> hidden2 ;== set new weight from delta For $x = 1 To UBound($weights_h1h2,1) - 1 For $y = 1 To UBound($delta_h2,1) - 1 $temp = normelize($weights_h1h2[$x][$y] + $delta_h2[$y][1]) If $temp > $max_weight Then $temp = $max_weight If $temp < $min_weight Then $temp = $min_weight $weights_h1h2[$x][$y] = $temp Next Next ;== set new bias from gradient For $x = 1 To UBound($bias_h2,1) -1 $temp = normelize($bias_h2[$x][1] + $grad_h2[$x][1]) If $temp > $max_bias Then $temp = $max_bias If $temp < $min_bias Then $temp = $min_bias $bias_h2[$x][1] = $temp Next ;###################################################################################### calc delta & gradient | input -> hidden1 For $m = 1 To UBound($error_h1,1) -1 $temp = 0 For $k = 1 To UBound($weights_h1h2,2) -1 $temp = ($weights_h1h2[$m][$k] * $error_h2[$k][1] ) + $temp Next $error_h1[$m][1] = normelize($temp) $dsig_h1[$m][1] = normelize(dsig($outputs_h1[$m][1])) $grad_h1[$m][1] = normelize(($dsig_h1[$m][1] * $error_h1[$m][1]) * $learning_rate) $delta_h1[$m][1] = normelize($grad_h1[$m][1] * $outputs_h1[$m][1]) Next ;###################################################################################### >> set new weigts/bias | input -> hidden1 ;== set new weight from delta For $x = 1 To UBound($weights_ih1,1) - 1 For $y = 1 To UBound($delta_h1,1) - 1 $temp = normelize($weights_ih1[$x][$y] + $delta_h1[$y][1]) If $temp > $max_weight Then $temp = $max_weight If $temp < $min_weight Then $temp = $min_weight $weights_ih1[$x][$y] = $temp Next Next ;== set new bias from gradient For $x = 1 To UBound($bias_h1,1) -1 $temp = normelize($bias_h1[$x][1] + $grad_h1[$x][1]) If $temp > $max_bias Then $temp = $max_bias If $temp < $min_bias Then $temp = $min_bias $bias_h1[$x][1] = $temp Next GUI_set_data() EndFunc Func sig($x) Return 1 / (1 + exp($x * -1)) EndFunc Func dsig($x) Return $x * (1 - $x) EndFunc Func normelize($x) If $normelize Then $x = Round(Execute(String($x)),6) ;~ $x = Round($x,6) EndIf Return $x EndFunc ;================================= report Func rap_rebuild_global($run_times) If IsDeclared("results") Then $results = 0 Global $results[$run_times + 1][5] = [["quessed_id","quessed","target","quessed_output","correct"]] EndFunc Func rap_report($run_time) ;set id $results[$run_time][0] = $run_time ;get quessed id and output $outputs_os = $outputs_o _ArraySort($outputs_os, 1, 1, 0, 1) $results[$run_time][1] = $outputs_os[1][0] $results[$run_time][3] = $outputs_os[1][1] ;~ ad($outputs_os,"$outputs_os" ,True) If $feed_backward Then ;get target For $x = 1 To UBound($target_o,1) - 1 If $target_o[$x][1] = 1 Then $results[$run_time][2] = $target_o[$x][0] Next If $results[$run_time][1] <> $results[$run_time][2] Then $settings[8][1] += 1 $results[$run_time][4] = 0 If $feed_gui_settings Then If $GUI Then Local $temp = GUICtrlRead($GUI_inp_wrongT) $temp += 1 GuiCtrlSetData($GUI_inp_wrongT , $temp ) Local $temp2 = GUICtrlRead($GUI_inp_wrong) $temp2 += 1 GuiCtrlSetData($GUI_inp_wrong , $temp2 ) ;~ $temp2 = GUICtrlRead($GUI_inp_wrongT) EndIf EndIf Else $results[$run_time][4] = 1 $settings[7][1] += 1 If $feed_gui_settings Then If $GUI Then Local $temp = GUICtrlRead($GUI_inp_correctT) $temp += 1 GuiCtrlSetData($GUI_inp_correctT , $temp ) Local $temp2 = GUICtrlRead($GUI_inp_correct) $temp2 += 1 GuiCtrlSetData($GUI_inp_correct , $temp2 ) EndIf EndIf EndIf EndIf EndFunc Func rap_calculate($times) Local $temp = 0 Local $total = 0 ;get feed good count For $x = 1 To UBound($results,1) - 1 If $results[$x][4] = 1 Then $temp += 1 Next ;calculate feed percantage If $temp > 0 Then $total = Round(($temp / $times) * 100 , 2 ) EndIf $settings[21][1] = $total If $GUI And $feed_gui_settings Then GuiCtrlSetData($GUI_inp_run_percent , $total ) ;calculate total good percentage If $settings[7][1] <> 0 Then $total = Round(($settings[7][1] / $settings[24][1]) * 100 , 2 ) EndIf $settings[22][1] = $total If $GUI And $feed_gui_settings Then GuiCtrlSetData($GUI_inp_res_total , $total ) If $GUI And $feed_gui_settings Then GuiCtrlSetData($GUI_inp_res_total , $total ) EndFunc Func rap_calculate1($times) Local $temp = 0 For $x = 1 To UBound($results,1) - 1 If $results[$x][4] = 1 Then $temp += 1 Next If $temp > 0 Then Local $total = ($temp / $times) * 100 cw("total % = " & $total) Else Local $total = 0 cw("total % = 0 ") EndIf GuiCtrlSetData($GUI_inp_current_result , $total ) $settings[21][1] = $total EndFunc ;--------------------------------- tools Func ad($array,$txt = "default txt" ,$force = False) Local $return = False If $array_display Or $force Then $return = True If Not IsArray($array) Then $return = False If $return Then _ArrayDisplay($array,$txt, False) EndFunc Func ad_w($x) If $x = 0 Then ad($weights_ih1,"$weights_ih1",True) ElseIf $x = 1 Then ad($weights_h1h2,"$weights_h1h2",True) ElseIf $x = 2 Then ad($weights_h2o,"$weights_h2o",True) EndIf EndFunc Func cw($txt = "here" , $force = False ) Local $return = False If $console_wright Or $force Then $return = True If $return Then ConsoleWrite( $txt & @LF ) EndFunc ;--------------------------------- globals Func rebuild_settings( $input_layer = 3 , $hidden1_layer = 3 , $hidden2_layer = 3 , $output_layer = 3 ) GuiCtrlSetData($GUI_inp_correct , 0 ) GuiCtrlSetData($GUI_inp_wrong , 0 ) If $input_layer < 3 OR $hidden1_layer < 3 OR $hidden2_layer < 3 OR $output_layer < 3 Then $may_update_GUIdata = False $GUI = False Else $may_update_GUIdata = True $GUI = True EndIf $settings[0][1] = $input_layer $settings[1][1] = $hidden1_layer $settings[2][1] = $hidden2_layer $settings[3][1] = $output_layer Globals_forward() Globals_backward() rap_rebuild_global(0) GUI_set_data() GUI_load_settings() EndFunc Func Globals_GUI() Global $GUI_lbl_result Global $GUI_inp_current_result Global $GUI_form Global $guifield Global $button1_1 Global $Checkbox[784] Global $GUI_inp_sleep Global $GUI_inp_sleepcount Global $GUI_inp_run_percent Global $GUI_inp_res_total Global $GUI_inp_learningrate Global $GUI_inp_runcount Global $GUI_lbl_raw_inp Global $GUI_lbl_raw_target Global $GUI_chk_data Global $GUI_chk_settings Global $GUI_lbl_in Global $GUI_lbl_inn Global $GUI_lbl_1w Global $GUI_lbl_1b Global $GUI_lbl_1o Global $GUI_lbl_2w Global $GUI_lbl_2b Global $GUI_lbl_2o Global $GUI_lbl_ow Global $GUI_lbl_ob Global $GUI_lbl_oo Global $GUI_lbl_tar Global $GUI_lbl_errh1 Global $GUI_lbl_dsigh1 Global $GUI_lbl_gradh1 Global $GUI_lbl_delh1 Global $GUI_lbl_errh2 Global $GUI_lbl_dsigh2 Global $GUI_lbl_gradh2 Global $GUI_lbl_delh2 Global $GUI_lbl_erro Global $GUI_lbl_dsigo Global $GUI_lbl_grado Global $GUI_lbl_delo Global $GUI_lbl_inp Global $GUI_lbl_hid1 Global $GUI_lbl_hid2 Global $GUI_lbl_o Global $GUI_set_loc Global $GUI_targets Global $GUI_inputs Global $GUI_btn_tst1 Global $GUI_btn_tst2 Global $GUI_btn_1 Global $GUI_btn_2 Global $GUI_btn_3 Global $GUI_btn_4 Global $GUI_btn_5 Global $GUI_btn_6 Global $GUI_btn_7 Global $GUI_btn_8 Global $GUI_btn_9 Global $GUI_btn_10 Global $GUI_btn_11 Global $GUI_btn_12 Global $GUI_inp_1 Global $GUI_inp_2 Global $GUI_inp_3 Global $GUI_inp_norm1 Global $GUI_inp_norm2 Global $GUI_inp_norm3 Global $GUI_inp_w11 Global $GUI_inp_w12 Global $GUI_inp_w13 Global $GUI_inp_w21 Global $GUI_inp_w22 Global $GUI_inp_w23 Global $GUI_inp_w31 Global $GUI_inp_w32 Global $GUI_inp_w33 Global $GUI_h1_w11 Global $GUI_h1_w12 Global $GUI_h1_w13 Global $GUI_h1_w21 Global $GUI_h1_w22 Global $GUI_h1_w23 Global $GUI_h1_w31 Global $GUI_h1_w32 Global $GUI_h1_w33 Global $GUI_h2_w11 Global $GUI_h2_w12 Global $GUI_h2_w13 Global $GUI_h2_w21 Global $GUI_h2_w22 Global $GUI_h2_w23 Global $GUI_h2_w31 Global $GUI_h2_w32 Global $GUI_h2_w33 Global $GUI_h1_b1 Global $GUI_h1_b2 Global $GUI_h1_b3 Global $GUI_h2_b1 Global $GUI_h2_b2 Global $GUI_h2_b3 Global $GUI_o_b1 Global $GUI_o_b2 Global $GUI_o_b3 Global $GUI_h1_o1 Global $GUI_h1_o2 Global $GUI_h1_o3 Global $GUI_h2_o1 Global $GUI_h2_o2 Global $GUI_h2_o3 Global $GUI_o_o1 Global $GUI_o_o2 Global $GUI_o_o3 Global $GUI_o_t1 Global $GUI_o_t2 Global $GUI_o_t3 Global $GUI_h1_e1 Global $GUI_h1_e2 Global $GUI_h1_e3 Global $GUI_h2_e1 Global $GUI_h2_e2 Global $GUI_h2_e3 Global $GUI_o_e1 Global $GUI_o_e2 Global $GUI_o_e3 Global $GUI_h1_d1 Global $GUI_h1_d2 Global $GUI_h1_d3 Global $GUI_h2_d1 Global $GUI_h2_d2 Global $GUI_h2_d3 Global $GUI_o_d1 Global $GUI_o_d2 Global $GUI_o_d3 Global $GUI_h1_g1 Global $GUI_h1_g2 Global $GUI_h1_g3 Global $GUI_h2_g1 Global $GUI_h2_g2 Global $GUI_h2_g3 Global $GUI_o_g1 Global $GUI_o_g2 Global $GUI_o_g3 Global $GUI_h1_delt1 Global $GUI_h1_delt2 Global $GUI_h1_delt3 Global $GUI_h2_delt1 Global $GUI_h2_delt2 Global $GUI_h2_delt3 Global $GUI_o_delt1 Global $GUI_o_delt2 Global $GUI_o_delt3 Global $GUI_inp_wrongT Global $GUI_inp_correctT Global $GUI_inp_wrong Global $GUI_inp_correct Global $GUI_set0 Global $GUI_set1 Global $GUI_set2 Global $GUI_set3 Global $GUI_inp_total_runs EndFunc Func Globals_forward() ;for forward ;~ Global $inputs[4][3] ;~ Global $weights_ih1[4][4] ;~ Global $weights_h1h2[4][4] ;~ Global $weights_h2o[4][3] ;~ Global $bias_h1[4][2] ;~ Global $bias_h2[4][2] ;~ Global $bias_o[3][2] ;~ Global $outputs_h1[4][2] ;~ Global $outputs_h2[4][2] ;~ Global $outputs_o[3][2] Global $raw_target[1][2] $raw_target[0][0] = "id" $raw_target[0][1] = "label" Global $raw_input[1][2] $raw_input[0][0] = "id" $raw_input[0][1] = "input" ;===================================================================================== If IsDeclared("inputs") Then $inputs = 0 Global $inputs[$settings[0][1] + 1 ][3] ;~ ad($inputs,"$inputs",True) ;===================================================================================== $inputs[0][0] = "id" $inputs[0][1] = "input" $inputs[0][2] = "normalized" For $x = 1 To UBound($inputs,1) - 1 $inputs[$x][0] = $x $inputs[$x][1] = Random($settings[4][1],$settings[5][1],1) Next ad($inputs,"$inputs",False) ;===================================================================================== If IsDeclared("weights_ih1") Then $weights_ih1 = 0 Global $weights_ih1[$settings[0][1] + 1 ][$settings[1][1] + 1 ] ;===================================================================================== $weights_ih1[0][0] = "id" $weights_ih1[0][1] = "wix->hy" For $x = 1 To UBound($weights_ih1,1) - 1 $weights_ih1[$x][0] = $x For $y = 1 To UBound($weights_ih1,2) - 1 $weights_ih1[$x][$y] = Round(Random(-1,1),4) ;~ ConsoleWrite( "$x = " & $x & " $y = " & $y & @LF ) Next Next ad($weights_ih1,"$weights_oh1", False) ;===================================================================================== If IsDeclared("weights_h1h2") Then $weights_h1h2 = 0 Global $weights_h1h2[$settings[1][1] + 1 ][$settings[2][1] + 1 ] ;===================================================================================== $weights_h1h2[0][0] = "id" $weights_h1h2[0][1] = "wix->hy" For $x = 1 To UBound($weights_h1h2,1) - 1 $weights_h1h2[$x][0] = $x For $y = 1 To UBound($weights_h1h2,2) - 1 $weights_h1h2[$x][$y] = Round(Random(-1,1),4) ;~ ConsoleWrite( "$x = " & $x & " $y = " & $y & @LF ) Next Next ad($weights_h1h2,"$weights_h1h2", False) ;===================================================================================== If IsDeclared("weights_h2o") Then $weights_h2o = 0 Global $weights_h2o[$settings[2][1] + 1 ][$settings[3][1] + 1 ] ;===================================================================================== $weights_h2o[0][0] = "id" $weights_h2o[0][1] = "wix->hy" For $x = 1 To UBound($weights_h2o,1) - 1 $weights_h2o[$x][0] = $x For $y = 1 To UBound($weights_h2o,2) - 1 $weights_h2o[$x][$y] = Round(Random(-1,1),4) ;~ ConsoleWrite( "$x = " & $x & " $y = " & $y & @LF ) Next Next ad($weights_h2o,"$weights_h2o", False) ;===================================================================================== If IsDeclared("bias_h1") Then $bias_h1 = 0 Global $bias_h1[$settings[1][1] + 1 ][2] ;===================================================================================== $bias_h1[0][0] = "id" $bias_h1[0][1] = "bias" For $x = 1 To UBound($bias_h1,1) - 1 $bias_h1[$x][0] = $x $bias_h1[$x][1] = 1 Next ad($bias_h1,"$bias_h1", False) ;===================================================================================== If IsDeclared("bias_h2") Then $bias_h2 = 0 Global $bias_h2[$settings[2][1] + 1 ][2] ;===================================================================================== $bias_h2[0][0] = "id" $bias_h2[0][1] = "bias" For $x = 1 To UBound($bias_h2,1) - 1 $bias_h2[$x][0] = $x $bias_h2[$x][1] = 1 Next ad($bias_h2,"$bias_h2", False) ;===================================================================================== If IsDeclared("bias_o") Then $bias_o = 0 Global $bias_o[$settings[3][1] + 1 ][2] ;===================================================================================== $bias_o[0][0] = "id" $bias_o[0][1] = "bias" For $x = 1 To UBound($bias_o,1) - 1 $bias_o[$x][0] = $x $bias_o[$x][1] = 1 Next ad($bias_o,"$bias_o", False) ;===================================================================================== If IsDeclared("outputs_h1") Then $outputs_h1 = 0 Global $outputs_h1[$settings[1][1] + 1 ][2] ;===================================================================================== $outputs_h1[0][0] = "id" $outputs_h1[0][1] = "$outputs_h1" For $x = 1 To UBound($outputs_h1,1) - 1 $outputs_h1[$x][0] = $x Next ad($outputs_h1,"$outputs_h1", False) ;===================================================================================== If IsDeclared("outputs_h2") Then $outputs_h2 = 0 Global $outputs_h2[$settings[2][1] + 1 ][2] ;===================================================================================== $outputs_h2[0][0] = "id" $outputs_h2[0][1] = "$outputs_h2" For $x = 1 To UBound($outputs_h2,1) - 1 $outputs_h2[$x][0] = $x Next ad($outputs_h2,"$outputs_h2", False) ;===================================================================================== If IsDeclared("outputs_o") Then $outputs_o = 0 Global $outputs_o[$settings[3][1] + 1 ][2] ;===================================================================================== $outputs_o[0][0] = "id" $outputs_o[0][1] = "$outputs_o" For $x = 1 To UBound($outputs_o,1) - 1 $outputs_o[$x][0] = $x Next ad($outputs_o,"$outputs_o", False) ;===================================================================================== If IsDeclared("outputs_os") Then $outputs_os = 0 Global $outputs_os[$settings[3][1] + 1 ][2] ;===================================================================================== $outputs_os[0][0] = "id" $outputs_os[0][1] = "$outputs_os" For $x = 1 To UBound($outputs_os,1) - 1 $outputs_os[$x][0] = $x Next ad($outputs_os,"$outputs_os", False) EndFunc Func Globals_backward() ;for back ;~ Global $target_o[3][2] ;~ Global $error_h1[4][2] ;~ Global $error_h2[4][2] ;~ Global $error_o[3][2] ;~ Global $dsig_h1[4][2] ;~ Global $dsig_h2[4][2] ;~ Global $dsig_o[3][2] ;~ Global $grad_h1[4][2] ;~ Global $grad_h2[4][2] ;~ Global $grad_o[3][2] ;~ Global $delta_h1[4][2] ;~ Global $delta_h2[4][2] ;~ Global $delta_o[3][2] ;===================================================================================== If IsDeclared("target_o") Then $target_o = 0 Global $target_o[$settings[3][1] + 1 ][2] ;===================================================================================== $target_o[0][0] = "id" $target_o[0][1] = "$target_o" For $x = 1 To UBound($target_o,1) - 1 $target_o[$x][0] = $x $target_o[$x][1] = 0 Next $target_o[Random(1 , UBound($target_o,1) - 1 , 1)][1] = 1 ad($target_o,"$target_o",False) ;===================================================================================== If IsDeclared("error_h1") Then $error_h1 = 0 Global $error_h1[$settings[1][1] + 1 ][2] ;===================================================================================== $error_h1[0][0] = "id" $error_h1[0][1] = "err" For $x = 1 To UBound($error_h1,1) - 1 $error_h1[$x][0] = $x Next ad($error_h1,"$error_h1",False) ;===================================================================================== If IsDeclared("error_h2") Then $error_h2 = 0 Global $error_h2[$settings[2][1] + 1 ][2] ;===================================================================================== $error_h2[0][0] = "id" $error_h2[0][1] = "err" For $x = 1 To UBound($error_h2,1) - 1 $error_h2[$x][0] = $x Next ad($error_h2,"$error_h2",False) ;===================================================================================== If IsDeclared("error_o") Then $error_o = 0 Global $error_o[$settings[3][1] + 1 ][2] ;===================================================================================== $error_o[0][0] = "id" $error_o[0][1] = "err" For $x = 1 To UBound($error_o,1) - 1 $error_o[$x][0] = $x Next ad($error_o,"$error_o",False) ;===================================================================================== If IsDeclared("dsig_h1") Then $dsig_h1 = 0 Global $dsig_h1[$settings[1][1] + 1 ][2] ;===================================================================================== $dsig_h1[0][0] = "id" $dsig_h1[0][1] = "$dsig_h1" For $x = 1 To UBound($dsig_h1,1) - 1 $dsig_h1[$x][0] = $x Next ad($dsig_h1,"$dsig_h1",False) ;===================================================================================== If IsDeclared("dsig_h2") Then $dsig_h2 = 0 Global $dsig_h2[$settings[2][1] + 1 ][2] ;===================================================================================== $dsig_h2[0][0] = "id" $dsig_h2[0][1] = "dsig" For $x = 1 To UBound($dsig_h2,1) - 1 $dsig_h2[$x][0] = $x Next ad($dsig_h2,"$dsig_h2",False) ;===================================================================================== If IsDeclared("dsig_o") Then $dsig_o = 0 Global $dsig_o[$settings[3][1] + 1 ][2] ;===================================================================================== $dsig_o[0][0] = "id" $dsig_o[0][1] = "dsig" For $x = 1 To UBound($dsig_o,1) - 1 $dsig_o[$x][0] = $x Next ad($dsig_o,"$dsig_o",False) ;===================================================================================== If IsDeclared("grad_h1") Then $grad_h1 = 0 Global $grad_h1[$settings[1][1] + 1 ][2] ;===================================================================================== $grad_h1[0][0] = "id" $grad_h1[0][1] = "$grad_h1" For $x = 1 To UBound($grad_h1,1) - 1 $grad_h1[$x][0] = $x Next ad($grad_h1,"$grad_h1",False) ;===================================================================================== If IsDeclared("grad_h2") Then $grad_h2 = 0 Global $grad_h2[$settings[2][1] + 1 ][2] ;===================================================================================== $grad_h2[0][0] = "id" $grad_h2[0][1] = "$grad_h2" For $x = 1 To UBound($grad_h2,1) - 1 $grad_h2[$x][0] = $x Next ad($grad_h2,"$grad_h2",False) ;===================================================================================== If IsDeclared("grad_o") Then $grad_o = 0 Global $grad_o[$settings[3][1] + 1 ][2] ;===================================================================================== $grad_o[0][0] = "id" $grad_o[0][1] = "$grad_o" For $x = 1 To UBound($grad_o,1) - 1 $grad_o[$x][0] = $x Next ad($grad_o,"$grad_o",False) ;===================================================================================== If IsDeclared("delta_h1") Then $delta_h1 = 0 Global $delta_h1[$settings[1][1] + 1 ][2] ;===================================================================================== $delta_h1[0][0] = "id" $delta_h1[0][1] = "$delta_h1" For $x = 1 To UBound($delta_h1,1) - 1 $delta_h1[$x][0] = $x Next ad($delta_h1,"$delta_h1",False) ;===================================================================================== If IsDeclared("delta_h2") Then $delta_h2 = 0 Global $delta_h2[$settings[2][1] + 1 ][2] ;===================================================================================== $delta_h2[0][0] = "id" $delta_h2[0][1] = "$delta_h2" For $x = 1 To UBound($delta_h2,1) - 1 $delta_h2[$x][0] = $x Next ad($delta_h2,"$delta_h2",False) ;===================================================================================== If IsDeclared("delta_o") Then $delta_o = 0 Global $delta_o[$settings[3][1] + 1 ][2] ;===================================================================================== $delta_o[0][0] = "id" $delta_o[0][1] = "$delta_o" For $x = 1 To UBound($delta_o,1) - 1 $delta_o[$x][0] = $x Next ad($delta_o,"$delta_o",False) EndFunc Func Globals_settings() Global $settings[27][2] = [ _ ["input_layer",784], _ ["hidden_layer_1",16], _ ["hidden_layer_2",16], _ ["outputlayer",10], _ ["input_min",0], _ ["input_max",255], _ ["learning_rate",0.01], _ ["correct",0], _ ["wrong",0], _ ["$settings_copy",@ScriptDir & "\Base\settings.set"], _ ["$results_copy",@ScriptDir & "\Base\results.res"], _ ["$weights_ih1_copy",@ScriptDir & "\Base\wheights.ih1"], _ ["$weights_h1h2_copy",@ScriptDir & "\Base\wheights.h1h2"], _ ["$weights_h2o_copy",@ScriptDir & "\Base\wheights.h2o"], _ ["$bias_h1_copy",@ScriptDir & "\Base\bias.h1"], _ ["$bias_h2_copy",@ScriptDir & "\Base\bias.h2"], _ ["$bias_o_copy",@ScriptDir & "\Base\bias.o"], _ ["$raw_input_test",@ScriptDir & "\Base\t10k-images.idx3-ubyte"], _ ["$raw_label_test",@ScriptDir & "\Base\t10k-labels.idx1-ubyte"], _ ["$raw_input_train",@ScriptDir & "\Base\train-images.idx3-ubyte"], _ ["$raw_label_train",@ScriptDir & "\Base\train-labels.idx1-ubyte"], _ ["percentage_good",0], _ ["total_percentage",0], _ ["total_run_times",0], _ ["total_backed_times",0], _ ["total_loop_times",0], _ ["mutate_percentage",0.01]] EndFunc ;- Func gui_iputfield() ; Array to hold button ControlIDs $guifield = GUICreate("Form1", 540, 540, 181, 125) Local $x = 0 For $y = 0 To 27 For $z = 0 To 27 $Checkbox[$x] = GUICtrlCreateCheckbox("", 10 + ( 18 * $z) , 10 + ( 18 * $y ) , 17, 17) $x += 1 Next Next $button1_1 = GUICtrlCreateButton("test 1", 216, 515, 75, 25) GUISetState() For $x = 1 To UBound($inputs , 1 ) - 1 If $inputs[$x][1] <> 0 Then GUICtrlSetState($Checkbox[$x - 1], $GUI_CHECKED) EndIf Next EndFunc