aboutsummaryrefslogtreecommitdiff
path: root/examples/tutorial-ann_mlp.pd
blob: 4c497158a248f91c8120b8694daaab1f9905d8e4 (plain)
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
#N canvas 297 73 593 517 12;
#X obj 65 379 ann_mlp;
#X text 39 59 input: mouse coord;
#X text 37 76 output: 1 if mouse is in the upper left part of the screen
;
#N canvas 106 171 568 438 step1-creation 0;
#X text 141 13 let's create the ANN;
#X obj 130 354 outlet;
#X msg 132 185 create 2 1;
#X text 59 102 let's assume you have 2 inputs value X and Y and you
want 1 output value that tells 1 when the mouse in in the upper left
part of the screen;
#X text 242 185 send this message;
#X connect 2 0 1 0;
#X restore 128 158 pd step1-creation;
#N canvas 46 38 644 604 step2-train 0;
#X obj 97 530 outlet;
#X msg 44 130 train;
#X text 102 129 first switch to train mode;
#X obj 139 367 pack s f f f;
#N canvas 0 0 462 312 normalized-inputs 0;
#X obj 105 64 r X;
#X obj 173 67 r Y;
#X obj 173 92 / 240;
#X obj 105 91 / 320;
#X obj 104 116 - 1;
#X obj 173 118 - 1;
#X text 221 108 normalize inputs to [-1 \, 1];
#X obj 104 211 outlet;
#X obj 177 215 outlet;
#X text 144 35 receive X and Y;
#X connect 0 0 3 0;
#X connect 1 0 2 0;
#X connect 2 0 5 0;
#X connect 3 0 4 0;
#X connect 4 0 7 0;
#X connect 5 0 8 0;
#X restore 127 271 pd normalized-inputs;
#N canvas 0 0 667 316 desired-output 0;
#X obj 383 63 key;
#X obj 383 92 select 97;
#X msg 382 118 1;
#X obj 528 97 select 97;
#X obj 528 68 keyup;
#X msg 527 123 0;
#X obj 183 195 outlet;
#X text 40 21 i send 1 when "a" is pressed \, 0 when released;
#X obj 180 108 r out;
#X connect 0 0 1 0;
#X connect 1 0 2 0;
#X connect 2 0 6 0;
#X connect 3 0 5 0;
#X connect 4 0 3 0;
#X connect 5 0 6 0;
#X connect 8 0 6 0;
#X restore 239 332 pd desired-output;
#X obj 91 192 tgl 15 0 empty empty train 0 -6 0 8 -258699 -1 -1 0 1
;
#X text 117 190 <-- toggle to train;
#X text 119 404 everytime the metro bangs you send a training pattern
to ann_mlp;
#X floatatom 247 357 5 0 0 0 - - -;
#X floatatom 287 295 5 0 0 0 - - -;
#X floatatom 148 295 5 0 0 0 - - -;
#X obj 110 328 metro 50;
#X text 53 45 (for this to work you need to give focus to this window
but the gem window must be visible);
#X text 335 293 <-- check mouse position;
#X text 112 213 then move the mouse and press left button when you
are in the upper left part of the screen \, release button when you
are not in the upper left part of the screen;
#X text 293 357 <-- check button pressed/not pressed;
#X obj 124 475 unpack s f f f;
#X obj 145 501 pack f f f;
#X floatatom 296 518 5 0 0 0 mse mse -;
#X text 116 447 go on until mse is low enough (< 0.01);
#X connect 1 0 0 0;
#X connect 3 0 17 0;
#X connect 4 0 3 1;
#X connect 4 0 11 0;
#X connect 4 1 3 2;
#X connect 4 1 10 0;
#X connect 5 0 3 3;
#X connect 5 0 9 0;
#X connect 6 0 12 0;
#X connect 12 0 3 0;
#X connect 17 1 18 0;
#X connect 17 2 18 1;
#X connect 17 3 18 2;
#X connect 18 0 0 0;
#X restore 134 218 pd step2-train;
#N canvas 0 0 462 312 mouseInput 0;
#X obj 41 139 gemwin;
#X msg 44 69 create \, 1;
#X msg 134 71 0 \, destroy;
#X obj 143 120 gemmouse 640 480;
#X obj 143 161 s X;
#X obj 172 161 s Y;
#X obj 54 25 inlet;
#X obj 133 27 inlet;
#X obj 206 162 s out;
#X connect 1 0 0 0;
#X connect 2 0 0 0;
#X connect 3 0 4 0;
#X connect 3 1 5 0;
#X connect 3 2 8 0;
#X connect 6 0 1 0;
#X connect 7 0 2 0;
#X restore 287 443 pd mouseInput;
#X obj 287 423 bng 15 250 50 0 empty empty start_GEM 0 -6 0 8 -262144
-1 -1;
#X obj 385 424 bng 15 250 50 0 empty empty stop_GEM 0 -6 0 8 -262144
-1 -1;
#X obj 281 389 loadbang;
#X floatatom 116 414 5 0 0 0 mse - mse;
#N canvas 618 -3 682 470 step3-run 0;
#X obj 64 377 outlet;
#N canvas 0 0 466 316 normalized-inputs 0;
#X obj 105 64 r X;
#X obj 173 67 r Y;
#X obj 173 92 / 240;
#X obj 105 91 / 320;
#X obj 104 116 - 1;
#X obj 173 118 - 1;
#X text 221 108 normalize inputs to [-1 \, 1];
#X obj 104 211 outlet;
#X obj 177 215 outlet;
#X text 144 35 receive X and Y;
#X connect 0 0 3 0;
#X connect 1 0 2 0;
#X connect 2 0 5 0;
#X connect 3 0 4 0;
#X connect 4 0 7 0;
#X connect 5 0 8 0;
#X restore 178 167 pd normalized-inputs;
#X obj 97 92 tgl 15 0 empty empty run 0 -6 0 8 -258699 -1 -1 1 1;
#X obj 145 267 pack s f f;
#X msg 50 30 run;
#X text 108 29 first switch to run mode;
#X text 123 90 <-- toggle to run;
#X obj 116 228 metro 50;
#X floatatom 332 196 5 0 0 0 - - -;
#X floatatom 191 193 5 0 0 0 - - -;
#X obj 145 293 unpack s f f;
#X obj 176 321 pack f f;
#X connect 1 0 3 1;
#X connect 1 0 9 0;
#X connect 1 1 3 2;
#X connect 1 1 8 0;
#X connect 2 0 7 0;
#X connect 3 0 10 0;
#X connect 4 0 0 0;
#X connect 7 0 3 0;
#X connect 10 1 11 0;
#X connect 10 2 11 1;
#X connect 11 0 0 0;
#X restore 139 284 pd step3-run;
#X floatatom 64 450 5 0 0 0 - - -;
#X connect 0 0 11 0;
#X connect 0 1 9 0;
#X connect 3 0 0 0;
#X connect 4 0 0 0;
#X connect 6 0 5 0;
#X connect 7 0 5 1;
#X connect 8 0 6 0;
#X connect 10 0 0 0;