Rev 9733 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 9733 | Rev 9821 | ||
---|---|---|---|
Line 98... | Line 98... | ||
98 | txt_c_size db '"c_size"',0 |
98 | txt_c_size db '"c_size"',0 |
99 | txt_n_size db '"n_size"',0 |
99 | txt_n_size db '"n_size"',0 |
100 | txt_biases db '"biases"',0 |
100 | txt_biases db '"biases"',0 |
101 | txt_weights db '"weights"',0 |
101 | txt_weights db '"weights"',0 |
Line -... | Line 102... | ||
- | 102 | ||
- | 103 | txt_err_layers_neq db 'number of layers does not match',0 |
|
- | 104 | txt_err_c_size db "not found value 'c_size'",0 |
|
- | 105 | txt_err_sqbrl_b1 db "not found opening '[' for biases",0 |
|
- | 106 | txt_err_sqbrl_w1 db "not found opening '[' for weights",0 |
|
- | 107 | txt_err_sqbrl_w2 db "not found opening '[[' for weights",0 |
|
- | 108 | txt_err_sqbrr_w2 db "not found closing ']]' for weights",0 |
|
102 | 109 | ||
103 | align 16 |
110 | align 16 |
104 | proc lib_init |
111 | proc lib_init |
105 | mov [mem.alloc], eax |
112 | mov [mem.alloc], eax |
106 | mov [mem.free], ebx |
113 | mov [mem.free], ebx |
Line 230... | Line 237... | ||
230 | mov eax,dsigmoid |
237 | mov eax,dsigmoid |
231 | @@: |
238 | @@: |
232 | mov dword[edx+NeuralNetwork.derivative],eax |
239 | mov dword[edx+NeuralNetwork.derivative],eax |
233 | mov eax,[ebp+32] ;sizes_length |
240 | mov eax,[ebp+32] ;sizes_length |
234 | imul eax,sizeof.Layer |
241 | imul eax,sizeof.Layer |
235 | push eax |
- | |
236 | call @$bnwa$qui |
242 | stdcall @$bnwa$qui,eax |
237 | pop ecx |
243 | pop ecx |
238 | mov edx,[ebp+8] ;o |
244 | mov edx,[ebp+8] ;o |
239 | mov dword[edx+NeuralNetwork.layers],eax |
245 | mov dword[edx+NeuralNetwork.layers],eax |
240 | mov ecx,[ebp+8] ;o |
246 | mov ecx,[ebp+8] ;o |
241 | mov eax,[ebp+32] ;sizes_length |
247 | mov eax,[ebp+32] ;sizes_length |
242 | mov dword[ecx+NeuralNetwork.layers_length],eax |
248 | mov dword[ecx+NeuralNetwork.layers_length],eax |
243 | xor edi,edi |
249 | xor edi,edi ;i=0 |
244 | mov eax,[ebp+28] ;sizes |
250 | mov eax,[ebp+28] ;sizes |
245 | lea edx,[eax+4] |
251 | lea edx,[eax+4] |
246 | mov dword[ebp-8],edx |
252 | mov dword[ebp-8],edx ;save &sizes[i+1] |
247 | jmp .150 |
253 | jmp .150 |
248 | .149: |
254 | .cycle_0: ;for (i=0; i < sizes_length; i++) |
249 | xor ecx,ecx |
255 | xor ecx,ecx |
250 | mov dword[ebp-4],ecx |
256 | mov dword[ebp-4],ecx ;nextSize = 0 |
251 | mov eax,[ebp+32] ;sizes_length |
257 | mov eax,[ebp+32] ;sizes_length |
252 | dec eax |
258 | dec eax |
253 | cmp edi,eax |
259 | cmp edi,eax |
254 | jae .152 |
260 | jae .152 |
255 | mov edx,[ebp-8] |
261 | mov edx,[ebp-8] |
256 | mov ecx,[edx] |
262 | mov ecx,[edx] |
257 | mov dword[ebp-4],ecx |
263 | mov dword[ebp-4],ecx ;nextSize = sizes[i+1] |
258 | .152: |
264 | .152: |
259 | mov eax,[ebp-4] |
265 | mov eax,[ebp-4] |
260 | push eax |
266 | push eax |
261 | mov edx,[ebp-8] |
267 | mov edx,[ebp-8] |
262 | mov ecx,[edx-4] |
268 | mov ecx,[edx-4] |
263 | push ecx |
269 | push ecx |
264 | mov ecx,edi |
270 | mov ecx,edi |
265 | shl ecx,2 |
271 | imul ecx,sizeof.Layer |
266 | mov eax,[ebp+8] ;o |
272 | mov eax,[ebp+8] ;o |
267 | mov edx,[eax+NeuralNetwork.layers] |
273 | mov edx,[eax+NeuralNetwork.layers] |
268 | lea ecx,[ecx+4*ecx] |
- | |
269 | add edx,ecx |
274 | add edx,ecx |
270 | push edx |
- | |
271 | call Layer_Create |
275 | stdcall Layer_Create,edx |
272 | xor esi,esi |
276 | xor esi,esi ;j=0 |
273 | mov eax,[ebp-8] |
277 | mov eax,[ebp-8] |
274 | lea edx,[eax-4] |
278 | lea edx,[eax-4] |
275 | mov dword[ebp-12],edx |
279 | mov dword[ebp-12],edx ;save &sizes[i] |
276 | jmp .154 |
280 | jmp .154 |
277 | .153: |
281 | .cycle_1: ;for (j=0; j < sizes[i]; j++) |
278 | call Math_random |
282 | call Math_random |
279 | fmul dword[f_2_0] |
283 | fmul dword[f_2_0] |
280 | fsub dword[f_1_0] |
284 | fsub dword[f_1_0] |
281 | mov eax,[ebp+8] ;o |
285 | mov eax,[ebp+8] ;o |
282 | lea ecx,[edi+4*edi] |
286 | mov ecx,edi |
283 | xor ebx,ebx |
287 | imul ecx,sizeof.Layer |
284 | mov edx,[eax+NeuralNetwork.layers] |
288 | add ecx,[eax+NeuralNetwork.layers] |
285 | mov ecx,[edx+4*ecx+12] |
289 | mov ecx,[ecx+Layer.biases] |
286 | fstp qword[ecx+8*esi] |
290 | fstp qword[ecx+8*esi] |
- | 291 | xor ebx,ebx ;k=0 |
|
287 | cmp ebx,[ebp-4] |
292 | cmp ebx,[ebp-4] |
288 | jae .157 |
293 | jae .157 |
289 | @@: |
294 | @@: ;for (k=0; k < nextSize; k++) |
290 | call Math_random |
295 | call Math_random |
291 | fmul dword[f_2_0] |
296 | fmul dword[f_2_0] |
292 | fsub dword[f_1_0] |
297 | fsub dword[f_1_0] |
293 | lea eax,[edi+4*edi] |
298 | mov eax,edi |
- | 299 | imul eax,sizeof.Layer |
|
294 | mov edx,[ebp+8] ;o |
300 | mov edx,[ebp+8] ;o |
295 | mov ecx,[edx+NeuralNetwork.layers] |
301 | mov ecx,[edx+NeuralNetwork.layers] |
296 | mov eax,[ecx+4*eax+16] |
302 | mov eax,[ecx+eax+Layer.weights] |
297 | mov edx,[eax+4*esi] |
303 | mov edx,[eax+4*esi] |
298 | fstp qword[edx+8*ebx] |
304 | fstp qword[edx+8*ebx] |
299 | inc ebx |
305 | inc ebx |
300 | cmp ebx,[ebp-4] |
306 | cmp ebx,[ebp-4] |
301 | jb @b |
307 | jb @b |
302 | .157: |
308 | .157: |
303 | inc esi |
309 | inc esi |
304 | .154: |
310 | .154: |
305 | mov ecx,[ebp-12] |
311 | mov ecx,[ebp-12] |
306 | cmp esi,[ecx] |
312 | cmp esi,[ecx] |
307 | jb .153 |
313 | jb .cycle_1 |
308 | inc edi |
314 | inc edi |
309 | add dword[ebp-8],4 |
315 | add dword[ebp-8],4 |
310 | .150: |
316 | .150: |
311 | cmp edi,[ebp+32] ;sizes_length |
317 | cmp edi,[ebp+32] ;sizes_length |
312 | jb .149 |
318 | jb .cycle_0 |
313 | ;create errors array |
319 | ;create errors array |
314 | push dword[ebp+8] |
320 | push dword[ebp+8] |
315 | call NNP_GetMaxLLen |
321 | call NNP_GetMaxLLen |
316 | mov esi,eax |
322 | mov esi,eax |
317 | shl esi,4 |
323 | shl esi,4 |
318 | push esi |
- | |
319 | call @$bnwa$qui |
324 | stdcall @$bnwa$qui,esi |
320 | pop ecx |
325 | pop ecx |
321 | mov edx,[ebp+8] |
326 | mov edx,[ebp+8] |
322 | mov dword[edx+NeuralNetwork.errors],eax |
327 | mov dword[edx+NeuralNetwork.errors],eax |
323 | shr esi,1 |
328 | shr esi,1 |
324 | add eax,esi |
329 | add eax,esi |
325 | mov dword[edx+NeuralNetwork.errorsNext],eax |
330 | mov dword[edx+NeuralNetwork.errorsNext],eax |
326 | ;create gradients array |
331 | ;create gradients array |
327 | push esi |
- | |
328 | call @$bnwa$qui |
332 | stdcall @$bnwa$qui,esi |
329 | pop ecx |
333 | pop ecx |
330 | mov edx,[ebp+8] |
334 | mov edx,[ebp+8] |
331 | mov dword[edx+NeuralNetwork.gradients],eax |
335 | mov dword[edx+NeuralNetwork.gradients],eax |
332 | ;create deltas array |
336 | ;create deltas array |
333 | shr esi,1 |
337 | shr esi,1 |
334 | push esi |
- | |
335 | call @$bnwa$qui |
338 | stdcall @$bnwa$qui,esi |
336 | pop ecx |
339 | pop ecx |
337 | mov edx,[ebp+8] |
340 | mov edx,[ebp+8] |
338 | mov dword[edx+NeuralNetwork.deltas],eax |
341 | mov dword[edx+NeuralNetwork.deltas],eax |
339 | pop edi esi ebx |
342 | pop edi esi ebx |
340 | mov esp,ebp |
343 | mov esp,ebp |
Line 344... | Line 347... | ||
344 | f_2_0: |
347 | f_2_0: |
345 | dd 2.0 |
348 | dd 2.0 |
346 | f_1_0: |
349 | f_1_0: |
347 | dd 1.0 |
350 | dd 1.0 |
Line -... | Line 351... | ||
- | 351 | ||
- | 352 | ;заполнение случайными числами |
|
- | 353 | ;+ 8 NeuralNetwork* o |
|
- | 354 | align 16 |
|
- | 355 | NNP_Reset: |
|
- | 356 | push ebp |
|
- | 357 | mov ebp,esp |
|
- | 358 | add esp,-8 |
|
- | 359 | push ebx esi edi |
|
- | 360 | ||
- | 361 | xor edi,edi ;i=0 |
|
- | 362 | jmp .3 |
|
- | 363 | .cycle_0: ;for (i=0; i < o->layers_length; i++) |
|
- | 364 | xor esi,esi ;j=0 |
|
- | 365 | mov eax,edi |
|
- | 366 | imul eax,sizeof.Layer |
|
- | 367 | mov edx,[ebp+8] |
|
- | 368 | add eax,[edx+NeuralNetwork.layers] |
|
- | 369 | mov edx,[eax+Layer.n_size] |
|
- | 370 | mov [ebp-4],edx |
|
- | 371 | mov edx,[eax+Layer.c_size] |
|
- | 372 | mov [ebp-8],edx |
|
- | 373 | jmp .2 |
|
- | 374 | .cycle_1: ;for (j=0; j < o->layers[i].c_size; j++) |
|
- | 375 | call Math_random |
|
- | 376 | fmul dword[f_2_0] |
|
- | 377 | fsub dword[f_1_0] |
|
- | 378 | mov eax,[ebp+8] ;o |
|
- | 379 | mov ecx,edi |
|
- | 380 | imul ecx,sizeof.Layer |
|
- | 381 | add ecx,[eax+NeuralNetwork.layers] |
|
- | 382 | mov ecx,[ecx+Layer.biases] |
|
- | 383 | fstp qword[ecx+8*esi] |
|
- | 384 | xor ebx,ebx ;k=0 |
|
- | 385 | cmp ebx,[ebp-4] |
|
- | 386 | jae .1 |
|
- | 387 | @@: ;for (k=0; k < o->layers[i].n_size; k++) |
|
- | 388 | call Math_random |
|
- | 389 | fmul dword[f_2_0] |
|
- | 390 | fsub dword[f_1_0] |
|
- | 391 | mov eax,edi |
|
- | 392 | imul eax,sizeof.Layer |
|
- | 393 | mov edx,[ebp+8] ;o |
|
- | 394 | add eax,[edx+NeuralNetwork.layers] |
|
- | 395 | mov eax,[eax+Layer.weights] |
|
- | 396 | mov edx,[eax+4*esi] ;edx = &o->layers[i].weights[j] |
|
- | 397 | fstp qword[edx+8*ebx] ;o->layers[i].weights[j][k] = Math_random()*2.0-1.0; |
|
- | 398 | inc ebx ;k++ |
|
- | 399 | cmp ebx,[ebp-4] |
|
- | 400 | jb @b |
|
- | 401 | .1: |
|
- | 402 | inc esi ;j++ |
|
- | 403 | .2: |
|
- | 404 | cmp esi,[ebp-8] |
|
- | 405 | jb .cycle_1 |
|
- | 406 | inc edi ;i++ |
|
- | 407 | .3: |
|
- | 408 | mov ecx,[ebp+8] ;o |
|
- | 409 | cmp edi,[ecx+NeuralNetwork.layers_length] |
|
- | 410 | jb .cycle_0 |
|
- | 411 | pop edi esi ebx |
|
- | 412 | mov esp,ebp |
|
- | 413 | pop ebp |
|
- | 414 | ret 4 |
|
- | 415 | ||
348 | 416 | ;расчет входных и выходных нейронов |
|
349 | ;+ 8 NeuralNetwork* o |
417 | ;+ 8 NeuralNetwork* o |
350 | ;+12 double* inputs |
418 | ;+12 double* inputs |
351 | align 16 |
419 | align 16 |
352 | NNP_FeedForward: |
420 | NNP_FeedForward: |
Line 619... | Line 687... | ||
619 | NNP_GetMemData: |
687 | NNP_GetMemData: |
620 | push ebp |
688 | push ebp |
621 | mov ebp,esp |
689 | mov ebp,esp |
622 | add esp,-12 |
690 | add esp,-12 |
623 | push ebx esi edi |
691 | push ebx esi edi |
624 | cmp dword[ebp+12],1852797802 |
692 | cmp dword[ebp+12],NNP_FF_JSON |
625 | jne .end_f |
693 | jne .end_f |
626 | mov esi,[ebp+16] |
694 | mov esi,[ebp+16] |
627 | mov byte[esi],0 |
695 | mov byte[esi],0 |
628 | stdcall [_strcat], esi,txt_QlearningRateQ_ |
696 | stdcall [_strcat], esi,txt_QlearningRateQ_ |
629 | add esp,8 |
697 | add esp,8 |
Line 663... | Line 731... | ||
663 | call @@strlen$qpxc |
731 | call @@strlen$qpxc |
664 | pop ecx |
732 | pop ecx |
665 | add esi,eax |
733 | add esi,eax |
666 | stdcall [_strcat], esi,txt_nl_t_Qc_sizeQ |
734 | stdcall [_strcat], esi,txt_nl_t_Qc_sizeQ |
667 | add esp,8 |
735 | add esp,8 |
668 | lea ebx,[edi+4*edi] |
736 | mov ebx,edi |
- | 737 | imul ebx,sizeof.Layer |
|
669 | push 1 |
738 | push 1 |
670 | push 0 |
739 | push 0 |
671 | mov eax,[ebp+8] |
740 | mov edx,[ebp+8] |
672 | mov edx,[eax+8] |
741 | mov edx,[edx+NeuralNetwork.layers] |
673 | xor eax,eax |
742 | xor eax,eax |
674 | add esp,-8 |
743 | add esp,-8 |
675 | mov ecx,[edx+4*ebx] |
744 | mov ecx,[edx+ebx+Layer.c_size] |
676 | mov dword[ebp-12],ecx |
745 | mov dword[ebp-12],ecx |
677 | mov dword[ebp-8],eax |
746 | mov dword[ebp-8],eax |
678 | fild qword[ebp-12] |
747 | fild qword[ebp-12] |
679 | fstp qword[esp] |
748 | fstp qword[esp] |
680 | call @@DoubleToStr$qduso |
749 | call @@DoubleToStr$qduso |
Line 683... | Line 752... | ||
683 | add esp,8 |
752 | add esp,8 |
684 | stdcall [_strcat], esi,txt_zap_nl_t_Qn_sizeQ |
753 | stdcall [_strcat], esi,txt_zap_nl_t_Qn_sizeQ |
685 | add esp,8 |
754 | add esp,8 |
686 | push 1 |
755 | push 1 |
687 | push 0 |
756 | push 0 |
688 | mov edx,[ebp+8] |
757 | mov ecx,[ebp+8] |
689 | mov ecx,[edx+8] |
758 | mov ecx,[ecx+NeuralNetwork.layers] |
690 | xor edx,edx |
759 | xor edx,edx |
691 | add esp,-8 |
760 | add esp,-8 |
692 | mov eax,[ecx+4*ebx+4] |
761 | mov eax,[ecx+ebx+Layer.n_size] |
693 | mov dword[ebp-12],eax |
762 | mov dword[ebp-12],eax |
694 | mov dword[ebp-8],edx |
763 | mov dword[ebp-8],edx |
695 | fild qword[ebp-12] |
764 | fild qword[ebp-12] |
696 | fstp qword[esp] |
765 | fstp qword[esp] |
697 | call @@DoubleToStr$qduso |
766 | call @@DoubleToStr$qduso |
Line 711... | Line 780... | ||
711 | stdcall [_strcat], esi,txt_zap_sp |
780 | stdcall [_strcat], esi,txt_zap_sp |
712 | add esp,8 |
781 | add esp,8 |
713 | .235: |
782 | .235: |
714 | push 1 |
783 | push 1 |
715 | push PRECISION |
784 | push PRECISION |
716 | lea eax,[edi+4*edi] |
785 | mov eax,edi |
- | 786 | imul eax,sizeof.Layer |
|
717 | mov edx,[ebp+8] |
787 | mov edx,[ebp+8] |
718 | mov ecx,[edx+8] |
788 | mov ecx,[edx+NeuralNetwork.layers] |
719 | mov eax,[ecx+4*eax+8] |
789 | mov eax,[ecx+eax+Layer.neurons] |
720 | push dword[eax+8*ebx+4] |
790 | push dword[eax+8*ebx+4] |
721 | push dword[eax+8*ebx] |
791 | push dword[eax+8*ebx] |
722 | call @@DoubleToStr$qduso |
792 | call @@DoubleToStr$qduso |
723 | add esp,16 |
793 | add esp,16 |
724 | stdcall [_strcat], esi,eax |
794 | stdcall [_strcat], esi,eax |
Line 744... | Line 814... | ||
744 | stdcall [_strcat], esi,txt_zap_sp |
814 | stdcall [_strcat], esi,txt_zap_sp |
745 | add esp,8 |
815 | add esp,8 |
746 | .239: |
816 | .239: |
747 | push 1 |
817 | push 1 |
748 | push PRECISION |
818 | push PRECISION |
749 | lea eax,[edi+4*edi] |
819 | mov eax,edi |
- | 820 | imul eax,sizeof.Layer |
|
750 | mov edx,[ebp+8] |
821 | mov edx,[ebp+8] |
751 | mov ecx,[edx+8] |
822 | add eax,[edx+NeuralNetwork.layers] |
752 | mov eax,[ecx+4*eax+12] |
823 | mov eax,[eax+Layer.biases] |
753 | push dword[eax+8*ebx+4] |
824 | push dword[eax+8*ebx+4] |
754 | push dword[eax+8*ebx] |
825 | push dword[eax+8*ebx] |
755 | call @@DoubleToStr$qduso |
826 | call @@DoubleToStr$qduso |
756 | add esp,16 |
827 | add esp,16 |
757 | stdcall [_strcat], esi,eax |
828 | stdcall [_strcat], esi,eax |
758 | add esp,8 |
829 | add esp,8 |
759 | inc ebx |
830 | inc ebx |
760 | .238: |
831 | .238: |
761 | lea ecx,[edi+4*edi] |
832 | mov ecx,edi |
- | 833 | imul ecx,sizeof.Layer |
|
762 | mov eax,[ebp+8] |
834 | mov eax,[ebp+8] |
763 | mov edx,[eax+8] |
835 | add ecx,[eax+NeuralNetwork.layers] |
764 | cmp ebx,[edx+4*ecx] |
836 | cmp ebx,[ecx+Layer.c_size] |
765 | jb .cycle_2 |
837 | jb .cycle_2 |
766 | stdcall [_strcat], esi,txt_sqbr_zap_t_QweightsQ |
838 | stdcall [_strcat], esi,txt_sqbr_zap_t_QweightsQ |
767 | add esp,8 |
839 | add esp,8 |
768 | mov eax,[ebp+8] |
840 | mov eax,[ebp+8] |
769 | lea ecx,[edi+4*edi] |
841 | mov ecx,edi |
770 | mov edx,[eax+8] |
842 | imul ecx,sizeof.Layer |
- | 843 | add ecx,[eax+NeuralNetwork.layers] |
|
771 | cmp dword[edx+4*ecx+4],0 |
844 | cmp dword[ecx+Layer.n_size],0 |
772 | je .241 |
845 | je .241 |
773 | xor ebx,ebx |
846 | xor ebx,ebx |
774 | jmp .243 |
847 | jmp .243 |
775 | .242: |
848 | .242: |
776 | test ebx,ebx |
849 | test ebx,ebx |
Line 789... | Line 862... | ||
789 | stdcall [_strcat], esi,txt_zap_sp |
862 | stdcall [_strcat], esi,txt_zap_sp |
790 | add esp,8 |
863 | add esp,8 |
791 | .247: |
864 | .247: |
792 | push 1 |
865 | push 1 |
793 | push PRECISION |
866 | push PRECISION |
794 | lea edx,[edi+4*edi] |
867 | mov edx,edi |
795 | mov ecx,[ebp+8] |
868 | imul edx,sizeof.Layer |
796 | mov eax,[ecx+8] |
869 | mov eax,[ebp+8] |
- | 870 | add edx,[eax+NeuralNetwork.layers] |
|
797 | mov edx,[eax+4*edx+16] |
871 | mov edx,[edx+Layer.weights] |
798 | mov ecx,[edx+4*ebx] |
872 | mov ecx,[edx+4*ebx] |
799 | mov eax,[ebp-4] |
873 | mov eax,[ebp-4] |
800 | push dword[ecx+8*eax+4] |
874 | push dword[ecx+8*eax+4] |
801 | push dword[ecx+8*eax] |
875 | push dword[ecx+8*eax] |
802 | @@: |
876 | @@: |
Line 809... | Line 883... | ||
809 | add esp,16 |
883 | add esp,16 |
810 | stdcall [_strcat], esi,eax |
884 | stdcall [_strcat], esi,eax |
811 | add esp,8 |
885 | add esp,8 |
812 | inc dword[ebp-4] |
886 | inc dword[ebp-4] |
813 | .246: |
887 | .246: |
814 | lea ecx,[edi+4*edi] |
888 | mov ecx,edi |
- | 889 | imul ecx,sizeof.Layer |
|
815 | mov eax,[ebp+8] |
890 | mov eax,[ebp+8] |
816 | mov edx,[eax+8] |
891 | add ecx,[eax+NeuralNetwork.layers] |
817 | mov ecx,[edx+4*ecx+4] |
892 | mov ecx,[ecx+Layer.n_size] |
818 | cmp ecx,[ebp-4] |
893 | cmp ecx,[ebp-4] |
819 | ja .245 |
894 | ja .245 |
820 | stdcall [_strcat], esi,txt_sqbr |
895 | stdcall [_strcat], esi,txt_sqbr |
821 | add esp,8 |
896 | add esp,8 |
822 | inc ebx |
897 | inc ebx |
823 | .243: |
898 | .243: |
824 | lea eax,[edi+4*edi] |
899 | mov eax,edi |
825 | mov edx,[ebp+8] |
900 | imul eax,sizeof.Layer |
826 | mov ecx,[edx+8] |
901 | mov ecx,[ebp+8] |
- | 902 | add eax,[ecx+NeuralNetwork.layers] |
|
827 | cmp ebx,[ecx+4*eax] |
903 | cmp ebx,[eax+Layer.c_size] |
828 | jb .242 |
904 | jb .242 |
829 | .241: |
905 | .241: |
830 | stdcall [_strcat], esi,txt_sqbr_fbr_zap |
906 | stdcall [_strcat], esi,txt_sqbr_fbr_zap |
831 | add esp,8 |
907 | add esp,8 |
832 | inc edi |
908 | inc edi |
Line 850... | Line 926... | ||
850 | push ebx esi |
926 | push ebx esi |
851 | mov ebx,[ebp+8] |
927 | mov ebx,[ebp+8] |
852 | cmp dword[ebx+NeuralNetwork.layers_length],1 |
928 | cmp dword[ebx+NeuralNetwork.layers_length],1 |
853 | jge .1 |
929 | jge .1 |
854 | xor eax,eax |
930 | xor eax,eax |
855 | jmp .5 |
931 | jmp .end_f |
856 | .1: |
932 | .1: |
857 | mov edx,[ebx+NeuralNetwork.layers] |
933 | mov edx,[ebx+NeuralNetwork.layers] |
858 | mov eax,[ebx+NeuralNetwork.layers] |
- | |
859 | add eax,sizeof.Layer |
934 | lea eax,[edx+sizeof.Layer] |
860 | mov ecx,[edx] |
935 | mov ecx,[edx] |
861 | mov edx,1 |
936 | mov edx,1 ;i=1 |
862 | jmp .4 |
937 | jmp .3 |
863 | .2: |
- | |
- | 938 | .cycle_0: ;for (i=1; i < o->layers_length; i++) |
|
864 | mov esi,[eax] |
939 | mov esi,[eax] |
865 | cmp esi,ecx |
940 | cmp esi,ecx |
866 | jbe .3 |
941 | jbe .2 |
867 | mov ecx,esi |
942 | mov ecx,esi |
868 | .3: |
943 | .2: |
869 | inc edx |
944 | inc edx |
870 | add eax,sizeof.Layer |
945 | add eax,sizeof.Layer |
871 | .4: |
946 | .3: |
872 | cmp edx,[ebx+NeuralNetwork.layers_length] |
947 | cmp edx,[ebx+NeuralNetwork.layers_length] |
873 | jl .2 |
948 | jl .cycle_0 |
874 | mov eax,ecx |
949 | mov eax,ecx |
875 | .5: |
950 | .end_f: |
876 | pop esi ebx ebp |
951 | pop esi ebx ebp |
877 | ret 4 |
952 | ret 4 |
Line 878... | Line 953... | ||
878 | 953 | ||
879 | ;+ 8 NeuralNetwork* o |
954 | ;+ 8 NeuralNetwork* o |
Line 932... | Line 1007... | ||
932 | ;add esp,12 |
1007 | ;add esp,12 |
933 | mov eax,[ebp+8] |
1008 | mov eax,[ebp+8] |
934 | mov edx,[eax+12] |
1009 | mov edx,[eax+12] |
935 | cmp edx,[ebp-4] |
1010 | cmp edx,[ebp-4] |
936 | je .203 |
1011 | je .203 |
937 | mov eax,4 |
1012 | mov eax,txt_err_layers_neq |
938 | jmp .193 |
1013 | jmp .193 |
939 | .203: |
1014 | .203: |
940 | xor edi,edi |
1015 | xor edi,edi ;i=0 |
941 | jmp .205 |
1016 | jmp .205 |
942 | .204: |
1017 | .204: ;for(i=0;i |
943 | stdcall @@strstr$qpxct1, esi,txt_c_size |
1018 | stdcall @@strstr$qpxct1, esi,txt_c_size |
944 | add esp,8 |
1019 | add esp,8 |
945 | mov esi,eax |
1020 | mov esi,eax |
946 | test esi,esi |
1021 | test esi,esi |
947 | jne .206 |
1022 | jne .206 |
948 | mov eax,5 |
1023 | mov eax,txt_err_c_size |
949 | jmp .193 |
1024 | jmp .193 |
950 | .206: |
1025 | .206: |
951 | stdcall @@strchr$qpxci, esi,':' |
1026 | stdcall @@strchr$qpxci, esi,':' |
952 | add esp,8 |
1027 | add esp,8 |
953 | mov ebx,eax |
1028 | mov ebx,eax |
Line 995... | Line 1070... | ||
995 | mov eax,10 |
1070 | mov eax,10 |
996 | jmp .193 |
1071 | jmp .193 |
997 | .211: |
1072 | .211: |
998 | mov byte[esi],0 |
1073 | mov byte[esi],0 |
999 | inc esi |
1074 | inc esi |
1000 | push ebx |
- | |
1001 | call @@StrToInt$qpc |
1075 | stdcall @@StrToInt$qpc,ebx |
1002 | pop ecx |
1076 | pop ecx |
1003 | mov dword[ebp-8],eax |
1077 | mov dword[ebp-8],eax |
1004 | lea eax,[edi+4*edi] |
1078 | mov eax,edi |
- | 1079 | imul eax,sizeof.Layer |
|
1005 | mov edx,[ebp+8] |
1080 | mov edx,[ebp+8] |
1006 | mov ecx,[edx+8] |
1081 | add eax,[edx+NeuralNetwork.layers] |
1007 | mov edx,[ecx+4*eax] |
1082 | mov edx,[eax+Layer.c_size] |
1008 | cmp edx,[ebp-4] |
1083 | cmp edx,[ebp-4] |
1009 | jne .213 |
1084 | jne .213 |
1010 | mov ecx,[ebp+8] |
- | |
1011 | mov edx,[ecx+8] |
- | |
1012 | mov eax,[edx+4*eax+4] |
1085 | mov edx,[eax+Layer.n_size] |
1013 | cmp eax,[ebp-8] |
1086 | cmp edx,[ebp-8] |
1014 | je .214 |
1087 | je .214 |
1015 | .213: |
1088 | .213: |
1016 | mov ecx,[ebp+8] |
1089 | mov ecx,[ebp+8] |
1017 | push ecx |
- | |
1018 | call NNP_GetMaxLLen |
1090 | stdcall NNP_GetMaxLLen,ecx |
1019 | mov ecx,edi |
1091 | mov ecx,edi |
- | 1092 | imul ecx,sizeof.Layer |
|
1020 | mov ebx,eax |
1093 | mov ebx,eax |
1021 | shl ecx,2 |
- | |
1022 | mov eax,[ebp+8] |
1094 | mov eax,[ebp+8] |
1023 | mov edx,[eax+8] |
1095 | mov edx,[eax+NeuralNetwork.layers] |
1024 | lea ecx,[ecx+4*ecx] |
- | |
1025 | add edx,ecx |
1096 | add edx,ecx |
1026 | push edx |
- | |
1027 | call Layer_Destroy |
1097 | stdcall Layer_Destroy,edx |
1028 | mov eax,[ebp-8] |
1098 | mov eax,[ebp-8] |
1029 | push eax |
1099 | push eax |
1030 | mov edx,[ebp-4] |
1100 | mov edx,[ebp-4] |
1031 | push edx |
1101 | push edx |
1032 | mov edx,edi |
1102 | mov edx,edi |
1033 | shl edx,2 |
1103 | imul edx,sizeof.Layer |
1034 | mov ecx,[ebp+8] |
1104 | mov ecx,[ebp+8] |
1035 | mov eax,[ecx+8] |
1105 | mov eax,[ecx+NeuralNetwork.layers] |
1036 | lea edx,[edx+4*edx] |
- | |
1037 | add eax,edx |
1106 | add eax,edx |
1038 | push eax |
- | |
1039 | call Layer_Create |
1107 | stdcall Layer_Create,eax |
1040 | cmp ebx,[ebp-4] ;if(n>s || k>s) |
1108 | cmp ebx,[ebp-4] ;if(n>s || k>s) |
1041 | jb .215 |
1109 | jb .215 |
1042 | cmp ebx,[ebp-8] |
1110 | cmp ebx,[ebp-8] |
1043 | jae .214 |
1111 | jae .214 |
1044 | .215: |
1112 | .215: |
Line 1079... | Line 1147... | ||
1079 | stdcall @@strchr$qpxci, esi,'[' |
1147 | stdcall @@strchr$qpxci, esi,'[' |
1080 | add esp,8 |
1148 | add esp,8 |
1081 | mov ebx,eax |
1149 | mov ebx,eax |
1082 | test ebx,ebx |
1150 | test ebx,ebx |
1083 | jne .217 |
1151 | jne .217 |
1084 | mov eax,12 |
1152 | mov eax,txt_err_sqbrl_b1 |
1085 | jmp .193 |
1153 | jmp .193 |
1086 | .217: |
1154 | .217: |
1087 | inc ebx |
1155 | inc ebx |
1088 | xor edx,edx |
1156 | xor edx,edx |
1089 | mov dword[ebp-8],edx |
1157 | mov dword[ebp-8],edx |
1090 | jmp .219 |
1158 | jmp .219 |
1091 | .218: |
1159 | .218: |
1092 | mov esi,[ebp+8] |
- | |
1093 | dec edx |
1160 | dec edx |
1094 | cmp eax,edx |
1161 | cmp eax,edx |
1095 | lea ecx,[edi+4*edi] |
- | |
1096 | mov esi,[esi+8] |
- | |
1097 | jae .220 |
1162 | jae .220 |
1098 | stdcall @@strchr$qpxci, ebx,',' |
1163 | stdcall @@strchr$qpxci, ebx,',' |
1099 | add esp,8 |
1164 | add esp,8 |
1100 | mov esi,eax |
1165 | mov esi,eax |
1101 | jmp .221 |
1166 | jmp .221 |
Line 1108... | Line 1173... | ||
1108 | jne .222 |
1173 | jne .222 |
1109 | mov eax,13 |
1174 | mov eax,13 |
1110 | jmp .193 |
1175 | jmp .193 |
1111 | .222: |
1176 | .222: |
1112 | mov byte[esi],0 |
1177 | mov byte[esi],0 |
1113 | push ebx |
- | |
1114 | call @@StrToDouble$qpc |
1178 | stdcall @@StrToDouble$qpc,ebx |
1115 | pop ecx |
1179 | pop ecx |
1116 | lea edx,[edi+4*edi] |
1180 | mov edx,edi |
- | 1181 | imul edx,sizeof.Layer |
|
1117 | mov ecx,[ebp+8] |
1182 | mov ecx,[ebp+8] |
1118 | lea ebx,[esi+1] |
1183 | lea ebx,[esi+1] |
1119 | mov eax,[ecx+8] |
1184 | mov eax,[ecx+NeuralNetwork.layers] |
1120 | mov ecx,[ebp-8] |
1185 | mov ecx,[ebp-8] |
1121 | mov edx,[eax+4*edx+12] |
1186 | mov edx,[eax+edx+Layer.biases] |
1122 | fstp qword[edx+8*ecx] |
1187 | fstp qword[edx+8*ecx] |
1123 | inc dword[ebp-8] |
1188 | inc dword[ebp-8] |
1124 | .219: |
1189 | .219: |
1125 | lea edx,[edi+4*edi] |
1190 | mov edx,edi |
- | 1191 | imul edx,sizeof.Layer |
|
1126 | mov ecx,[ebp+8] |
1192 | mov ecx,[ebp+8] |
1127 | mov ecx,[ecx+8] |
1193 | add edx,[ecx+NeuralNetwork.layers] |
1128 | mov edx,[ecx+4*edx] |
1194 | mov edx,[edx+Layer.c_size] |
1129 | mov eax,[ebp-8] |
1195 | mov eax,[ebp-8] |
1130 | cmp edx,eax |
1196 | cmp edx,eax |
1131 | ja .218 |
1197 | ja .218 |
1132 | mov esi,ebx |
1198 | mov esi,ebx |
1133 | stdcall @@strstr$qpxct1, esi,txt_weights |
1199 | stdcall @@strstr$qpxct1, esi,txt_weights |
Line 1141... | Line 1207... | ||
1141 | stdcall @@strchr$qpxci, esi,'[' |
1207 | stdcall @@strchr$qpxci, esi,'[' |
1142 | add esp,8 |
1208 | add esp,8 |
1143 | mov esi,eax |
1209 | mov esi,eax |
1144 | test esi,esi |
1210 | test esi,esi |
1145 | jne .225 |
1211 | jne .225 |
1146 | mov eax,15 |
1212 | mov eax,txt_err_sqbrl_w1 |
1147 | jmp .193 |
1213 | jmp .193 |
1148 | .225: |
1214 | .225: |
1149 | inc esi |
1215 | inc esi |
1150 | xor edx,edx |
1216 | xor edx,edx |
1151 | mov dword[ebp-8],edx |
1217 | mov dword[ebp-8],edx ;k=0 |
1152 | jmp .227 |
1218 | jmp .227 |
- | 1219 | .226: ;for(k=0;k |
|
- | 1220 | ||
- | 1221 | mov eax,edi |
|
- | 1222 | imul eax,sizeof.Layer |
|
- | 1223 | mov edx,[ebp+8] |
|
- | 1224 | add eax,[edx+NeuralNetwork.layers] |
|
- | 1225 | mov eax,[eax+Layer.n_size] |
|
- | 1226 | or eax,eax |
|
- | 1227 | jnz .end_null_we |
|
- | 1228 | inc dword[ebp-8] ;k++ |
|
- | 1229 | jmp .227 ;if 'weights' is null array |
|
1153 | .226: |
1230 | .end_null_we: |
- | 1231 | ||
1154 | stdcall @@strchr$qpxci, esi,'[' |
1232 | stdcall @@strchr$qpxci, esi,'[' |
1155 | add esp,8 |
1233 | add esp,8 |
1156 | mov ebx,eax |
1234 | mov ebx,eax |
1157 | test ebx,ebx |
1235 | test ebx,ebx |
1158 | jne .228 |
1236 | jne .228 |
1159 | mov eax,16 |
1237 | mov eax,txt_err_sqbrl_w2 |
1160 | jmp .193 |
1238 | jmp .193 |
1161 | .228: |
1239 | .228: |
1162 | inc ebx |
1240 | inc ebx |
1163 | xor edx,edx |
1241 | xor edx,edx |
1164 | mov dword[ebp-12],edx |
1242 | mov dword[ebp-12],edx ;j=0 |
1165 | jmp .230 |
1243 | jmp .230 |
1166 | .229: |
- | |
1167 | mov esi,[ebp+8] |
1244 | .229: ;for(j=0;j |
1168 | dec edx |
1245 | dec edx |
1169 | cmp eax,edx |
- | |
1170 | lea ecx,[edi+4*edi] |
1246 | cmp eax,edx ;eax = j, edx = n_size-1 |
1171 | mov esi,[esi+8] |
- | |
1172 | jae .231 |
1247 | jae .231 |
1173 | stdcall @@strchr$qpxci, ebx,',' |
1248 | stdcall @@strchr$qpxci, ebx,',' |
1174 | add esp,8 |
1249 | add esp,8 |
1175 | mov esi,eax |
1250 | mov esi,eax |
1176 | jmp .232 |
1251 | jmp .232 |
Line 1179... | Line 1254... | ||
1179 | add esp,8 |
1254 | add esp,8 |
1180 | mov esi,eax |
1255 | mov esi,eax |
1181 | .232: |
1256 | .232: |
1182 | test esi,esi |
1257 | test esi,esi |
1183 | jne .233 |
1258 | jne .233 |
1184 | mov eax,17 |
1259 | mov eax,txt_err_sqbrr_w2 |
1185 | jmp .193 |
1260 | jmp .193 |
1186 | .233: |
1261 | .233: |
1187 | mov byte[esi],0 |
1262 | mov byte[esi],0 |
1188 | push ebx |
- | |
1189 | call @@StrToDouble$qpc |
1263 | stdcall @@StrToDouble$qpc,ebx |
1190 | pop ecx |
1264 | pop ecx |
1191 | lea edx,[edi+4*edi] |
1265 | mov edx,edi |
- | 1266 | imul edx,sizeof.Layer |
|
1192 | mov ecx,[ebp+8] |
1267 | mov ecx,[ebp+8] |
1193 | lea ebx,[esi+1] |
1268 | lea ebx,[esi+1] |
1194 | mov eax,[ecx+8] |
1269 | mov eax,[ecx+NeuralNetwork.layers] |
1195 | mov ecx,[ebp-8] |
1270 | mov ecx,[ebp-8] |
1196 | mov edx,[eax+4*edx+16] |
1271 | mov edx,[eax+edx+Layer.weights] |
1197 | mov eax,[edx+4*ecx] |
1272 | mov eax,[edx+4*ecx] |
1198 | mov edx,[ebp-12] |
1273 | mov edx,[ebp-12] |
1199 | fstp qword[eax+8*edx] |
1274 | fstp qword[eax+8*edx] |
1200 | inc dword[ebp-12] |
1275 | inc dword[ebp-12] |
1201 | .230: |
1276 | .230: |
1202 | lea edx,[edi+4*edi] |
1277 | mov edx,edi |
- | 1278 | imul edx,sizeof.Layer |
|
1203 | mov ecx,[ebp+8] |
1279 | mov ecx,[ebp+8] |
1204 | mov ecx,[ecx+8] |
1280 | add edx,[ecx+NeuralNetwork.layers] |
1205 | mov edx,[ecx+4*edx+4] |
1281 | mov edx,[edx+Layer.n_size] |
1206 | mov eax,[ebp-12] |
1282 | mov eax,[ebp-12] |
1207 | cmp edx,eax |
1283 | cmp edx,eax |
1208 | ja .229 |
1284 | ja .229 |
1209 | mov esi,ebx |
1285 | mov esi,ebx |
1210 | inc dword[ebp-8] |
1286 | inc dword[ebp-8] |
1211 | .227: |
1287 | .227: |
1212 | lea eax,[edi+4*edi] |
1288 | mov eax,edi |
- | 1289 | imul eax,sizeof.Layer |
|
1213 | mov edx,[ebp+8] |
1290 | mov edx,[ebp+8] |
1214 | mov ecx,[edx+8] |
1291 | add eax,[edx+NeuralNetwork.layers] |
1215 | mov eax,[ecx+4*eax] |
1292 | mov eax,[eax+Layer.c_size] |
1216 | cmp eax,[ebp-8] |
1293 | cmp eax,[ebp-8] |
1217 | ja .226 |
1294 | ja .226 |
1218 | inc edi |
1295 | inc edi |
1219 | .205: |
1296 | .205: |
1220 | mov edx,[ebp+8] |
1297 | mov edx,[ebp+8] |
1221 | cmp edi,[edx+12] |
1298 | cmp edi,[edx+NeuralNetwork.layers_length] |
1222 | jb .204 |
1299 | jb .204 |
1223 | xor eax,eax |
1300 | xor eax,eax |
1224 | jmp .193 |
1301 | jmp .193 |
1225 | .198: |
1302 | .198: |
1226 | mov eax,1000 |
1303 | mov eax,1000 |
Line 1304... | Line 1381... | ||
1304 | 1381 | ||
1305 | align 16 |
1382 | align 16 |
1306 | EXPORTS: |
1383 | EXPORTS: |
1307 | dd sz_lib_init, lib_init |
1384 | dd sz_lib_init, lib_init |
- | 1385 | dd sz_create, NNP_Create |
|
1308 | dd sz_create, NNP_Create |
1386 | dd sz_reset, NNP_Reset |
1309 | dd sz_feedforward, NNP_FeedForward |
1387 | dd sz_feedforward, NNP_FeedForward |
1310 | dd sz_backpropagation, NNP_BackPropagation |
1388 | dd sz_backpropagation, NNP_BackPropagation |
1311 | dd sz_getmemdata, NNP_GetMemData |
1389 | dd sz_getmemdata, NNP_GetMemData |
1312 | dd sz_setmemdata, NNP_SetMemData |
1390 | dd sz_setmemdata, NNP_SetMemData |
1313 | dd sz_destroy, NNP_Destroy |
1391 | dd sz_destroy, NNP_Destroy |
1314 | dd 0,0 |
1392 | dd 0,0 |
1315 | sz_lib_init db 'lib_init',0 |
1393 | sz_lib_init db 'lib_init',0 |
- | 1394 | sz_create db 'NNP_Create',0 |
|
1316 | sz_create db 'NNP_Create',0 |
1395 | sz_reset db 'NNP_Reset',0 |
1317 | sz_feedforward db 'NNP_FeedForward',0 |
1396 | sz_feedforward db 'NNP_FeedForward',0 |
1318 | sz_backpropagation db 'NNP_BackPropagation',0 |
1397 | sz_backpropagation db 'NNP_BackPropagation',0 |
1319 | sz_getmemdata db 'NNP_GetMemData',0 |
1398 | sz_getmemdata db 'NNP_GetMemData',0 |
1320 | sz_setmemdata db 'NNP_SetMemData',0 |
1399 | sz_setmemdata db 'NNP_SetMemData',0 |