-
Notifications
You must be signed in to change notification settings - Fork 19
/
index.html
466 lines (434 loc) · 127 KB
/
index.html
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
<!doctype html>
<html>
<head>
<meta charset='UTF-8'><meta name='viewport' content='width=device-width initial-scale=1'>
<style type='text/css'>html {overflow-x: initial !important;}:root { --bg-color: #ffffff; --text-color: #333333; --select-text-bg-color: #B5D6FC; --select-text-font-color: auto; --monospace: "Lucida Console",Consolas,"Courier",monospace; --title-bar-height: 20px; }
.mac-os-11 { --title-bar-height: 28px; }
html { font-size: 14px; background-color: var(--bg-color); color: var(--text-color); font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; -webkit-font-smoothing: antialiased; }
body { margin: 0px; padding: 0px; height: auto; bottom: 0px; top: 0px; left: 0px; right: 0px; font-size: 1rem; line-height: 1.42857143; overflow-x: hidden; background-image: inherit; background-size: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: inherit; tab-size: 4; background-position: inherit inherit; background-repeat: inherit inherit; }
iframe { margin: auto; }
a.url { word-break: break-all; }
a:active, a:hover { outline: 0px; }
.in-text-selection, ::selection { text-shadow: none; background: var(--select-text-bg-color); color: var(--select-text-font-color); }
#write { margin: 0px auto; height: auto; width: inherit; word-break: normal; word-wrap: break-word; position: relative; white-space: normal; overflow-x: visible; padding-top: 36px; }
#write.first-line-indent p { text-indent: 2em; }
#write.first-line-indent li p, #write.first-line-indent p * { text-indent: 0px; }
#write.first-line-indent li { margin-left: 2em; }
.for-image #write { padding-left: 8px; padding-right: 8px; }
body.typora-export { padding-left: 30px; padding-right: 30px; }
.typora-export .footnote-line, .typora-export li, .typora-export p { white-space: pre-wrap; }
.typora-export .task-list-item input { pointer-events: none; }
@media screen and (max-width: 500px) {
body.typora-export { padding-left: 0px; padding-right: 0px; }
#write { padding-left: 20px; padding-right: 20px; }
}
#write li > figure:last-child { margin-bottom: 0.5rem; }
#write ol, #write ul { position: relative; }
img { max-width: 100%; vertical-align: middle; }
button, input, select, textarea { color: inherit; font-family: inherit; font-size: inherit; font-style: inherit; font-variant-caps: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; }
input[type="checkbox"], input[type="radio"] { line-height: normal; padding: 0px; }
*, ::after, ::before { box-sizing: border-box; }
#write h1, #write h2, #write h3, #write h4, #write h5, #write h6, #write p, #write pre { width: inherit; }
#write h1, #write h2, #write h3, #write h4, #write h5, #write h6, #write p { position: relative; }
p { line-height: inherit; }
h1, h2, h3, h4, h5, h6 { break-after: avoid-page; break-inside: avoid; orphans: 4; }
p { orphans: 4; }
h1 { font-size: 2rem; }
h2 { font-size: 1.8rem; }
h3 { font-size: 1.6rem; }
h4 { font-size: 1.4rem; }
h5 { font-size: 1.2rem; }
h6 { font-size: 1rem; }
.md-math-block, .md-rawblock, h1, h2, h3, h4, h5, h6, p { margin-top: 1rem; margin-bottom: 1rem; }
.hidden { display: none; }
.md-blockmeta { color: rgb(204, 204, 204); font-weight: 700; font-style: italic; }
a { cursor: pointer; }
sup.md-footnote { padding: 2px 4px; background-color: rgba(238, 238, 238, 0.701961); color: rgb(85, 85, 85); border-top-left-radius: 4px; border-top-right-radius: 4px; border-bottom-right-radius: 4px; border-bottom-left-radius: 4px; cursor: pointer; }
sup.md-footnote a, sup.md-footnote a:hover { color: inherit; text-transform: inherit; text-decoration: inherit; }
#write input[type="checkbox"] { cursor: pointer; width: inherit; height: inherit; }
figure { overflow-x: auto; margin: 1.2em 0px; max-width: calc(100% + 16px); padding: 0px; }
figure > table { margin: 0px; }
thead, tr { break-inside: avoid; break-after: auto; }
thead { display: table-header-group; }
table { border-collapse: collapse; border-spacing: 0px; width: 100%; overflow: auto; break-inside: auto; text-align: left; }
table.md-table td { min-width: 32px; }
.CodeMirror-gutters { border-right-width: 0px; background-color: inherit; }
.CodeMirror-linenumber { }
.CodeMirror { text-align: left; }
.CodeMirror-placeholder { opacity: 0.3; }
.CodeMirror pre { padding: 0px 4px; }
.CodeMirror-lines { padding: 0px; }
div.hr:focus { cursor: none; }
#write pre { white-space: pre-wrap; }
#write.fences-no-line-wrapping pre { white-space: pre; }
#write pre.ty-contain-cm { white-space: normal; }
.CodeMirror-gutters { margin-right: 4px; }
.md-fences { font-size: 0.9rem; display: block; break-inside: avoid; text-align: left; overflow: visible; white-space: pre; background-image: inherit; background-size: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: inherit; position: relative !important; background-position: inherit inherit; background-repeat: inherit inherit; }
.md-fences-adv-panel { width: 100%; margin-top: 10px; text-align: center; padding-top: 0px; padding-bottom: 8px; overflow-x: auto; }
#write .md-fences.mock-cm { white-space: pre-wrap; }
.md-fences.md-fences-with-lineno { padding-left: 0px; }
#write.fences-no-line-wrapping .md-fences.mock-cm { white-space: pre; overflow-x: auto; }
.md-fences.mock-cm.md-fences-with-lineno { padding-left: 8px; }
.CodeMirror-line, twitterwidget { break-inside: avoid; }
svg { break-inside: avoid; }
.footnotes { opacity: 0.8; font-size: 0.9rem; margin-top: 1em; margin-bottom: 1em; }
.footnotes + .footnotes { margin-top: 0px; }
.md-reset { margin: 0px; padding: 0px; border: 0px; outline: 0px; vertical-align: top; text-decoration: none; text-shadow: none; float: none; position: static; width: auto; height: auto; white-space: nowrap; cursor: inherit; line-height: normal; font-weight: 400; text-align: left; box-sizing: content-box; direction: ltr; background-position: 0px 0px; background-repeat: initial initial; }
li div { padding-top: 0px; }
blockquote { margin: 1rem 0px; }
li .mathjax-block, li p { margin: 0.5rem 0px; }
li blockquote { margin: 1rem 0px; }
li { margin: 0px; position: relative; }
blockquote > :last-child { margin-bottom: 0px; }
blockquote > :first-child, li > :first-child { margin-top: 0px; }
.footnotes-area { color: rgb(136, 136, 136); margin-top: 0.714rem; padding-bottom: 0.143rem; white-space: normal; }
#write .footnote-line { white-space: pre-wrap; }
@media print {
body, html { border: 1px solid transparent; height: 99%; break-after: avoid-page; break-before: avoid-page; font-variant-ligatures: no-common-ligatures; }
#write { margin-top: 0px; padding-top: 0px; border-color: transparent !important; padding-bottom: 0px !important; }
.typora-export * { -webkit-print-color-adjust: exact; }
.typora-export #write { break-after: avoid-page; }
.typora-export #write::after { height: 0px; }
.is-mac table { break-inside: avoid; }
.typora-export-show-outline .typora-export-sidebar { display: none; }
}
.footnote-line { margin-top: 0.714em; font-size: 0.7em; }
a img, img a { cursor: pointer; }
pre.md-meta-block { font-size: 0.8rem; min-height: 0.8rem; white-space: pre-wrap; background-color: rgb(204, 204, 204); display: block; overflow-x: hidden; background-position: initial initial; background-repeat: initial initial; }
p > .md-image:only-child:not(.md-img-error) img, p > img:only-child { display: block; margin: auto; }
#write.first-line-indent p > .md-image:only-child:not(.md-img-error) img { left: -2em; position: relative; }
p > .md-image:only-child { display: inline-block; width: 100%; }
#write .MathJax_Display { margin: 0.8em 0px 0px; }
.md-math-block { width: 100%; }
.md-math-block:not(:empty)::after { display: none; }
.MathJax_ref { fill: currentcolor; }
[contenteditable="true"]:active, [contenteditable="true"]:focus, [contenteditable="false"]:active, [contenteditable="false"]:focus { outline: 0px; box-shadow: none; }
.md-task-list-item { position: relative; list-style-type: none; }
.task-list-item.md-task-list-item { padding-left: 0px; }
.md-task-list-item > input { position: absolute; top: 0px; left: 0px; margin-left: -1.2em; margin-top: calc(1em - 10px); border: none; }
.math { font-size: 1rem; }
.md-toc { min-height: 3.58rem; position: relative; font-size: 0.9rem; border-top-left-radius: 10px; border-top-right-radius: 10px; border-bottom-right-radius: 10px; border-bottom-left-radius: 10px; }
.md-toc-content { position: relative; margin-left: 0px; }
.md-toc-content::after, .md-toc::after { display: none; }
.md-toc-item { display: block; color: rgb(65, 131, 196); }
.md-toc-item a { text-decoration: none; }
.md-toc-inner:hover { text-decoration: underline; }
.md-toc-inner { display: inline-block; cursor: pointer; }
.md-toc-h1 .md-toc-inner { margin-left: 0px; font-weight: 700; }
.md-toc-h2 .md-toc-inner { margin-left: 2em; }
.md-toc-h3 .md-toc-inner { margin-left: 4em; }
.md-toc-h4 .md-toc-inner { margin-left: 6em; }
.md-toc-h5 .md-toc-inner { margin-left: 8em; }
.md-toc-h6 .md-toc-inner { margin-left: 10em; }
@media screen and (max-width: 48em) {
.md-toc-h3 .md-toc-inner { margin-left: 3.5em; }
.md-toc-h4 .md-toc-inner { margin-left: 5em; }
.md-toc-h5 .md-toc-inner { margin-left: 6.5em; }
.md-toc-h6 .md-toc-inner { margin-left: 8em; }
}
a.md-toc-inner { font-size: inherit; font-style: inherit; font-weight: inherit; line-height: inherit; }
.footnote-line a:not(.reversefootnote) { color: inherit; }
.reversefootnote { font-family: ui-monospace, sans-serif; }
.md-attr { display: none; }
.md-fn-count::after { content: "."; }
code, pre, samp, tt { font-family: var(--monospace); }
kbd { margin: 0px 0.1em; padding: 0.1em 0.6em; font-size: 0.8em; color: rgb(36, 39, 41); background-color: rgb(255, 255, 255); border: 1px solid rgb(173, 179, 185); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; box-shadow: rgba(12, 13, 14, 0.2) 0px 1px 0px, rgb(255, 255, 255) 0px 0px 0px 2px inset; white-space: nowrap; vertical-align: middle; background-position: initial initial; background-repeat: initial initial; }
.md-comment { color: rgb(162, 127, 3); opacity: 0.6; font-family: var(--monospace); }
code { text-align: left; }
a.md-print-anchor { white-space: pre !important; border: none !important; display: inline-block !important; position: absolute !important; width: 1px !important; right: 0px !important; outline: 0px !important; text-shadow: initial !important; background-position: 0px 0px !important; background-repeat: initial initial !important; }
.os-windows.monocolor-emoji .md-emoji { font-family: "Segoe UI Symbol", sans-serif; }
.md-diagram-panel > svg { max-width: 100%; }
[lang="flow"] svg, [lang="mermaid"] svg { max-width: 100%; height: auto; }
[lang="mermaid"] .node text { font-size: 1rem; }
table tr th { border-bottom-width: 0px; }
video { max-width: 100%; display: block; margin: 0px auto; }
iframe { max-width: 100%; width: 100%; border: none; }
.highlight td, .highlight tr { border: 0px; }
mark { background-color: rgb(255, 255, 0); color: rgb(0, 0, 0); background-position: initial initial; background-repeat: initial initial; }
.md-html-inline .md-plain, .md-html-inline strong, mark .md-inline-math, mark strong { color: inherit; }
.md-expand mark .md-meta { opacity: 0.3 !important; }
mark .md-meta { color: rgb(0, 0, 0); }
@media print {
.typora-export h1, .typora-export h2, .typora-export h3, .typora-export h4, .typora-export h5, .typora-export h6 { break-inside: avoid; }
}
.md-diagram-panel .messageText { stroke: none !important; }
.md-diagram-panel .start-state { fill: var(--node-fill); }
.md-diagram-panel .edgeLabel rect { opacity: 1 !important; }
.md-fences.md-fences-math { font-size: 1em; }
.md-fences-advanced:not(.md-focus) { padding: 0px; white-space: nowrap; border: 0px; }
.md-fences-advanced:not(.md-focus) { background-image: inherit; background-size: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: inherit; background-position: inherit inherit; background-repeat: inherit inherit; }
.typora-export-show-outline .typora-export-content { max-width: 1440px; margin: auto; display: flex; flex-direction: row; }
.typora-export-sidebar { width: 300px; font-size: 0.8rem; margin-top: 80px; margin-right: 18px; }
.typora-export-show-outline #write { --webkit-flex: 2; flex: 2 1 0%; }
.typora-export-sidebar .outline-content { position: fixed; top: 0px; max-height: 100%; overflow-y: auto; padding-bottom: 30px; padding-top: 60px; width: 300px; overflow-x: hidden; }
@media screen and (max-width: 1024px) {
.typora-export-sidebar, .typora-export-sidebar .outline-content { width: 240px; }
}
@media screen and (max-width: 800px) {
.typora-export-sidebar { display: none; }
}
.outline-content li, .outline-content ul { margin-left: 0px; margin-right: 0px; padding-left: 0px; padding-right: 0px; list-style: none; }
.outline-content ul { margin-top: 0px; margin-bottom: 0px; }
.outline-content strong { font-weight: 400; }
.outline-expander { width: 1rem; height: 1.428571429rem; position: relative; display: table-cell; vertical-align: middle; cursor: pointer; padding-left: 4px; }
.outline-expander::before { content: ''; position: relative; font-family: Ionicons; display: inline-block; font-size: 8px; vertical-align: middle; }
.outline-item { padding-top: 3px; padding-bottom: 3px; cursor: pointer; }
.outline-expander:hover::before { content: ''; }
.outline-h1 > .outline-item { padding-left: 0px; }
.outline-h2 > .outline-item { padding-left: 1em; }
.outline-h3 > .outline-item { padding-left: 2em; }
.outline-h4 > .outline-item { padding-left: 3em; }
.outline-h5 > .outline-item { padding-left: 4em; }
.outline-h6 > .outline-item { padding-left: 5em; }
.outline-label { cursor: pointer; display: table-cell; vertical-align: middle; text-decoration: none; color: inherit; }
.outline-label:hover { text-decoration: underline; }
.outline-item:hover { border-color: rgb(245, 245, 245); background-color: var(--item-hover-bg-color); }
.outline-item:hover { margin-left: -28px; margin-right: -28px; border-left-width: 28px; border-left-style: solid; border-left-color: transparent; border-right-width: 28px; border-right-style: solid; border-right-color: transparent; }
.outline-item-single .outline-expander::before, .outline-item-single .outline-expander:hover::before { display: none; }
.outline-item-open > .outline-item > .outline-expander::before { content: ''; }
.outline-children { display: none; }
.info-panel-tab-wrapper { display: none; }
.outline-item-open > .outline-children { display: block; }
.typora-export .outline-item { padding-top: 1px; padding-bottom: 1px; }
.typora-export .outline-item:hover { margin-right: -8px; border-right-width: 8px; border-right-style: solid; border-right-color: transparent; }
.typora-export .outline-expander::before { content: "+"; font-family: inherit; top: -1px; }
.typora-export .outline-expander:hover::before, .typora-export .outline-item-open > .outline-item > .outline-expander::before { content: '−'; }
.typora-export-collapse-outline .outline-children { display: none; }
.typora-export-collapse-outline .outline-item-open > .outline-children, .typora-export-no-collapse-outline .outline-children { display: block; }
.typora-export-no-collapse-outline .outline-expander::before { content: "" !important; }
.typora-export-show-outline .outline-item-active > .outline-item .outline-label { font-weight: 700; }
.md-inline-math-container mjx-container { zoom: 0.95; }
mjx-container { break-inside: avoid; }
.CodeMirror { height: auto; }
.CodeMirror.cm-s-inner { background-image: inherit; background-size: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: inherit; background-position: inherit inherit; background-repeat: inherit inherit; }
.CodeMirror-scroll { overflow-y: hidden; overflow-x: auto; z-index: 3; }
.CodeMirror-gutter-filler, .CodeMirror-scrollbar-filler { background-color: rgb(255, 255, 255); }
.CodeMirror-gutters { border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); background-image: inherit; background-size: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: inherit; white-space: nowrap; background-position: inherit inherit; background-repeat: inherit inherit; }
.CodeMirror-linenumber { padding: 0px 3px 0px 5px; text-align: right; color: rgb(153, 153, 153); }
.cm-s-inner .cm-keyword { color: rgb(119, 0, 136); }
.cm-s-inner .cm-atom, .cm-s-inner.cm-atom { color: rgb(34, 17, 153); }
.cm-s-inner .cm-number { color: rgb(17, 102, 68); }
.cm-s-inner .cm-def { color: rgb(0, 0, 255); }
.cm-s-inner .cm-variable { color: rgb(0, 0, 0); }
.cm-s-inner .cm-variable-2 { color: rgb(0, 85, 170); }
.cm-s-inner .cm-variable-3 { color: rgb(0, 136, 85); }
.cm-s-inner .cm-string { color: rgb(170, 17, 17); }
.cm-s-inner .cm-property { color: rgb(0, 0, 0); }
.cm-s-inner .cm-operator { color: rgb(152, 26, 26); }
.cm-s-inner .cm-comment, .cm-s-inner.cm-comment { color: rgb(170, 85, 0); }
.cm-s-inner .cm-string-2 { color: rgb(255, 85, 0); }
.cm-s-inner .cm-meta { color: rgb(85, 85, 85); }
.cm-s-inner .cm-qualifier { color: rgb(85, 85, 85); }
.cm-s-inner .cm-builtin { color: rgb(51, 0, 170); }
.cm-s-inner .cm-bracket { color: rgb(153, 153, 119); }
.cm-s-inner .cm-tag { color: rgb(17, 119, 0); }
.cm-s-inner .cm-attribute { color: rgb(0, 0, 204); }
.cm-s-inner .cm-header, .cm-s-inner.cm-header { color: rgb(0, 0, 255); }
.cm-s-inner .cm-quote, .cm-s-inner.cm-quote { color: rgb(0, 153, 0); }
.cm-s-inner .cm-hr, .cm-s-inner.cm-hr { color: rgb(153, 153, 153); }
.cm-s-inner .cm-link, .cm-s-inner.cm-link { color: rgb(0, 0, 204); }
.cm-negative { color: rgb(221, 68, 68); }
.cm-positive { color: rgb(34, 153, 34); }
.cm-header, .cm-strong { font-weight: 700; }
.cm-del { text-decoration: line-through; }
.cm-em { font-style: italic; }
.cm-link { text-decoration: underline; }
.cm-error { color: red; }
.cm-invalidchar { color: red; }
.cm-constant { color: rgb(38, 139, 210); }
.cm-defined { color: rgb(181, 137, 0); }
div.CodeMirror span.CodeMirror-matchingbracket { color: rgb(0, 255, 0); }
div.CodeMirror span.CodeMirror-nonmatchingbracket { color: rgb(255, 34, 34); }
.cm-s-inner .CodeMirror-activeline-background { background-image: inherit; background-size: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: inherit; background-position: inherit inherit; background-repeat: inherit inherit; }
.CodeMirror { position: relative; overflow: hidden; }
.CodeMirror-scroll { height: 100%; outline: 0px; position: relative; box-sizing: content-box; background-image: inherit; background-size: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: inherit; background-position: inherit inherit; background-repeat: inherit inherit; }
.CodeMirror-sizer { position: relative; }
.CodeMirror-gutter-filler, .CodeMirror-hscrollbar, .CodeMirror-scrollbar-filler, .CodeMirror-vscrollbar { position: absolute; z-index: 6; display: none; outline: 0px; }
.CodeMirror-vscrollbar { right: 0px; top: 0px; overflow: hidden; }
.CodeMirror-hscrollbar { bottom: 0px; left: 0px; overflow-y: hidden; overflow-x: auto; }
.CodeMirror-scrollbar-filler { right: 0px; bottom: 0px; }
.CodeMirror-gutter-filler { left: 0px; bottom: 0px; }
.CodeMirror-gutters { position: absolute; left: 0px; top: 0px; padding-bottom: 10px; z-index: 3; overflow-y: hidden; }
.CodeMirror-gutter { white-space: normal; height: 100%; box-sizing: content-box; padding-bottom: 30px; margin-bottom: -32px; display: inline-block; }
.CodeMirror-gutter-wrapper { position: absolute; z-index: 4; border: none !important; background-position: 0px 0px !important; background-repeat: initial initial !important; }
.CodeMirror-gutter-background { position: absolute; top: 0px; bottom: 0px; z-index: 4; }
.CodeMirror-gutter-elt { position: absolute; cursor: default; z-index: 4; }
.CodeMirror-lines { cursor: text; }
.CodeMirror pre { border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; border-width: 0px; font-family: inherit; font-size: inherit; margin: 0px; white-space: pre; word-wrap: normal; color: inherit; z-index: 2; position: relative; overflow: visible; background-position: 0px 0px; background-repeat: initial initial; }
.CodeMirror-wrap pre { word-wrap: break-word; white-space: pre-wrap; word-break: normal; }
.CodeMirror-code pre { border-right-width: 30px; border-right-style: solid; border-right-color: transparent; width: fit-content; }
.CodeMirror-wrap .CodeMirror-code pre { border-right-style: none; width: auto; }
.CodeMirror-linebackground { position: absolute; left: 0px; right: 0px; top: 0px; bottom: 0px; z-index: 0; }
.CodeMirror-linewidget { position: relative; z-index: 2; overflow: auto; }
.CodeMirror-wrap .CodeMirror-scroll { overflow-x: hidden; }
.CodeMirror-measure { position: absolute; width: 100%; height: 0px; overflow: hidden; visibility: hidden; }
.CodeMirror-measure pre { position: static; }
.CodeMirror div.CodeMirror-cursor { position: absolute; visibility: hidden; border-right-style: none; width: 0px; }
.CodeMirror div.CodeMirror-cursor { visibility: hidden; }
.CodeMirror-focused div.CodeMirror-cursor { visibility: inherit; }
.cm-searching { background-color: rgba(255, 255, 0, 0.4); background-position: initial initial; background-repeat: initial initial; }
span.cm-underlined { text-decoration: underline; }
span.cm-strikethrough { text-decoration: line-through; }
.cm-tw-syntaxerror { color: rgb(255, 255, 255); background-color: rgb(153, 0, 0); }
.cm-tw-deleted { text-decoration: line-through; }
.cm-tw-header5 { font-weight: 700; }
.cm-tw-listitem:first-child { padding-left: 10px; }
.cm-tw-box { border-style: solid; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-color: inherit; border-top-width: 0px !important; }
.cm-tw-underline { text-decoration: underline; }
@media print {
.CodeMirror div.CodeMirror-cursor { visibility: hidden; }
}
:root {
--primary-color: #2875d9;
}
* {
box-sizing: border-box;
}
html, body, #write {
font-family: 'Computer Modern';
}
h1, h2, h3, h4, h5, h6 {
font-family: 'Computer Modern';
}
h1 {
font-size: 1.8rem;
}
h2 {
font-size: 1.4rem;
}
h3 {
font-size: 1.2rem;
}
h4 {
font-size: 1rem;
}
h5 {
font-size: 0.8rem;
}
h6 {
font-size: 0.6rem;
}
html {
font-size: 20px;
}
body, #write {
max-width: 914px;
text-align: justify;
display: block;
margin: auto;
}
p {
font-size: 0.8rem;
}
a {
color: var(--primary-color);
}
/* Stuff */
sup.md-footnote {
background-color: transparent;
color: var(--primary-color);
padding: 1px;
margin: 0;
}
code, .md-fences, .sourceCode {
background: #f2f2f2;
}
.md-fences, pre.sourceCode {
font-size: .7em;
padding: .5rem;
}
.show-fences-line-number .md-fences {
padding-left: .5rem;
}
blockquote {
margin: 2rem .2rem;
padding: .3rem .5rem;
color: #6f6f6f;
border-left: .4rem solid gray;
}
blockquote p {
padding: .2rem 1.5rem;
}
mark {
background: yellow;
}
figure {
margin: .5rem auto;
max-width: 100%;
display: block;
margin: auto;
}
figcaption {
text-align: center;
margin: .5rem auto;
}
img {
max-width: 100%;
display: block;
margin: auto;
}
/*
Print Mode and page breaks.
WkhtmlToPDF does not work on @print mode
*/
@media (max-width: 210mm) {
img {
max-height: 8cm;
}
html {
font-size: 16px;
}
div[title="pb"], page-break {
display: block;
page-break-after: always;
break-after: page;
}
nav {
font-size: .9rem;
page-break-after: always;
page-break-before: always;
}
nav a {
color: black;
}
/* Move top-level headings to a new page on the right-hand side: */
h1, h2 {
page-break-before: right;
break-before: recto;
}
/* Override the previous ruleset for the very first heading: */
h1:first-of-type, section>h1:first-child {
page-break-before: avoid;
break-before: avoid;
}
/* Headings should not be the last paragraph on a page: */
h1, h2, h3, h4, h5, h6 {
page-break-after: avoid;
}
/* Consecutive headings with deepening level should not be split across pages: */
h1+h2, h2+h3, h3+h4, h4+h5, h5+h6 {
page-break-before: avoid;
}
}
@media print { @page {margin: 0 0 0 0;} body.typora-export {padding-left: 0; padding-right: 0;} #write {padding:0;}}
</style><title>README</title>
</head>
<body class='typora-export'><div class='typora-export-content'>
<div id='write' class=''><p> </p><div align="center"><img src="./picture/01.svg"></div><h1 id='edge-engine'><span>Edge-Engine</span></h1><p> </p><h2 id='edge--一个开源的科学计算引擎'><span>Edge : 一个开源的科学计算引擎</span></h2><p><a href='./README_EN.md'><span>README for English_version</span></a></p><p><span>声明:本项目禁止闭源商用,如有需要请和作者取得联系</span></p><p><span>email: [email protected]</span></p><p><a href='https://raw.githubusercontent.com/tesseract-ocr/tesseract/master/LICENSE'><img src="https://img.shields.io/badge/license-Apache--2.0-blue.svg" referrerpolicy="no-referrer" alt="GitHub license"></a></p><hr /><p> </p><blockquote><p><span>项目开始日期 : 2019/10/01</span></p><p><span>测试 : main.cpp | nerual_network.cpp | </span></p><p><span>2022年11月19日12:28:29:实现卷积神经网络单元前向传播</span></p><p><span>2019年10月01日12:28:56:新增全连接神经网络架构(新增全连接网络正向传播和反向传播的测试demo)</span></p><p><span>测试环境:</span></p><p><span>MacBook Pro、ubuntu</span></p><p><span>编译器环境:</span></p><p><span>Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/c++/4.2.1</span>
<span>Apple LLVM version 10.0.1 (clang-1001.0.46.4)</span>
<span>Target: x86_64-apple-darwin18.7.0</span>
<span>Thread model: posix</span></p></blockquote><p><img src="picture/image-20200418210521131.png" alt="image-20200418210521131" /></p><p> </p><hr /><p><span>这是什么?</span></p><p><img src="./picture/path.png" referrerpolicy="no-referrer" alt="path"></p><h2 id='快速开始'><span>快速开始</span></h2><pre class="md-fences md-end-block ty-contain-cm modeLoaded" spellcheck="false" lang=""><div class="CodeMirror cm-s-inner cm-s-null-scroll CodeMirror-wrap" lang=""><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 5.5px; left: 4px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">git clone [email protected]:AllenZYJ/Edge-Computing-Engine.git</span></pre></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="" cm-zwsp="">
</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">cd to install_diff</span></pre></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom-width: 0px; border-bottom-style: solid; border-bottom-color: transparent; top: 45px;"></div><div class="CodeMirror-gutters" style="display: none; height: 45px;"></div></div></div></pre><p><span>进入install_diff目录:</span></p><p><span>执行</span></p><pre class="md-fences md-end-block ty-contain-cm modeLoaded" spellcheck="false" lang=""><div class="CodeMirror cm-s-inner cm-s-null-scroll CodeMirror-wrap" lang=""><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 5.5px; left: 4px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">make</span></pre></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">make install</span></pre></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom-width: 0px; border-bottom-style: solid; border-bottom-color: transparent; top: 30px;"></div><div class="CodeMirror-gutters" style="display: none; height: 30px;"></div></div></div></pre><p><span>编译demo入口程序</span></p><pre class="md-fences md-end-block ty-contain-cm modeLoaded" spellcheck="false" lang="shell"><div class="CodeMirror cm-s-inner cm-s-null-scroll CodeMirror-wrap" lang="shell"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 5px; left: 4px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">g<span class="cm-operator">++</span> main.cpp <span class="cm-attribute">-o</span> main <span class="cm-attribute">-lautodiff</span></span></pre></div></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom-width: 0px; border-bottom-style: solid; border-bottom-color: transparent; top: 15px;"></div><div class="CodeMirror-gutters" style="display: none; height: 15px;"></div></div></div></pre><p><span>或者BP测试程序</span></p><pre class="md-fences md-end-block ty-contain-cm modeLoaded" spellcheck="false" lang="shell"><div class="CodeMirror cm-s-inner cm-s-null-scroll CodeMirror-wrap" lang="shell"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 5px; left: 4px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">g<span class="cm-operator">++</span> nerual_network.cpp <span class="cm-attribute">-o</span> main</span></pre></div></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom-width: 0px; border-bottom-style: solid; border-bottom-color: transparent; top: 15px;"></div><div class="CodeMirror-gutters" style="display: none; height: 15px;"></div></div></div></pre><p><span>运行</span></p><pre class="md-fences md-end-block ty-contain-cm modeLoaded" spellcheck="false" lang="shell"><div class="CodeMirror cm-s-inner cm-s-null-scroll CodeMirror-wrap" lang="shell"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 5px; left: 4px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">./main</span></pre></div></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom-width: 0px; border-bottom-style: solid; border-bottom-color: transparent; top: 15px;"></div><div class="CodeMirror-gutters" style="display: none; height: 15px;"></div></div></div></pre><h2 id='算子系列'><span>算子系列</span></h2><p><span>卷积:</span></p><pre class="md-fences md-end-block ty-contain-cm modeLoaded" spellcheck="false" lang="c++"><div class="CodeMirror cm-s-inner cm-s-null-scroll CodeMirror-wrap" lang="c++"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 5.5px; left: 4px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable-3">double</span> <span class="cm-def">conv_test</span>(<span class="cm-variable">Matrix</span> <span class="cm-variable">mid1</span>,<span class="cm-variable-3">int</span> <span class="cm-variable">input_dim</span> <span class="cm-operator">=</span> <span class="cm-number">3</span>,<span class="cm-variable-3">int</span> <span class="cm-variable">output_channels</span> <span class="cm-operator">=</span> <span class="cm-number">3</span>,<span class="cm-variable-3">int</span> <span class="cm-variable">stride</span> <span class="cm-operator">=</span> <span class="cm-number">1</span>,<span class="cm-variable-3">int</span> <span class="cm-variable">kernel_size</span> <span class="cm-operator">=</span> <span class="cm-number">2</span>,<span class="cm-variable-3">int</span> <span class="cm-variable">mode</span> <span class="cm-operator">=</span> <span class="cm-number">0</span>,<span class="cm-variable-3">int</span> <span class="cm-variable">padding</span> <span class="cm-operator">=</span> <span class="cm-number">0</span>)</span></pre></div></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom-width: 0px; border-bottom-style: solid; border-bottom-color: transparent; top: 30px;"></div><div class="CodeMirror-gutters" style="display: none; height: 30px;"></div></div></div></pre><p><span>测试:</span></p><pre class="md-fences md-end-block ty-contain-cm modeLoaded" spellcheck="false" lang="c"><div class="CodeMirror cm-s-inner cm-s-null-scroll CodeMirror-wrap" lang="c"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 5px; left: 4px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">g</span><span class="cm-operator">++</span> <span class="cm-variable">conv_test</span>.<span class="cm-variable">cpp</span> <span class="cm-operator">-</span><span class="cm-variable">o</span> <span class="cm-variable">conv_test</span> <span class="cm-operator">-</span><span class="cm-variable">lautodiff</span> <span class="cm-operator">&&</span> .<span class="cm-operator">/</span><span class="cm-variable">conv_test</span></span></pre></div></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom-width: 0px; border-bottom-style: solid; border-bottom-color: transparent; top: 15px;"></div><div class="CodeMirror-gutters" style="display: none; height: 15px;"></div></div></div></pre><h3 id='模型定义方法'><span>模型定义方法:</span></h3><pre class="md-fences md-end-block ty-contain-cm modeLoaded" spellcheck="false" lang="c"><div class="CodeMirror cm-s-inner cm-s-null-scroll CodeMirror-wrap" lang="c"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 5px; left: 4px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">edge_network</span>(<span class="cm-variable-3">int</span> <span class="cm-variable">input</span>, <span class="cm-variable-3">int</span> <span class="cm-variable">num_neuron</span>)</span></pre></div></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom-width: 0px; border-bottom-style: solid; border-bottom-color: transparent; top: 15px;"></div><div class="CodeMirror-gutters" style="display: none; height: 15px;"></div></div></div></pre><p><span>作为序列模型api</span></p><p><span>edge_network作为一个类型存在,位于matrix_grad.h中结构体类型的数据</span></p><p><span>定义了前向传播函数,前向传播无激活版,反向传播,末层反向传播,四大最常用的函数主体.</span></p><p><span>完整的序列模型:</span></p><p><img src="picture/image-20200128154352842.png" referrerpolicy="no-referrer" alt="image-20200128154352842"></p><h3 id='实现5层全连接层可自定义神经元和激活函数损失函数'><span>实现5层全连接层,可自定义神经元和激活函数,损失函数</span></h3><p><span>全连接层使用方法:</span></p><p><span>第一层的权重自定义,而后调用forward函数前向传播一层,自动求出激活以后的值,激活函数可自定义.</span></p><p><span>首先定义一个权重矩阵和偏置矩阵,第一个矩阵的维度大小使用数据列去定义:</span></p><pre class="md-fences md-end-block ty-contain-cm modeLoaded" spellcheck="false" lang="c"><div class="CodeMirror cm-s-inner cm-s-null-scroll CodeMirror-wrap" lang="c"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 5.5px; left: 4px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">Matrix</span> <span class="cm-variable">bias1</span> <span class="cm-operator">=</span> <span class="cm-variable">CreateRandMat</span>(<span class="cm-number">2</span>,<span class="cm-number">1</span>);</span></pre></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">Matrix</span> <span class="cm-variable">weight1</span> <span class="cm-operator">=</span> <span class="cm-variable">CreateRandMat</span>(<span class="cm-number">2</span>,<span class="cm-variable">data</span>.<span class="cm-variable">col</span>);</span></pre></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom-width: 0px; border-bottom-style: solid; border-bottom-color: transparent; top: 30px;"></div><div class="CodeMirror-gutters" style="display: none; height: 30px;"></div></div></div></pre><p><span>之后可以输出第一层前向传播的值,同时可以定义下一层的bias的维度, row使用第一层的权重矩阵的行,第二层的权重矩阵的行使用了第一层的输出的行, 而列自行定义即可, 这一点体现了前向传播算法的维度相容. 也就是:</span></p><pre class="md-fences md-end-block ty-contain-cm modeLoaded" spellcheck="false" lang="c"><div class="CodeMirror cm-s-inner cm-s-null-scroll CodeMirror-wrap" lang="c"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 5.5px; left: 4px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">Matrix</span> <span class="cm-variable">output1</span> <span class="cm-operator">=</span> <span class="cm-variable">sequaltial</span>.<span class="cm-variable">forward</span>(<span class="cm-variable">get_T</span>(<span class="cm-variable">get_row</span>(<span class="cm-variable">data_mine</span>,<span class="cm-variable">index</span>)),<span class="cm-variable">weight1</span>,<span class="cm-variable">bias1</span>);</span></pre></div></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom-width: 0px; border-bottom-style: solid; border-bottom-color: transparent; top: 30px;"></div><div class="CodeMirror-gutters" style="display: none; height: 30px;"></div></div></div></pre><pre class="md-fences md-end-block ty-contain-cm modeLoaded" spellcheck="false" lang="c"><div class="CodeMirror cm-s-inner cm-s-null-scroll CodeMirror-wrap" lang="c"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 5.5px; left: 4px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">Matrix</span> <span class="cm-variable">weight2</span> <span class="cm-operator">=</span> <span class="cm-variable">CreateRandMat</span>(<span class="cm-variable">output1</span>.<span class="cm-variable">row</span>,<span class="cm-number">2</span>);</span></pre></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">Matrix</span> <span class="cm-variable">bias2</span> <span class="cm-operator">=</span> <span class="cm-variable">CreateRandMat</span>(<span class="cm-variable">weight2</span>.<span class="cm-variable">row</span>,<span class="cm-number">1</span>);</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">Matrix</span> <span class="cm-variable">output2</span> <span class="cm-operator">=</span> <span class="cm-variable">sequaltial</span>.<span class="cm-variable">forward</span>(<span class="cm-variable">output1</span>,<span class="cm-variable">weight2</span>,<span class="cm-variable">bias2</span>);</span></pre></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom-width: 0px; border-bottom-style: solid; border-bottom-color: transparent; top: 45px;"></div><div class="CodeMirror-gutters" style="display: none; height: 45px;"></div></div></div></pre><p><span>同时第二层的输出也可以求出来,以此类推 .</span></p><p><span>最终输出代码见nerual_test.cpp </span><img src="./picture/nerual_test1.png" referrerpolicy="no-referrer" alt="nerual_test1"></p><p><span>代码:</span></p><pre class="md-fences md-end-block ty-contain-cm modeLoaded" spellcheck="false" lang="c" style="page-break-inside: unset;"><div class="CodeMirror cm-s-inner cm-s-null-scroll CodeMirror-wrap" lang="c"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 5.5px; left: 4px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation" style=""><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">Matrix</span> <span class="cm-variable">data_mine</span> <span class="cm-operator">=</span> <span class="cm-variable">CreateRandMat</span>(<span class="cm-number">2</span>,<span class="cm-number">1</span>);</span></pre></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">Matrix</span> <span class="cm-variable">label</span> <span class="cm-operator">=</span> <span class="cm-variable">CreateMatrix</span>(<span class="cm-number">2</span>,<span class="cm-number">1</span>);</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">Matrix</span> <span class="cm-variable">weight1</span> <span class="cm-operator">=</span> <span class="cm-variable">CreateRandMat</span>(<span class="cm-number">2</span>,<span class="cm-number">2</span>);</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">Matrix</span> <span class="cm-variable">weight2</span> <span class="cm-operator">=</span> <span class="cm-variable">CreateRandMat</span>(<span class="cm-number">2</span>,<span class="cm-number">2</span>);</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">Matrix</span> <span class="cm-variable">weight3</span> <span class="cm-operator">=</span> <span class="cm-variable">CreateRandMat</span>(<span class="cm-number">2</span>,<span class="cm-number">2</span>);</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">Matrix</span> <span class="cm-variable">weight4</span> <span class="cm-operator">=</span> <span class="cm-variable">CreateRandMat</span>(<span class="cm-number">2</span>,<span class="cm-number">2</span>);</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-keyword">for</span>(<span class="cm-variable-3">int</span> <span class="cm-variable">epoch</span> <span class="cm-operator">=</span> <span class="cm-number">0</span>;<span class="cm-variable">epoch</span><span class="cm-operator"><</span><span class="cm-number">20</span>;<span class="cm-variable">epoch</span><span class="cm-operator">++</span>)</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">{</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">cout_mat</span>(<span class="cm-variable">weight1</span>);</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">edge_network</span> <span class="cm-variable">sequaltial</span>(<span class="cm-number">2</span>,<span class="cm-number">2</span>);</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="" cm-zwsp="">
</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">Matrix</span> <span class="cm-variable">output1</span> <span class="cm-operator">=</span> <span class="cm-variable">sequaltial</span>.<span class="cm-variable">forward</span>(<span class="cm-variable">data_mine</span>,<span class="cm-variable">weight1</span>);</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">Matrix</span> <span class="cm-variable">output2</span> <span class="cm-operator">=</span> <span class="cm-variable">sequaltial</span>.<span class="cm-variable">forward</span>(<span class="cm-variable">output1</span>,<span class="cm-variable">weight2</span>);</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">Matrix</span> <span class="cm-variable">output3</span> <span class="cm-operator">=</span> <span class="cm-variable">sequaltial</span>.<span class="cm-variable">forward</span>(<span class="cm-variable">output2</span>,<span class="cm-variable">weight3</span>);</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">Matrix</span> <span class="cm-variable">output4</span> <span class="cm-operator">=</span> <span class="cm-variable">sequaltial</span>.<span class="cm-variable">forward</span>(<span class="cm-variable">output3</span>,<span class="cm-variable">weight4</span>);</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">Matrix</span> <span class="cm-variable">output_end</span> <span class="cm-operator">=</span> <span class="cm-variable">sequaltial</span>.<span class="cm-variable">end_layer_backward</span>(<span class="cm-variable">label</span>,<span class="cm-variable">output4</span>);</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-comment">//get the forward</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">Matrix</span> <span class="cm-variable">backward1</span> <span class="cm-operator">=</span> <span class="cm-variable">sequaltial</span>.<span class="cm-variable">backward</span>(<span class="cm-variable">output_end</span>,<span class="cm-variable">output3</span>,<span class="cm-variable">weight4</span>);</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">Matrix</span> <span class="cm-variable">grad_w1w2</span> <span class="cm-operator">=</span> <span class="cm-variable">mul_simple</span>(<span class="cm-variable">backward1</span>,<span class="cm-variable">data_mine</span>);</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">Matrix</span> <span class="cm-variable">backward2</span> <span class="cm-operator">=</span> <span class="cm-variable">sequaltial</span>.<span class="cm-variable">backward</span>(<span class="cm-variable">backward1</span>,<span class="cm-variable">output2</span>,<span class="cm-variable">weight3</span>);</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">Matrix</span> <span class="cm-variable">grad_w3w4</span> <span class="cm-operator">=</span> <span class="cm-variable">mul_simple</span>(<span class="cm-variable">backward2</span>,<span class="cm-variable">data_mine</span>);</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">Matrix</span> <span class="cm-variable">backward3</span> <span class="cm-operator">=</span> <span class="cm-variable">sequaltial</span>.<span class="cm-variable">backward</span>(<span class="cm-variable">backward2</span>,<span class="cm-variable">output1</span>,<span class="cm-variable">weight2</span>);</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">Matrix</span> <span class="cm-variable">grad_w5w6</span> <span class="cm-operator">=</span> <span class="cm-variable">mul_simple</span>(<span class="cm-variable">backward3</span>,<span class="cm-variable">data_mine</span>);</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">Matrix</span> <span class="cm-variable">backward4</span> <span class="cm-operator">=</span> <span class="cm-variable">sequaltial</span>.<span class="cm-variable">backward</span>(<span class="cm-variable">backward3</span>,<span class="cm-variable">output4</span>,<span class="cm-variable">weight1</span>);</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">Matrix</span> <span class="cm-variable">grad_w7w8</span> <span class="cm-operator">=</span> <span class="cm-variable">mul_simple</span>(<span class="cm-variable">backward4</span>,<span class="cm-variable">data_mine</span>);</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">weight1</span> <span class="cm-operator">=</span> <span class="cm-variable">subtract</span>(<span class="cm-variable">weight1</span>,<span class="cm-variable">times_mat</span>(<span class="cm-number">0.0001</span>,<span class="cm-variable">padding</span>(<span class="cm-variable">grad_w1w2</span>,<span class="cm-number">2</span>,<span class="cm-number">2</span>)));</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">weight2</span> <span class="cm-operator">=</span> <span class="cm-variable">subtract</span>(<span class="cm-variable">weight2</span>,<span class="cm-variable">times_mat</span>(<span class="cm-number">0.0001</span>,<span class="cm-variable">padding</span>(<span class="cm-variable">grad_w3w4</span>,<span class="cm-number">2</span>,<span class="cm-number">2</span>)));</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">weight3</span> <span class="cm-operator">=</span> <span class="cm-variable">subtract</span>(<span class="cm-variable">weight3</span>,<span class="cm-variable">times_mat</span>(<span class="cm-number">0.0001</span>,<span class="cm-variable">padding</span>(<span class="cm-variable">grad_w5w6</span>,<span class="cm-number">2</span>,<span class="cm-number">2</span>)));</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">weight4</span> <span class="cm-operator">=</span> <span class="cm-variable">subtract</span>(<span class="cm-variable">weight4</span>,<span class="cm-variable">times_mat</span>(<span class="cm-number">0.0001</span>,<span class="cm-variable">padding</span>(<span class="cm-variable">grad_w7w8</span>,<span class="cm-number">2</span>,<span class="cm-number">2</span>)));</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">}</span></pre></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom-width: 0px; border-bottom-style: solid; border-bottom-color: transparent; top: 450px;"></div><div class="CodeMirror-gutters" style="display: none; height: 450px;"></div></div></div></pre><pre class="md-fences md-end-block ty-contain-cm modeLoaded" spellcheck="false" lang="shell" style="page-break-inside: unset;"><div class="CodeMirror cm-s-inner cm-s-null-scroll CodeMirror-wrap" lang="shell"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 5.5px; left: 4px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation" style=""><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-attribute">---------epoch</span>: <span class="cm-number">0</span><span class="cm-attribute">------------</span></span></pre></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">loss: <span class="cm-number">4</span>.65667</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">loss: <span class="cm-number">3</span>.28273</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-attribute">---------epoch</span>: <span class="cm-number">1</span><span class="cm-attribute">------------</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">loss: <span class="cm-number">4</span>.65655</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">loss: <span class="cm-number">3</span>.28265</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-attribute">---------epoch</span>: <span class="cm-number">2</span><span class="cm-attribute">------------</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">loss: <span class="cm-number">4</span>.65643</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">loss: <span class="cm-number">3</span>.28257</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-attribute">---------epoch</span>: <span class="cm-number">3</span><span class="cm-attribute">------------</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">loss: <span class="cm-number">4</span>.65631</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">loss: <span class="cm-number">3</span>.28249</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-attribute">---------epoch</span>: <span class="cm-number">4</span><span class="cm-attribute">------------</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">loss: <span class="cm-number">4</span>.65619</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">loss: <span class="cm-number">3</span>.2824</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-attribute">---------epoch</span>: <span class="cm-number">5</span><span class="cm-attribute">------------</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">loss: <span class="cm-number">4</span>.65607</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">loss: <span class="cm-number">3</span>.28232</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-attribute">---------epoch</span>: <span class="cm-number">6</span><span class="cm-attribute">------------</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">loss: <span class="cm-number">4</span>.65596</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">loss: <span class="cm-number">3</span>.28224</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-attribute">---------epoch</span>: <span class="cm-number">7</span><span class="cm-attribute">------------</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">loss: <span class="cm-number">4</span>.65584</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">loss: <span class="cm-number">3</span>.28216</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-attribute">---------epoch</span>: <span class="cm-number">8</span><span class="cm-attribute">------------</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">loss: <span class="cm-number">4</span>.65572</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">loss: <span class="cm-number">3</span>.28208</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-attribute">---------epoch</span>: <span class="cm-number">9</span><span class="cm-attribute">------------</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">loss: <span class="cm-number">4</span>.6556</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">loss: <span class="cm-number">3</span>.282</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-attribute">---------epoch</span>: <span class="cm-number">10</span><span class="cm-attribute">------------</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">loss: <span class="cm-number">4</span>.65548</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">loss: <span class="cm-number">3</span>.28192</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-attribute">---------epoch</span>: <span class="cm-number">11</span><span class="cm-attribute">------------</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">loss: <span class="cm-number">4</span>.65536</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">loss: <span class="cm-number">3</span>.28184</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-attribute">---------epoch</span>: <span class="cm-number">12</span><span class="cm-attribute">------------</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">loss: <span class="cm-number">4</span>.65524</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">loss: <span class="cm-number">3</span>.28176</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-attribute">---------epoch</span>: <span class="cm-number">13</span><span class="cm-attribute">------------</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">loss: <span class="cm-number">4</span>.65512</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">loss: <span class="cm-number">3</span>.28168</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-attribute">---------epoch</span>: <span class="cm-number">14</span><span class="cm-attribute">------------</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">loss: <span class="cm-number">4</span>.65501</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">loss: <span class="cm-number">3</span>.2816</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-attribute">---------epoch</span>: <span class="cm-number">15</span><span class="cm-attribute">------------</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">loss: <span class="cm-number">4</span>.65489</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">loss: <span class="cm-number">3</span>.28152</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-attribute">---------epoch</span>: <span class="cm-number">16</span><span class="cm-attribute">------------</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">loss: <span class="cm-number">4</span>.65477</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">loss: <span class="cm-number">3</span>.28144</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-attribute">---------epoch</span>: <span class="cm-number">17</span><span class="cm-attribute">------------</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">loss: <span class="cm-number">4</span>.65465</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">loss: <span class="cm-number">3</span>.28136</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-attribute">---------epoch</span>: <span class="cm-number">18</span><span class="cm-attribute">------------</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">loss: <span class="cm-number">4</span>.65453</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">loss: <span class="cm-number">3</span>.28128</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-attribute">---------epoch</span>: <span class="cm-number">19</span><span class="cm-attribute">------------</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">loss: <span class="cm-number">4</span>.65441</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">loss: <span class="cm-number">3</span>.2812</span></pre></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom-width: 0px; border-bottom-style: solid; border-bottom-color: transparent; top: 900px;"></div><div class="CodeMirror-gutters" style="display: none; height: 900px;"></div></div></div></pre><h2 id='bp反向传播的demo程序基于pytorch官方代码模拟实现测试'><span>Bp反向传播的demo程序基于Pytorch官方代码模拟实现测试</span></h2><p><span>迭代结果 :</span></p><p><span>W1: 0.6944 1.52368</span>
<span> </span><span>-1.46644 -0.154097</span>
<span>W2: 1.10079</span>
<span> </span><span>0.462984</span>
<span>loss: 0.559269</span></p><p><span>epoch:100 , 可自行测试.</span></p><p><span>输出最终损失和参数迭代结果.</span></p><p><span>-----------split-line-----------</span>
<span>2.79955</span>
<span>0.36431</span>
<span>-0.451694</span>
<span>epoch: 100 error: 6.05895</span>
<span>-----------split-line-----------</span>
<span>0.009167(sum of loss)</span></p><h3 id='目前实现的程序接口'><span>目前实现的程序接口</span></h3><h3 id='api'><span>API:</span></h3><ul><li class='md-task-list-item task-list-item task-list-done' ><input type='checkbox' checked/><p><span>Matrix read_csv(string &file_path)读取格式化文件(csv),返回一个自动计算长度的矩阵.</span></p></li><li class='md-task-list-item task-list-item task-list-done' ><input type='checkbox' checked/><p><span>实现格式化文件写入接口.比较pandas.to_csv.</span></p></li><li class='md-task-list-item task-list-item task-list-done' ><input type='checkbox' checked/><p><span>矩阵广播机制,实现padding接口</span></p></li><li class='md-task-list-item task-list-item task-list-done' ><input type='checkbox' checked/><p><span>全连接层前向传播和反向传播接口,支持自动求导</span></p></li><li class='md-task-list-item task-list-item task-list-done' ><input type='checkbox' checked/><p><span>矩阵微分和自动求导接口封装</span></p></li><li class='md-task-list-item task-list-item task-list-done' ><input type='checkbox' checked/><p><span>int save_txt(Matrix mid1,string path = "./",string delimiter = ",",string header="./") 设计文件流获取文件头部接口 , 写入格式化文件 , 已设计支持矩阵类型数据写入,支持自定义表头,写入文件路径 , 自定义分隔符,默认为" , ".</span></p></li><li class='md-task-list-item task-list-item task-list-done' ><input type='checkbox' checked/><p><span>Create a matrix : create(row,cols)开辟一个矩阵结构的内存,元素初值为0;</span></p></li><li class='md-task-list-item task-list-item task-list-done' ><input type='checkbox' checked/><p><span>Change the element for matrix void move_ele(int &ele1, int &ele2),修改某一个位置的元素的值.</span></p></li><li class='md-task-list-item task-list-item task-list-done' ><input type='checkbox' checked/><p><span>Matrix1+Matrix2 : Matrix add(Matrix mid1,Matrix mid2,int flag=1),矩阵加和操作接口,可选位运算加速.</span></p></li><li class='md-task-list-item task-list-item task-list-done' ><input type='checkbox' checked/><p><span>Flag is how to compete the ele ,default 1 ,bitwise operation(位运算加速).</span></p></li><li class='md-task-list-item task-list-item task-list-done' ><input type='checkbox' checked/><p><span>Matrix1-Matrix2 : Matrix subtract(Matrix mid1,Matrix mid2)</span></p></li><li class='md-task-list-item task-list-item task-list-done' ><input type='checkbox' checked/><p><span>Matrix1*Matrix2 : Matrix mul(Matrix mid1,Matrix mid2)</span></p></li><li class='md-task-list-item task-list-item task-list-done' ><input type='checkbox' checked/><p><span>Matrix1*n : Matrix times_mat(int times,Matrix mid1)</span></p></li><li class='md-task-list-item task-list-item task-list-done' ><input type='checkbox' checked/><p><span>Matrix1's Transposition : Matrix get_T(Matrix mid1)矩阵转置</span></p></li><li class='md-task-list-item task-list-item task-list-done' ><input type='checkbox' checked/><p><span>Mul(matrix1,matrix2)矩阵乘积(完整数学定义).</span></p></li><li class='md-task-list-item task-list-item task-list-done' ><input type='checkbox' checked/><p><span>double* flatten(Matrix mid1) : Return a flattened array.矩阵展开</span></p></li><li class='md-task-list-item task-list-item task-list-done' ><input type='checkbox' checked/><p><span>Matrix matrix_rs(Matrix mid1,int rs_row,int rs_col) 矩阵的结构压缩</span></p></li><li class='md-task-list-item task-list-item task-list-done' ><input type='checkbox' checked/><p><span>double matrix_sum(Matrix mid1)矩阵求和</span></p></li><li class='md-task-list-item task-list-item task-list-done' ><input type='checkbox' checked/><p><span>double matrix_mean(Matrix mid1)均值</span></p></li><li class='md-task-list-item task-list-item task-list-done' ><input type='checkbox' checked/><p><span>Matrix appply(Matrix mid1,Matrix mid2,int axis = 0)矩阵拼接</span></p></li><li class='md-task-list-item task-list-item task-list-done' ><input type='checkbox' checked/><p><span>Matrix iloc(Matrix mid1,int start_x=0,int end_x=0,int start_y=0,int end_y=0)矩阵切片</span></p></li><li class='md-task-list-item task-list-item task-list-done' ><input type='checkbox' checked/><p><span>Matrix mul_simple(Matrix mid1,Matrix mid2)为了贴合机器学习的需要,实现了矩阵对应元素相乘,请与传统意义的矩阵乘法区分开.</span></p></li><li class='md-task-list-item task-list-item task-list-done' ><input type='checkbox' checked/><p><span>Relu激活函数矩阵接口</span></p></li><li class='md-task-list-item task-list-item task-list-done' ><input type='checkbox' checked/><p><span>均方误差矩阵接口</span></p></li><li class='md-task-list-item task-list-item task-list-done' ><input type='checkbox' checked/><p><span>创建随机权重矩阵接口</span></p></li><li class='md-task-list-item task-list-item task-list-done' ><input type='checkbox' checked/><p><span>卷积神经网络定义(包括但不限于卷积核,池化层定义,自定义损失接口).</span></p><h3 id='即将着手开发'><span>即将着手开发:</span></h3></li><li class='md-task-list-item task-list-item task-list-not-done' ><input type='checkbox' /><p><span>主流网络架构实现.</span></p><p> </p></li></ul><h2 id='反向传播测试demo'><span>反向传播测试demo:</span></h2><pre class="md-fences md-end-block ty-contain-cm modeLoaded" spellcheck="false" lang="c" style="page-break-inside: unset;"><div class="CodeMirror cm-s-inner cm-s-null-scroll CodeMirror-wrap" lang="c"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 5.5px; left: 4px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation" style=""><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-meta">#include<iostream></span></span></pre></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-meta">#include<ctime></span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-meta">#include<string></span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-meta">#include<time.h></span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-meta">#include<math.h></span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-meta">#include<fstream></span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-meta">#include<stdlib.h></span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-meta">#include"./matrix/matrix_def.h"</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-meta">#include"./matrix/matrix_pro.h"</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-meta">#include"./welcome/score_wel.cpp"</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-meta">#include"./logistic/logistic_def.h"</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-meta">#include"./file_pro/data_read.h"</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">using</span> <span class="cm-variable">namespace</span> <span class="cm-variable">std</span>;</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">clock_t</span> <span class="cm-variable">start</span>, <span class="cm-variable">stop</span>;</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable-3">double</span> <span class="cm-variable">duration</span>;</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable-3">int</span> <span class="cm-def">main</span>()</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">{</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" class="cm-tab-wrap-hack" style="padding-right: 0.1px;"><span class="cm-tab" role="presentation" cm-text=" "> </span><span class="cm-variable">welcome</span>();<span class="cm-tab" role="presentation" cm-text=" "> </span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-tab" role="presentation" cm-text=" "> </span><span class="cm-variable">string</span> <span class="cm-variable">path</span> <span class="cm-operator">=</span> <span class="cm-string">"./data/nerual_data.csv"</span>;</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-tab" role="presentation" cm-text=" "> </span><span class="cm-variable">Matrix</span> <span class="cm-variable">data</span> <span class="cm-operator">=</span> <span class="cm-variable">read_csv</span>(<span class="cm-variable">path</span>);</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" class="cm-tab-wrap-hack" style="padding-right: 0.1px;"><span class="cm-tab" role="presentation" cm-text=" "> </span><span class="cm-variable">Matrix</span> <span class="cm-variable">bais</span> <span class="cm-operator">=</span> <span class="cm-variable">CreateMatrix</span>(<span class="cm-variable">data</span>.<span class="cm-variable">row</span>,<span class="cm-number">1</span>);<span class="cm-tab" role="presentation" cm-text=" "> </span><span class="cm-tab" role="presentation" cm-text=" "> </span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-tab" role="presentation" cm-text=" "> </span><span class="cm-variable">Matrix</span> <span class="cm-variable">x</span> <span class="cm-operator">=</span> <span class="cm-variable">iloc</span>(<span class="cm-variable">data</span>,<span class="cm-number">0</span>,<span class="cm-number">100</span>,<span class="cm-number">0</span>,<span class="cm-number">2</span>);</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-tab" role="presentation" cm-text=" "> </span><span class="cm-variable">Matrix</span> <span class="cm-variable">y</span> <span class="cm-operator">=</span> <span class="cm-variable">iloc</span>(<span class="cm-variable">data</span>,<span class="cm-number">0</span>,<span class="cm-number">100</span>,<span class="cm-number">2</span>,<span class="cm-number">3</span>);</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-tab" role="presentation" cm-text=" "> </span><span class="cm-variable-3">int</span> <span class="cm-variable">N</span><span class="cm-operator">=</span><span class="cm-number">100</span>,<span class="cm-variable">in_Dim</span><span class="cm-operator">=</span><span class="cm-number">2</span>,<span class="cm-variable">H_num</span><span class="cm-operator">=</span><span class="cm-number">2</span>,<span class="cm-variable">out_Dim</span><span class="cm-operator">=</span><span class="cm-number">2</span>;</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-tab" role="presentation" cm-text=" "> </span><span class="cm-variable-3">double</span> <span class="cm-variable">learning_rate</span> <span class="cm-operator">=</span> <span class="cm-number">0.0001</span>;</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-tab" role="presentation" cm-text=" "> </span><span class="cm-variable">Matrix</span> <span class="cm-variable">W1</span> <span class="cm-operator">=</span> <span class="cm-variable">CreateRandMat</span>(<span class="cm-variable">in_Dim</span>,<span class="cm-variable">H_num</span>);</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-tab" role="presentation" cm-text=" "> </span><span class="cm-variable">Matrix</span> <span class="cm-variable">W2</span> <span class="cm-operator">=</span> <span class="cm-variable">CreateRandMat</span>(<span class="cm-variable">H_num</span>,<span class="cm-variable">out_Dim</span>);</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-tab" role="presentation" cm-text=" "> </span><span class="cm-variable">cout_mat</span>(<span class="cm-variable">W1</span>);</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-tab" role="presentation" cm-text=" "> </span><span class="cm-variable">cout_mat</span>(<span class="cm-variable">W2</span>);</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-tab" role="presentation" cm-text=" "> </span><span class="cm-keyword">for</span>(<span class="cm-variable-3">int</span> <span class="cm-variable">epoch</span> <span class="cm-operator">=</span> <span class="cm-number">0</span>;<span class="cm-variable">epoch</span><span class="cm-operator"><</span><span class="cm-number">100</span>;<span class="cm-variable">epoch</span><span class="cm-operator">++</span>)</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-tab" role="presentation" cm-text=" "> </span>{</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-tab" role="presentation" cm-text=" "> </span><span class="cm-tab" role="presentation" cm-text=" "> </span><span class="cm-variable">Matrix</span> <span class="cm-variable">x_w1</span> <span class="cm-operator">=</span> <span class="cm-variable">mul</span>(<span class="cm-variable">x</span>,<span class="cm-variable">W1</span>);</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-tab" role="presentation" cm-text=" "> </span><span class="cm-tab" role="presentation" cm-text=" "> </span><span class="cm-variable">Matrix</span> <span class="cm-variable">re</span> <span class="cm-operator">=</span> <span class="cm-variable">mat_relu</span>(<span class="cm-variable">x_w1</span>);</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-tab" role="presentation" cm-text=" "> </span><span class="cm-tab" role="presentation" cm-text=" "> </span><span class="cm-variable">Matrix</span> <span class="cm-variable">out</span> <span class="cm-operator">=</span> <span class="cm-variable">mul</span>(<span class="cm-variable">re</span>,<span class="cm-variable">W2</span>);</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-tab" role="presentation" cm-text=" "> </span><span class="cm-tab" role="presentation" cm-text=" "> </span><span class="cm-variable">Matrix</span> <span class="cm-variable">mat_sq</span> <span class="cm-operator">=</span> <span class="cm-variable">mat_sq_loss</span>(<span class="cm-variable">out</span>,<span class="cm-variable">y</span>);</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-tab" role="presentation" cm-text=" "> </span><span class="cm-tab" role="presentation" cm-text=" "> </span><span class="cm-variable">Matrix</span> <span class="cm-variable">grad_y_pred</span> <span class="cm-operator">=</span> <span class="cm-variable">times_mat</span>(<span class="cm-number">2.0</span>,<span class="cm-variable">subtract</span>(<span class="cm-variable">out</span>,<span class="cm-variable">y</span>));</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-tab" role="presentation" cm-text=" "> </span><span class="cm-tab" role="presentation" cm-text=" "> </span><span class="cm-variable">Matrix</span> <span class="cm-variable">grad_w2</span> <span class="cm-operator">=</span> <span class="cm-variable">mul</span>(<span class="cm-variable">get_T</span>(<span class="cm-variable">re</span>),<span class="cm-variable">grad_y_pred</span>);</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-tab" role="presentation" cm-text=" "> </span><span class="cm-tab" role="presentation" cm-text=" "> </span><span class="cm-variable">Matrix</span> <span class="cm-variable">grad_h_relu</span> <span class="cm-operator">=</span> <span class="cm-variable">mul</span>(<span class="cm-variable">grad_y_pred</span>,<span class="cm-variable">get_T</span>(<span class="cm-variable">W2</span>));</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-tab" role="presentation" cm-text=" "> </span><span class="cm-tab" role="presentation" cm-text=" "> </span><span class="cm-variable">Matrix</span> <span class="cm-variable">grad_h_relu_copy</span> <span class="cm-operator">=</span> <span class="cm-variable">mat_relu</span>(<span class="cm-variable">grad_h_relu</span>);</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-tab" role="presentation" cm-text=" "> </span><span class="cm-tab" role="presentation" cm-text=" "> </span><span class="cm-variable">Matrix</span> <span class="cm-variable">grad_w1</span> <span class="cm-operator">=</span> <span class="cm-variable">mul</span>(<span class="cm-variable">get_T</span>(<span class="cm-variable">x</span>),<span class="cm-variable">grad_h_relu_copy</span>);</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-tab" role="presentation" cm-text=" "> </span><span class="cm-tab" role="presentation" cm-text=" "> </span><span class="cm-variable">Matrix</span> <span class="cm-variable">dw1</span> <span class="cm-operator">=</span> <span class="cm-variable">times_mat</span>(<span class="cm-variable">learning_rate</span>,<span class="cm-variable">mul</span>(<span class="cm-variable">get_T</span>(<span class="cm-variable">x</span>),<span class="cm-variable">grad_h_relu_copy</span>));</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-tab" role="presentation" cm-text=" "> </span><span class="cm-tab" role="presentation" cm-text=" "> </span><span class="cm-variable">W1</span> <span class="cm-operator">=</span> <span class="cm-variable">subtract</span>(<span class="cm-variable">W1</span>,<span class="cm-variable">dw1</span>);</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-tab" role="presentation" cm-text=" "> </span><span class="cm-tab" role="presentation" cm-text=" "> </span><span class="cm-variable">W2</span> <span class="cm-operator">=</span> <span class="cm-variable">subtract</span>(<span class="cm-variable">W2</span>,<span class="cm-variable">times_mat</span>(<span class="cm-variable">learning_rate</span>,<span class="cm-variable">grad_w2</span>));</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-tab" role="presentation" cm-text=" "> </span><span class="cm-tab" role="presentation" cm-text=" "> </span><span class="cm-variable">cout</span><span class="cm-operator"><<</span><span class="cm-string">"W1: "</span>;</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-tab" role="presentation" cm-text=" "> </span><span class="cm-tab" role="presentation" cm-text=" "> </span><span class="cm-variable">cout_mat</span>(<span class="cm-variable">W1</span>);</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-tab" role="presentation" cm-text=" "> </span><span class="cm-tab" role="presentation" cm-text=" "> </span><span class="cm-variable">cout</span><span class="cm-operator"><<</span><span class="cm-string">"W2: "</span>;</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-tab" role="presentation" cm-text=" "> </span><span class="cm-tab" role="presentation" cm-text=" "> </span><span class="cm-variable">cout_mat</span>(<span class="cm-variable">W2</span>);</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-tab" role="presentation" cm-text=" "> </span><span class="cm-tab" role="presentation" cm-text=" "> </span><span class="cm-variable">cout</span><span class="cm-operator"><<</span><span class="cm-string">"loss"</span><span class="cm-operator"><<</span><span class="cm-string">": "</span>;</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-tab" role="presentation" cm-text=" "> </span><span class="cm-tab" role="presentation" cm-text=" "> </span><span class="cm-variable">cout</span><span class="cm-operator"><<</span><span class="cm-variable">matrix_sum</span>(<span class="cm-variable">mat_sq</span>)<span class="cm-operator">/</span><span class="cm-number">100</span><span class="cm-operator"><<</span><span class="cm-variable">endl</span>;</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-tab" role="presentation" cm-text=" "> </span>}</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">}</span></pre></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom-width: 0px; border-bottom-style: solid; border-bottom-color: transparent; top: 765px;"></div><div class="CodeMirror-gutters" style="display: none; height: 765px;"></div></div></div></pre><p> </p><h2 id='演示矩阵乘法'><span>演示:矩阵乘法</span></h2><p><span>Matrix </span><strong><span>A</span></strong><span>:</span></p><figure><table><thead><tr><th><span>第1列</span></th><th><span>第2列</span></th><th><span>第3列</span></th><th><span>第4列</span></th><th><span>第5列</span></th></tr></thead><tbody><tr><td><span>72.0000</span></td><td><span>0.0000</span></td><td><span>0.0000</span></td><td><span>0.0000</span></td><td><span>0.0000</span></td></tr><tr><td><span>0.0000</span></td><td><span>64.0000</span></td><td><span>0.0000</span></td><td><span>0.0000</span></td><td><span>0.0000</span></td></tr><tr><td><span>16.0000</span></td><td><span>8.0000</span></td><td><span>0.0000</span></td><td><span>0.0000</span></td><td><span>0.0000</span></td></tr><tr><td><span>0.0000</span></td><td><span>0.0000</span></td><td><span>56.0000</span></td><td><span>16.0000</span></td><td><span>32.0000</span></td></tr><tr><td><span>0.0000</span></td><td><span>0.0000</span></td><td><span>0.0000</span></td><td><span>0.0000</span></td><td><span>0.0000</span></td></tr><tr><td><span>0.0000</span></td><td><span>0.0000</span></td><td><span>0.0000</span></td><td><span>0.0000</span></td><td><span>0.0000</span></td></tr></tbody></table></figure><p><span>MAtrix </span><strong><span>B</span></strong><span>:</span></p><figure><table><thead><tr><th><span>第1列</span></th><th><span>第2列</span></th><th><span>第3列</span></th><th><span>第4列</span></th><th><span>第5列</span></th><th><span>第6列</span></th></tr></thead><tbody><tr><td><span>72.0000</span></td><td><span>0.0000</span></td><td><span>16.0000</span></td><td><span>0.0000</span></td><td><span>0.0000</span></td><td><span>0.0000</span></td></tr><tr><td><span>0.0000</span></td><td><span>64.0000</span></td><td><span>8.0000</span></td><td><span>0.0000</span></td><td><span>0.0000</span></td><td><span>0.0000</span></td></tr><tr><td><span>0.0000</span></td><td><span>0.0000</span></td><td><span>0.0000</span></td><td><span>56.0000</span></td><td><span>0.0000</span></td><td><span>0.0000</span></td></tr><tr><td><span>0.0000</span></td><td><span>0.0000</span></td><td><span>0.0000</span></td><td><span>16.0000</span></td><td><span>0.0000</span></td><td><span>0.0000</span></td></tr><tr><td><span>0.0000</span></td><td><span>0.0000</span></td><td><span>0.0000</span></td><td><span>32.0000</span></td><td><span>0.0000</span></td><td><span>0.0000</span></td></tr></tbody></table></figure><p><span>To</span></p><figure><table><thead><tr><th><span>第1列</span></th><th><span>第2列</span></th><th><span>第3列</span></th><th><span>第4列</span></th><th><span>第5列</span></th><th><span>第6列</span></th></tr></thead><tbody><tr><td><span>5184.0000</span></td><td><span>0.0000</span></td><td><span>1152.0000</span></td><td><span>0.0000</span></td><td><span>0.0000</span></td><td><span>0.0000</span></td></tr><tr><td><span>0.0000</span></td><td><span>4096.0000</span></td><td><span>512.0000</span></td><td><span>0.0000</span></td><td><span>0.0000</span></td><td><span>0.0000</span></td></tr><tr><td><span>1152.0000</span></td><td><span>512.0000</span></td><td><span>320.0000</span></td><td><span>0.0000</span></td><td><span>0.0000</span></td><td><span>0.0000</span></td></tr><tr><td><span>0.0000</span></td><td><span>0.0000</span></td><td><span>0.0000</span></td><td><span>4416.0000</span></td><td><span>0.0000</span></td><td><span>0.0000</span></td></tr><tr><td><span>0.0000</span></td><td><span>0.0000</span></td><td><span>0.0000</span></td><td><span>0.0000</span></td><td><span>0.0000</span></td><td><span>0.0000</span></td></tr><tr><td><span>0.0000</span></td><td><span>0.0000</span></td><td><span>0.0000</span></td><td><span>0.0000</span></td><td><span>0.0000</span></td><td><span>0.0000</span></td></tr></tbody></table></figure><h2 id='演示-矩阵展开flatten'><span>演示: 矩阵展开(flatten).</span></h2><p><span>double* flatten(Matrix mid1)</span></p><figure><table><thead><tr><th style='text-align:center;' ><span>1</span></th><th style='text-align:center;' ><span>2</span></th><th style='text-align:center;' ><span>3</span></th></tr></thead><tbody><tr><td style='text-align:center;' ><span>2</span></td><td style='text-align:center;' ><span>4</span></td><td style='text-align:center;' ><span>6</span></td></tr><tr><td style='text-align:center;' ><span>7</span></td><td style='text-align:center;' ><span>8</span></td><td style='text-align:center;' ><span>9</span></td></tr></tbody></table></figure><p><span> </span><span>To</span></p><figure><table><thead><tr><th><span>1</span></th><th><span>2</span></th><th><span>3</span></th><th><span>2</span></th><th><span>4</span></th><th><span>6</span></th><th><span>7</span></th><th><span>8</span></th><th style='text-align:left;' ><span>9</span></th></tr></thead><tbody><tr><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td style='text-align:left;' ><span>Like numpy.flatten</span></td></tr></tbody></table></figure><p><span>function:</span></p><h2 id='演示-邻接矩阵的参数定义'><span>演示: 邻接矩阵的参数定义:</span></h2><p><span> </span><span>Matrix appply(Matrix mid1,Matrix mid2,int axis = 0)</span></p><blockquote><p><span>参数 axis=0 :</span></p></blockquote><figure><table><thead><tr><th><span>0</span></th><th><span>7</span></th><th><span>2</span></th></tr></thead><tbody><tr><td><span>0</span></td><td><span>3</span></td><td><span>1</span></td></tr><tr><td><span>0</span></td><td><span>0</span></td><td><span>0</span></td></tr><tr><td><span>0</span></td><td><span>0</span></td><td><span>11</span></td></tr><tr><td><span>0</span></td><td><span>7</span></td><td><span>2</span></td></tr><tr><td><span>0</span></td><td><span>3</span></td><td><span>1</span></td></tr><tr><td><span>0</span></td><td><span>0</span></td><td><span>0</span></td></tr><tr><td><span>0</span></td><td><span>0</span></td><td><span>11</span></td></tr></tbody></table></figure><hr /><blockquote><p><span>axis = 1:</span></p></blockquote><figure><table><thead><tr><th><span>0</span></th><th><span>7</span></th><th><span>2</span></th><th><span>0</span></th><th><span>7</span></th><th><span>2</span></th></tr></thead><tbody><tr><td><span>0</span></td><td><span>3</span></td><td><span>1</span></td><td><span>0</span></td><td><span>3</span></td><td><span>1</span></td></tr><tr><td><span>0</span></td><td><span>0</span></td><td><span>0</span></td><td><span>0</span></td><td><span>0</span></td><td><span>0</span></td></tr><tr><td><span>0</span></td><td><span>0</span></td><td><span>11</span></td><td><span>0</span></td><td><span>0</span></td><td><span>11</span></td></tr></tbody></table></figure><hr /><h2 id='更新201911180012'><span>更新2019/11/18/00:12</span></h2><ul><li class='md-task-list-item task-list-item task-list-done' ><input type='checkbox' checked/><p><span>read_csv 通过文件流读取逗号分隔符文件,返回一个自动计算长度的矩阵.</span></p><p><span>例如 CSV's head :</span></p><figure><table><thead><tr><th><span>-0.017612</span></th><th><span>14.053064</span></th><th><span>0</span></th></tr></thead><tbody><tr><td><span>-1.395634</span></td><td><span>4.662541</span></td><td><span>1</span></td></tr><tr><td><span>-0.752157</span></td><td><span>6.53862</span></td><td><span>0</span></td></tr><tr><td><span>-1.322371</span></td><td><span>7.152853</span></td><td><span>0</span></td></tr><tr><td><span>0.423363</span></td><td><span>11.054677</span></td><td><span>0</span></td></tr><tr><td><span>0.406704</span></td><td><span>7.067335</span></td><td><span>1</span></td></tr></tbody></table></figure><p><span>Get:</span></p><p><img src="./picture/[email protected]" referrerpolicy="no-referrer"></p><p> </p><h2 id='logistic-regression-demo-base-edge'><span>Logistic Regression demo base Edge:</span></h2></li></ul><pre class="md-fences md-end-block ty-contain-cm modeLoaded" spellcheck="false" lang="c" style="page-break-inside: unset;"><div class="CodeMirror cm-s-inner cm-s-null-scroll CodeMirror-wrap" lang="c"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 5.5px; left: 4px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation" style=""><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-meta">#include<iostream></span></span></pre></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-meta">#include<ctime></span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-meta">#include<string></span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-meta">#include <time.h></span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-meta">#include <math.h></span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-meta">#include <fstream></span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-meta">#include"./matrix/matrix_def.h"</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-meta">#include"./matrix/matrix_pro.h"</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-meta">#include"./welcome/score_wel.cpp"</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-meta">#include"./logistic/logistic_def.h"</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-meta">#include"./file_pro/data_read.h"</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">using</span> <span class="cm-variable">namespace</span> <span class="cm-variable">std</span>;</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">clock_t</span> <span class="cm-variable">start</span>, <span class="cm-variable">stop</span>;</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable-3">double</span> <span class="cm-variable">duration</span>;</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable-3">int</span> <span class="cm-def">main</span>()</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">{</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" class="cm-tab-wrap-hack" style="padding-right: 0.1px;"><span class="cm-tab" role="presentation" cm-text=" "> </span><span class="cm-variable">welcome</span>();<span class="cm-tab" role="presentation" cm-text=" "> </span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-tab" role="presentation" cm-text=" "> </span><span class="cm-variable">string</span> <span class="cm-variable">path</span> <span class="cm-operator">=</span> <span class="cm-string">"./new_data2.csv"</span>;</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-tab" role="presentation" cm-text=" "> </span><span class="cm-variable">Matrix</span> <span class="cm-variable">data</span> <span class="cm-operator">=</span> <span class="cm-variable">read_csv</span>(<span class="cm-variable">path</span>);</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" class="cm-tab-wrap-hack" style="padding-right: 0.1px;"><span class="cm-tab" role="presentation" cm-text=" "> </span><span class="cm-variable">Matrix</span> <span class="cm-variable">bais</span> <span class="cm-operator">=</span> <span class="cm-variable">CreateMatrix</span>(<span class="cm-variable">data</span>.<span class="cm-variable">row</span>,<span class="cm-number">1</span>);<span class="cm-tab" role="presentation" cm-text=" "> </span><span class="cm-tab" role="presentation" cm-text=" "> </span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-tab" role="presentation" cm-text=" "> </span><span class="cm-variable">data</span> <span class="cm-operator">=</span> <span class="cm-variable">appply</span>(<span class="cm-variable">data</span>,<span class="cm-variable">bais</span>,<span class="cm-number">1</span>);</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-tab" role="presentation" cm-text=" "> </span><span class="cm-variable">Matrix</span> <span class="cm-variable">y</span> <span class="cm-operator">=</span> <span class="cm-variable">iloc</span>(<span class="cm-variable">data</span>,<span class="cm-number">0</span>,<span class="cm-number">0</span>,<span class="cm-number">3</span>,<span class="cm-number">4</span>);</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-tab" role="presentation" cm-text=" "> </span><span class="cm-variable">Matrix</span> <span class="cm-variable">x_1</span> <span class="cm-operator">=</span> <span class="cm-variable">iloc</span>(<span class="cm-variable">data</span>,<span class="cm-number">0</span>,<span class="cm-number">0</span>,<span class="cm-number">0</span>,<span class="cm-number">3</span>);</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-tab" role="presentation" cm-text=" "> </span><span class="cm-variable">Matrix</span> <span class="cm-variable">x_2</span> <span class="cm-operator">=</span> <span class="cm-variable">get_T</span>(<span class="cm-variable">x_1</span>);</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-tab" role="presentation" cm-text=" "> </span><span class="cm-variable-3">double</span> <span class="cm-variable">alpha</span> <span class="cm-operator">=</span> <span class="cm-number">0.002</span>;</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-tab" role="presentation" cm-text=" "> </span><span class="cm-variable-3">int</span> <span class="cm-variable">max_epoch</span> <span class="cm-operator">=</span> <span class="cm-number">100</span>;</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-tab" role="presentation" cm-text=" "> </span><span class="cm-variable">Matrix</span> <span class="cm-variable">weight</span> <span class="cm-operator">=</span> <span class="cm-variable">CreateMatrix</span>(<span class="cm-number">3</span>,<span class="cm-number">1</span>);</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-tab" role="presentation" cm-text=" "> </span><span class="cm-variable">change_va</span>(<span class="cm-variable">weight</span>,<span class="cm-number">0</span>,<span class="cm-number">0</span>,<span class="cm-number">1</span>);</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-tab" role="presentation" cm-text=" "> </span><span class="cm-variable">change_va</span>(<span class="cm-variable">weight</span>,<span class="cm-number">1</span>,<span class="cm-number">0</span>,<span class="cm-number">1</span>);</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-tab" role="presentation" cm-text=" "> </span><span class="cm-variable">change_va</span>(<span class="cm-variable">weight</span>,<span class="cm-number">2</span>,<span class="cm-number">0</span>,<span class="cm-number">1</span>);</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-tab" role="presentation" cm-text=" "> </span><span class="cm-variable-3">int</span> <span class="cm-variable">epoch</span> <span class="cm-operator">=</span> <span class="cm-number">0</span>;</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-tab" role="presentation" cm-text=" "> </span><span class="cm-keyword">for</span>(<span class="cm-variable">epoch</span> <span class="cm-operator">=</span> <span class="cm-number">0</span>;<span class="cm-variable">epoch</span><span class="cm-operator"><=</span><span class="cm-variable">max_epoch</span>;<span class="cm-variable">epoch</span><span class="cm-operator">++</span>)</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-tab" role="presentation" cm-text=" "> </span>{</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" class="cm-tab-wrap-hack" style="padding-right: 0.1px;"><span class="cm-tab" role="presentation" cm-text=" "> </span><span class="cm-variable">cout</span><span class="cm-operator"><<</span><span class="cm-string">"-----------split-line-----------"</span><span class="cm-operator"><<</span><span class="cm-variable">endl</span>;<span class="cm-tab" role="presentation" cm-text=" "> </span><span class="cm-tab" role="presentation" cm-text=" "> </span><span class="cm-tab" role="presentation" cm-text=" "> </span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-tab" role="presentation" cm-text=" "> </span><span class="cm-variable">Matrix</span> <span class="cm-variable">temp_mul</span> <span class="cm-operator">=</span> <span class="cm-variable">mul</span>(<span class="cm-variable">x_1</span>,<span class="cm-variable">weight</span>);</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-tab" role="presentation" cm-text=" "> </span><span class="cm-variable">Matrix</span> <span class="cm-variable">h</span> <span class="cm-operator">=</span><span class="cm-variable">e_sigmoid</span>(<span class="cm-variable">temp_mul</span>);</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-tab" role="presentation" cm-text=" "> </span><span class="cm-variable">Matrix</span> <span class="cm-variable">error</span> <span class="cm-operator">=</span> <span class="cm-variable">subtract</span>(<span class="cm-variable">y</span>,<span class="cm-variable">h</span>);</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-tab" role="presentation" cm-text=" "> </span><span class="cm-variable">Matrix</span> <span class="cm-variable">temp_update</span> <span class="cm-operator">=</span> <span class="cm-variable">mul</span>(<span class="cm-variable">x_2</span>,<span class="cm-variable">error</span>);</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-tab" role="presentation" cm-text=" "> </span><span class="cm-variable">Matrix</span> <span class="cm-variable">updata</span> <span class="cm-operator">=</span> <span class="cm-variable">add</span>(<span class="cm-variable">weight</span>,<span class="cm-variable">times_mat</span>(<span class="cm-variable">alpha</span>,<span class="cm-variable">temp_update</span>),<span class="cm-number">0</span>);</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-tab" role="presentation" cm-text=" "> </span><span class="cm-variable">cout_mat</span>(<span class="cm-variable">weight</span>);</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-tab" role="presentation" cm-text=" "> </span><span class="cm-variable">cout</span><span class="cm-operator"><<</span><span class="cm-string">"epoch: "</span><span class="cm-operator"><<</span><span class="cm-variable">epoch</span><span class="cm-operator"><<</span><span class="cm-string">" error: "</span><span class="cm-operator"><<</span><span class="cm-variable">matrix_sum</span>(<span class="cm-variable">error</span>)<span class="cm-operator"><<</span><span class="cm-variable">endl</span>;</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" class="cm-tab-wrap-hack" style="padding-right: 0.1px;"><span class="cm-tab" role="presentation" cm-text=" "> </span><span class="cm-variable">cout</span><span class="cm-operator"><<</span><span class="cm-string">"-----------split-line-----------"</span><span class="cm-operator"><<</span><span class="cm-variable">endl</span>;<span class="cm-tab" role="presentation" cm-text=" "> </span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-tab" role="presentation" cm-text=" "> </span>}</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-tab" role="presentation" cm-text=" "> </span><span class="cm-variable">stop</span> <span class="cm-operator">=</span> <span class="cm-variable">clock</span>();</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> <span class="cm-variable">printf</span>(<span class="cm-string">"%f\n"</span>, (<span class="cm-variable-3">double</span>)(<span class="cm-variable">stop</span> <span class="cm-operator">-</span> <span class="cm-variable">start</span>) <span class="cm-operator">/</span> <span class="cm-variable">CLOCKS_PER_SEC</span>);</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-tab" role="presentation" cm-text=" "> </span><span class="cm-keyword">return</span> <span class="cm-number">0</span>;</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">}</span></pre></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom-width: 0px; border-bottom-style: solid; border-bottom-color: transparent; top: 705px;"></div><div class="CodeMirror-gutters" style="display: none; height: 705px;"></div></div></div></pre><p><span>Something :</span></p><blockquote><ol start='' ><li><span>矩阵元素默认为1</span></li><li><span>使用位运算加速防止填充过大的数值,但是会损失一定精度,慎用.</span></li><li><span>记得delete(matrix)在你使用完一个矩阵计算单元以后.</span></li><li><span>api接口更多的接近于pandas和numpy的使用习惯.</span></li><li><span>更多的细节参见目前最新的代码</span></li><li><span>欢迎star和关注.</span></li><li><span>autodiff部分感谢国外博主Omar的思路提醒.</span></li></ol></blockquote><hr /><p> </p><div align="center"><img src="./picture/星月.svg"></div><p><span> 个人小站:</span><a href='http://likedge.top/'><span>极度空间</span></a></p><p><span>作者邮箱:[email protected] | </span><a href='mailto:[email protected]' target='_blank' class='url'>[email protected]</a></p><p><span> QQ:2533524298</span></p></div></div>
</body>
</html>