vlbthambawita commited on
Commit
5be31b1
·
verified ·
1 Parent(s): fcaeaaf

Release site-v1.0.4 (part 3)

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .gitattributes +1 -0
  2. lecture-03/assets/index-UHfzOQ7q.css +0 -0
  3. lecture-03/assets/interactive-CBN7ZXLe.js +1 -0
  4. lecture-03/assets/interactive-D_LX0oud.css +1 -0
  5. lecture-03/assets/logo-BYkHSa_O.png +0 -0
  6. lecture-03/assets/md-12mDjVUb.js +1 -0
  7. lecture-03/assets/md-2xLwDcaF.css +1 -0
  8. lecture-03/assets/md-5DLtPaNo.css +1 -0
  9. lecture-03/assets/md-7Ye1IzaG.js +16 -0
  10. lecture-03/assets/md-AOTeS7la.js +1 -0
  11. lecture-03/assets/md-BCE3_zZH2.js +1 -0
  12. lecture-03/assets/md-BJK-Icy_.js +5 -0
  13. lecture-03/assets/md-BJWJAX7h.js +1 -0
  14. lecture-03/assets/md-BJc_Ngxk.js +13 -0
  15. lecture-03/assets/md-BPSetbzY.js +1 -0
  16. lecture-03/assets/md-BV7tqBmU.css +1 -0
  17. lecture-03/assets/md-BZuzz048.js +1 -0
  18. lecture-03/assets/md-Be9Z9nVr.js +1 -0
  19. lecture-03/assets/md-BfELaV__.js +1 -0
  20. lecture-03/assets/md-BhW511Ut.js +2 -0
  21. lecture-03/assets/md-BjlkbSdd2.js +1 -0
  22. lecture-03/assets/md-Bx7fJlZr2.js +14 -0
  23. lecture-03/assets/md-C20K91iw.css +1 -0
  24. lecture-03/assets/md-C246a0Zo.js +1 -0
  25. lecture-03/assets/md-C2rUqOeQ.js +1 -0
  26. lecture-03/assets/md-C6zLxdHH.js +1 -0
  27. lecture-03/assets/md-C9B1QIfs.css +1 -0
  28. lecture-03/assets/md-CATIlakB.js +1 -0
  29. lecture-03/assets/md-CDHWFGeQ2.js +1 -0
  30. lecture-03/assets/md-CI1ql4wp.js +5 -0
  31. lecture-03/assets/md-CIaX1C6P.js +1 -0
  32. lecture-03/assets/md-CYXxUBJM.css +1 -0
  33. lecture-03/assets/md-Cb-WM6X62.js +1 -0
  34. lecture-03/assets/md-Ceq69z99.js +1 -0
  35. lecture-03/assets/md-Cqra_90r2.js +1 -0
  36. lecture-03/assets/md-Cw0ZpuKK.js +2 -0
  37. lecture-03/assets/md-CxLxpOf2.js +1 -0
  38. lecture-03/assets/md-CyDkwqZf.js +6 -0
  39. lecture-03/assets/md-D1FObvji.js +1 -0
  40. lecture-03/assets/md-D7KY7dJ8.css +1 -0
  41. lecture-03/assets/md-DE2QGCpb.css +1 -0
  42. lecture-03/assets/md-DEacZnAz2.js +4 -0
  43. lecture-03/assets/md-DLy5QXlk.css +1 -0
  44. lecture-03/assets/md-DSqY0rZq.js +1 -0
  45. lecture-03/assets/md-DV4Jznr4.js +1 -0
  46. lecture-03/assets/md-DcE0WCje.js +10 -0
  47. lecture-03/assets/md-DfVty-xn2.js +11 -0
  48. lecture-03/assets/md-DlxdIU0_.js +1 -0
  49. lecture-03/assets/md-DpUFBAFd2.js +1 -0
  50. lecture-03/assets/md-Ds2r8LNq.js +1 -0
.gitattributes CHANGED
@@ -48,3 +48,4 @@ lecture-02/slides.pdf filter=lfs diff=lfs merge=lfs -text
48
  lecture-01/assets/generated-faces-BvUuJNEP.jpeg filter=lfs diff=lfs merge=lfs -text
49
  lecture-07/slides.pdf filter=lfs diff=lfs merge=lfs -text
50
  lecture-05/slides.pdf filter=lfs diff=lfs merge=lfs -text
 
 
48
  lecture-01/assets/generated-faces-BvUuJNEP.jpeg filter=lfs diff=lfs merge=lfs -text
49
  lecture-07/slides.pdf filter=lfs diff=lfs merge=lfs -text
50
  lecture-05/slides.pdf filter=lfs diff=lfs merge=lfs -text
51
+ lecture-03/slides.pdf filter=lfs diff=lfs merge=lfs -text
lecture-03/assets/index-UHfzOQ7q.css ADDED
The diff for this file is too large to render. See raw diff
 
lecture-03/assets/interactive-CBN7ZXLe.js ADDED
@@ -0,0 +1 @@
 
 
1
+ import{B as e,C as t,Ct as n,St as r,T as i,U as a,_ as o,b as s,bt as c,y as l}from"./modules/shiki-CJZsCeMT.js";import{t as u}from"./_plugin-vue_export-helper-BDNMzG2s.js";import{n as d}from"./slidev/context-DB-9afGB.js";import{t as f}from"./DeckFooter-BMnt3Ksi.js";var p={class:`slidev-layout dl-interactive`},m={key:0,class:`dl-interactive__title`},h={class:`dl-interactive__stage`},g=u(i({__name:`interactive`,props:{heading:{},asideWidth:{},asideLeft:{type:Boolean}},setup(i){let{$slidev:u,$nav:g,$clicksContext:_,$clicks:v,$page:y,$renderContext:b,$frontmatter:x}=d(),S=i;return(i,u)=>{let d=f;return e(),s(`div`,p,[S.heading?(e(),s(`h1`,m,n(S.heading),1)):l(`v-if`,!0),o(`div`,{class:c([`dl-interactive__grid`,{"is-aside-left":S.asideLeft}])},[o(`div`,h,[a(i.$slots,`default`,{},void 0,!0)]),o(`div`,{class:`dl-interactive__aside`,style:r({flexBasis:S.asideWidth??`17rem`})},[a(i.$slots,`aside`,{},void 0,!0)],4)],2),t(d)])}}}),[[`__scopeId`,`data-v-0c449bbd`]]);export{g as t};
lecture-03/assets/interactive-D_LX0oud.css ADDED
@@ -0,0 +1 @@
 
 
1
+ .dl-interactive[data-v-0c449bbd]{flex-direction:column;display:flex}.dl-interactive__title[data-v-0c449bbd]{margin-bottom:.7rem}.dl-interactive__grid[data-v-0c449bbd]{flex:auto;align-items:stretch;gap:1.6rem;min-height:0;display:flex}.dl-interactive__grid.is-aside-left[data-v-0c449bbd]{flex-direction:row-reverse}.dl-interactive__stage[data-v-0c449bbd]{flex:auto;justify-content:center;align-items:center;min-width:0;display:flex}.dl-interactive__aside[data-v-0c449bbd]{font-size:var(--dl-fs-secondary);flex-grow:0;flex-shrink:0;overflow-y:auto}.dl-interactive__aside[data-v-0c449bbd]:empty{display:none}
lecture-03/assets/logo-BYkHSa_O.png ADDED
lecture-03/assets/md-12mDjVUb.js ADDED
@@ -0,0 +1 @@
 
 
1
+ import{B as e,C as t,D as n,S as r,_ as i,et as a,v as o,xt as s,yt as c}from"./modules/shiki-CJZsCeMT.js";import{n as l,t as u}from"./slidev/context-DB-9afGB.js";import{t as d}from"./interactive-CBN7ZXLe.js";import{t as f}from"./TensorLadder-CuthEwW0.js";var p={__name:`slides.md__slidev_8`,setup(p){let{$slidev:m,$nav:h,$clicksContext:g,$clicks:_,$page:v,$renderContext:y,$frontmatter:b}=l();return g.setup(),(l,p)=>{let m=f;return e(),o(d,s(n(c(u)(c(b),7))),{aside:a(e=>[...p[0]||=[i(`p`,null,[r(`Click along the tabs. Each picture `),i(`em`,null,`contains`),r(` the one before it — a matrix is a stack of vectors, a batch of images a stack of matrices.`)],-1),i(`div`,{class:`mt-3 dl-secondary`},[i(`p`,null,[r(`Then click a cell. The number in it is its position `),i(`strong`,null,`in memory`),r(`; the index that reaches it is what you type.`)])],-1)]]),default:a(()=>[t(m,{start:`scalar`})]),_:1},16)}}};export{p as default};
lecture-03/assets/md-2xLwDcaF.css ADDED
@@ -0,0 +1 @@
 
 
1
+ .dl-slicer[data-v-7d62ffa3]{width:100%;height:100%}.dl-slicer__head text[data-v-7d62ffa3]{fill:var(--dl-muted);font-variant-numeric:tabular-nums;font-size:10px}.dl-slicer__grid rect[data-v-7d62ffa3]{fill:var(--dl-surface);stroke:var(--dl-border);stroke-width:.8px;transition:fill .15s,stroke .15s}.dl-slicer__grid text[data-v-7d62ffa3]{fill:var(--dl-muted);font-variant-numeric:tabular-nums;font-size:11px}.dl-slicer__grid g.is-on rect[data-v-7d62ffa3]{fill:var(--dl-accent-soft);stroke:var(--dl-accent);stroke-width:1.4px}.dl-slicer__grid g.is-on text[data-v-7d62ffa3]{fill:var(--dl-heading);font-weight:600}.dl-slicer__arrow line[data-v-7d62ffa3]{stroke:var(--dl-muted);stroke-width:1px}.dl-slicer__arrow path[data-v-7d62ffa3]{fill:var(--dl-muted)}.dl-slicer__arrow text[data-v-7d62ffa3]{fill:var(--dl-accent);font-size:12px;font-weight:600;font-family:var(--slidev-code-font-family,monospace)}.dl-slicer__tab[data-v-7d62ffa3]{border:1px solid var(--dl-border);font-family:var(--slidev-code-font-family,monospace);color:var(--dl-body);cursor:pointer;background:0 0;border-radius:6px;padding:.24rem .6rem;font-size:.78rem}.dl-slicer__tab[data-v-7d62ffa3]:hover{border-color:var(--dl-accent);color:var(--dl-accent)}.dl-slicer__tab.is-active[data-v-7d62ffa3]{background:var(--dl-accent);border-color:var(--dl-accent);color:#fff;font-weight:600}.dl-slicer__tab[data-v-7d62ffa3]:focus-visible{outline:2px solid var(--dl-accent);outline-offset:2px}.dl-slicer__facts[data-v-7d62ffa3]{gap:1.4rem;margin-bottom:.2rem;display:flex}.dl-slicer__facts strong[data-v-7d62ffa3]{color:var(--dl-accent);font-size:1rem}.dl-slicer__note[data-v-7d62ffa3]{line-height:1.35}
lecture-03/assets/md-5DLtPaNo.css ADDED
@@ -0,0 +1 @@
 
 
1
+ .dl-mnist[data-v-8c4f21b8]{width:100%;height:100%}.dl-mnist__box[data-v-8c4f21b8]{fill:var(--dl-surface);stroke:var(--dl-border);stroke-width:1.2px}.dl-mnist__ink[data-v-8c4f21b8]{fill:var(--dl-heading)}.dl-mnist__digit[data-v-8c4f21b8]{fill:var(--dl-heading);font-size:20px}.dl-mnist__bar[data-v-8c4f21b8]{fill:var(--dl-surface);stroke:var(--dl-muted);stroke-width:1.2px}.dl-mnist__bar.is-live[data-v-8c4f21b8]{fill:var(--dl-accent);stroke:var(--dl-accent-strong)}.dl-mnist__arrow[data-v-8c4f21b8],.dl-mnist__leader[data-v-8c4f21b8]{stroke:var(--dl-muted);stroke-width:1.2px;fill:none}.dl-mnist__leader[data-v-8c4f21b8]{stroke-dasharray:3 3}.dl-mnist__head[data-v-8c4f21b8]{fill:var(--dl-muted)}.dl-mnist__head.is-fwd[data-v-8c4f21b8]{fill:var(--dl-accent)}.dl-mnist__head.is-back[data-v-8c4f21b8]{fill:var(--dl-danger)}.dl-mnist__cap[data-v-8c4f21b8]{fill:var(--dl-body);font-size:11px}.dl-mnist__sub[data-v-8c4f21b8],.dl-mnist__idx[data-v-8c4f21b8]{fill:var(--dl-muted);font-size:9px}.dl-mnist__op[data-v-8c4f21b8]{fill:var(--dl-muted);font-size:10px}.dl-mnist__count[data-v-8c4f21b8]{fill:var(--dl-heading);font-size:11px;font-weight:600}.dl-mnist__code[data-v-8c4f21b8]{fill:var(--dl-accent-strong);font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:10px}.dl-mnist__code.is-back[data-v-8c4f21b8]{fill:var(--dl-danger)}.dl-mnist__arrow.is-back[data-v-8c4f21b8]{stroke:var(--dl-danger);stroke-dasharray:5 3}.dl-mnist__arrow.is-fwd[data-v-8c4f21b8]{stroke:var(--dl-accent)}.dl-mnist__onehot rect[data-v-8c4f21b8]{fill:var(--dl-surface);stroke:var(--dl-border);stroke-width:1px}.dl-mnist__onehot rect.is-on[data-v-8c4f21b8]{fill:var(--dl-accent-soft);stroke:var(--dl-accent)}.dl-mnist__onehot text[data-v-8c4f21b8]{fill:var(--dl-body);font-size:7px}.dl-mnist__onehot text.is-on[data-v-8c4f21b8]{fill:var(--dl-accent-strong);font-weight:700}.dl-figure[data-v-8876733c]{flex-direction:column;display:flex}.dl-figure__title[data-v-8876733c]{margin-bottom:.8rem}.dl-figure__canvas[data-v-8876733c]{flex:auto;justify-content:center;align-items:center;min-height:0;display:flex}.dl-figure__canvas[data-v-8876733c] img,.dl-figure__canvas[data-v-8876733c] svg{object-fit:contain;max-width:100%;max-height:100%}.dl-figure__footer[data-v-8876733c]{justify-content:space-between;align-items:flex-end;gap:2rem;margin-top:.6rem;display:flex}.dl-figure__caption[data-v-8876733c]{font-size:var(--dl-fs-secondary);color:var(--dl-body)}.dl-figure__citation[data-v-8876733c]{font-size:var(--dl-fs-citation);color:var(--dl-muted);text-align:right;flex-shrink:0}
lecture-03/assets/md-7Ye1IzaG.js ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import{B as e,C as t,D as n,G as r,N as i,S as a,_ as o,b as s,et as c,tt as l,v as u,xt as d,yt as f}from"./modules/shiki-CJZsCeMT.js";import{n as p,t as m}from"./slidev/context-DB-9afGB.js";import{t as h}from"./slidev/CodeBlockWrapper-DqFdVwPK.js";import{t as g}from"./default-IV3yhGVf.js";var _={class:`mt-1 dl-secondary`},v={__name:`slides.md__slidev_33`,setup(v){let{$slidev:y,$nav:b,$clicksContext:x,$clicks:S,$page:C,$renderContext:w,$frontmatter:T}=p();return x.setup(),(p,v)=>{let y=h,b=r(`click`);return e(),u(g,d(n(f(m)(f(T),32))),{default:c(()=>[v[2]||=o(`h1`,null,[a(`An `),o(`code`,null,`nn.Module`),a(` has exactly two parts`)],-1),t(y,i({lines:!0},{title:``,ranges:[`all`,`1-2`,`4-5`,`6-13`,`15-16`,`all`]}),{default:c(()=>[...v[0]||=[o(`pre`,{class:`shiki shiki-themes vitesse-dark vitesse-light slidev-code`,style:{"--shiki-dark":`#dbd7caee`,"--shiki-light":`#393a34`,"--shiki-dark-bg":`#121212`,"--shiki-light-bg":`#ffffff`}},[o(`code`,{class:`language-python`},[o(`span`,{class:`line`},[o(`span`,{style:{"--shiki-dark":`#4D9375`,"--shiki-light":`#1E754F`}},`import`),o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},` torch`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`.`),o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},`nn `),o(`span`,{style:{"--shiki-dark":`#4D9375`,"--shiki-light":`#1E754F`}},`as`),o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},` nn`)]),a(`
2
+ `),o(`span`,{class:`line`}),a(`
3
+ `),o(`span`,{class:`line`},[o(`span`,{style:{"--shiki-dark":`#CB7676`,"--shiki-light":`#AB5959`}},`class`),o(`span`,{style:{"--shiki-dark":`#5DA994`,"--shiki-light":`#2E8F82`}},` MnistFCNN`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`(`),o(`span`,{style:{"--shiki-dark":`#80A665`,"--shiki-light":`#59873A`}},`nn`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`.`),o(`span`,{style:{"--shiki-dark":`#80A665`,"--shiki-light":`#59873A`}},`Module`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`):`)]),a(`
4
+ `),o(`span`,{class:`line`},[o(`span`,{style:{"--shiki-dark":`#CB7676`,"--shiki-light":`#AB5959`}},` def`),o(`span`,{style:{"--shiki-dark":`#B8A965`,"--shiki-light":`#998418`}},` __init__`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`(`),o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},`self`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`,`),o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},` hidden1`),o(`span`,{style:{"--shiki-dark":`#CB7676`,"--shiki-light":`#AB5959`}},`=`),o(`span`,{style:{"--shiki-dark":`#4C9A91`,"--shiki-light":`#2F798A`}},`128`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`,`),o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},` hidden2`),o(`span`,{style:{"--shiki-dark":`#CB7676`,"--shiki-light":`#AB5959`}},`=`),o(`span`,{style:{"--shiki-dark":`#4C9A91`,"--shiki-light":`#2F798A`}},`64`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`):`)]),a(`
5
+ `),o(`span`,{class:`line`},[o(`span`,{style:{"--shiki-dark":`#B8A965`,"--shiki-light":`#998418`}},` super`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`().`),o(`span`,{style:{"--shiki-dark":`#B8A965`,"--shiki-light":`#998418`}},`__init__`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`()`),o(`span`,{style:{"--shiki-dark":`#758575DD`,"--shiki-light":`#A0ADA0`}},` # never forget this line`)]),a(`
6
+ `),o(`span`,{class:`line`},[o(`span`,{style:{"--shiki-dark":`#C99076`,"--shiki-light":`#A65E2B`}},` self`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`.`),o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},`flatten `),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`=`),o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},` nn`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`.`),o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},`Flatten`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`()`)]),a(`
7
+ `),o(`span`,{class:`line`},[o(`span`,{style:{"--shiki-dark":`#C99076`,"--shiki-light":`#A65E2B`}},` self`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`.`),o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},`net `),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`=`),o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},` nn`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`.`),o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},`Sequential`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`(`)]),a(`
8
+ `),o(`span`,{class:`line`},[o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},` nn`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`.`),o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},`Linear`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`(`),o(`span`,{style:{"--shiki-dark":`#4C9A91`,"--shiki-light":`#2F798A`}},`28`),o(`span`,{style:{"--shiki-dark":`#CB7676`,"--shiki-light":`#AB5959`}},` *`),o(`span`,{style:{"--shiki-dark":`#4C9A91`,"--shiki-light":`#2F798A`}},` 28`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`,`),o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},` hidden1`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`),`)]),a(`
9
+ `),o(`span`,{class:`line`},[o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},` nn`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`.`),o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},`ReLU`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`(),`)]),a(`
10
+ `),o(`span`,{class:`line`},[o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},` nn`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`.`),o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},`Linear`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`(`),o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},`hidden1`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`,`),o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},` hidden2`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`),`)]),a(`
11
+ `),o(`span`,{class:`line`},[o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},` nn`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`.`),o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},`ReLU`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`(),`)]),a(`
12
+ `),o(`span`,{class:`line`},[o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},` nn`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`.`),o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},`Linear`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`(`),o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},`hidden2`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`,`),o(`span`,{style:{"--shiki-dark":`#4C9A91`,"--shiki-light":`#2F798A`}},` 10`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`),`),o(`span`,{style:{"--shiki-dark":`#758575DD`,"--shiki-light":`#A0ADA0`}},` # 10 logits, no activation`)]),a(`
13
+ `),o(`span`,{class:`line`},[o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},` )`)]),a(`
14
+ `),o(`span`,{class:`line`}),a(`
15
+ `),o(`span`,{class:`line`},[o(`span`,{style:{"--shiki-dark":`#CB7676`,"--shiki-light":`#AB5959`}},` def`),o(`span`,{style:{"--shiki-dark":`#80A665`,"--shiki-light":`#59873A`}},` forward`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`(`),o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},`self`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`,`),o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},` x`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`):`),o(`span`,{style:{"--shiki-dark":`#758575DD`,"--shiki-light":`#A0ADA0`}},` # x: (batch, 1, 28, 28)`)]),a(`
16
+ `),o(`span`,{class:`line`},[o(`span`,{style:{"--shiki-dark":`#4D9375`,"--shiki-light":`#1E754F`}},` return`),o(`span`,{style:{"--shiki-dark":`#C99076`,"--shiki-light":`#A65E2B`}},` self`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`.`),o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},`net`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`(`),o(`span`,{style:{"--shiki-dark":`#C99076`,"--shiki-light":`#A65E2B`}},`self`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`.`),o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},`flatten`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`(`),o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},`x`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`))`),o(`span`,{style:{"--shiki-dark":`#758575DD`,"--shiki-light":`#A0ADA0`}},` # -> (batch, 10)`)])])],-1)]]),_:1},16),l((e(),s(`div`,_,[...v[1]||=[o(`p`,null,[o(`code`,null,`__init__`),a(),o(`strong`,null,`registers`),a(` the pieces that own parameters; `),o(`code`,null,`forward`),a(` says what to do with an input. There is no third part.`)],-1)]])),[[b]])]),_:1},16)}}};export{v as default};
lecture-03/assets/md-AOTeS7la.js ADDED
@@ -0,0 +1 @@
 
 
1
+ import{B as e,C as t,D as n,G as r,S as i,_ as a,b as o,et as s,tt as c,v as l,xt as u,yt as d}from"./modules/shiki-CJZsCeMT.js";import{n as f,t as p}from"./slidev/context-DB-9afGB.js";import{t as m}from"./default-IV3yhGVf.js";import{t as h}from"./slidev/VClicks-DYiBHOPb.js";var g={class:`mt-3 dl-callout`},_={__name:`slides.md__slidev_3`,setup(_){let{$slidev:v,$nav:y,$clicksContext:b,$clicks:x,$page:S,$renderContext:C,$frontmatter:w}=f();return b.setup(),(f,_)=>{let v=h,y=r(`click`);return e(),l(m,u(n(d(p)(d(w),2))),{default:s(()=>[_[2]||=a(`h1`,null,`What last week cost us`,-1),_[3]||=a(`p`,null,`Last week’s MLP (multilayer perceptron) worked. Writing it hurt in three ways.`,-1),t(v,null,{default:s(()=>[..._[0]||=[a(`ul`,null,[a(`li`,null,[a(`strong`,null,`The gradient was ours to derive.`),i(` One slide of algebra, valid for one loss and one activation. Change either and you redo it.`)]),a(`li`,null,[a(`strong`,null,`It ran on the CPU.`),i(` A matrix multiply is the same operation on a GPU, a hundred times faster — and NumPy cannot reach one.`)]),a(`li`,null,[a(`strong`,null,`Everything was written twice.`),i(` Initialisation, shuffling, one-hot encoding: identical in every project on earth.`)])],-1)]]),_:1}),c((e(),o(`div`,g,[..._[1]||=[a(`p`,null,[i(`None of these is a problem with the `),a(`em`,null,`idea`),i(` of a network. All three are problems with writing one down.`)],-1)]])),[[y]])]),_:1},16)}}};export{_ as default};
lecture-03/assets/md-BCE3_zZH2.js ADDED
@@ -0,0 +1 @@
 
 
1
+ import{B as e,D as t,_ as n,et as r,v as i,xt as a,yt as o}from"./modules/shiki-CJZsCeMT.js";import{n as s,t as c}from"./slidev/context-DB-9afGB.js";import{t as l}from"./section-CqA-0pFf.js";var u={__name:`slides.md__slidev_27`,setup(u){let{$slidev:d,$nav:f,$clicksContext:p,$clicks:m,$page:h,$renderContext:g,$frontmatter:_}=s();return p.setup(),(s,u)=>(e(),i(l,a(t(o(c)(o(_),26))),{default:r(()=>[...u[0]||=[n(`h1`,null,`Every PyTorch program is five pieces`,-1)]]),_:1},16))}};export{u as default};
lecture-03/assets/md-BJK-Icy_.js ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ import{B as e,C as t,D as n,G as r,S as i,_ as a,b as o,et as s,tt as c,v as l,xt as u,yt as d}from"./modules/shiki-CJZsCeMT.js";import{n as f,t as p}from"./slidev/context-DB-9afGB.js";import{t as m}from"./slidev/CodeBlockWrapper-DqFdVwPK.js";import{t as h}from"./default-IV3yhGVf.js";import{t as g}from"./slidev/VClicks-DYiBHOPb.js";var _={class:`grid grid-cols-2 gap-8 mt-2`},v={class:`dl-callout`},y={class:`mt-4`},b={__name:`slides.md__slidev_14`,setup(b){let{$slidev:x,$nav:S,$clicksContext:C,$clicks:w,$page:T,$renderContext:E,$frontmatter:D}=f();return C.setup(),(f,b)=>{let x=g,S=m,C=r(`click`);return e(),l(h,u(n(d(p)(d(D),13))),{default:s(()=>[b[3]||=a(`h1`,null,[a(`code`,null,`view`),i(` vs `),a(`code`,null,`reshape`),i(` vs `),a(`code`,null,`flatten`)],-1),a(`div`,_,[a(`div`,null,[t(x,null,{default:s(()=>[...b[0]||=[a(`ul`,null,[a(`li`,null,[a(`strong`,null,[a(`code`,null,`reshape(...)`)]),i(` — always works. Returns a view if it can, a copy if it must`)]),a(`li`,null,[a(`strong`,null,[a(`code`,null,`view(...)`)]),i(` — never a copy. Fails when memory is no longer in order, e.g. after a `),a(`code`,null,`transpose`)]),a(`li`,null,[a(`strong`,null,[a(`code`,null,`flatten(start_dim=1)`)]),i(` — reshape’s common case, named: keep the batch axis, collapse everything after it`)])],-1)]]),_:1})]),a(`div`,null,[c((e(),o(`div`,v,[...b[1]||=[a(`p`,null,[a(`strong`,null,[i(`Use `),a(`code`,null,`reshape`)]),i(`, and `),a(`code`,null,`flatten(1)`),i(` when the batch axis must survive.`)],-1)]])),[[C]]),c((e(),o(`div`,y,[t(S,{title:``,ranges:[]},{default:s(()=>[...b[2]||=[a(`pre`,{class:`shiki shiki-themes vitesse-dark vitesse-light slidev-code`,style:{"--shiki-dark":`#dbd7caee`,"--shiki-light":`#393a34`,"--shiki-dark-bg":`#121212`,"--shiki-light-bg":`#ffffff`}},[a(`code`,{class:`language-python`},[a(`span`,{class:`line`},[a(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},`x `),a(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`=`),a(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},` torch`),a(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`.`),a(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},`randn`),a(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`(`),a(`span`,{style:{"--shiki-dark":`#4C9A91`,"--shiki-light":`#2F798A`}},`64`),a(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`,`),a(`span`,{style:{"--shiki-dark":`#4C9A91`,"--shiki-light":`#2F798A`}},` 1`),a(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`,`),a(`span`,{style:{"--shiki-dark":`#4C9A91`,"--shiki-light":`#2F798A`}},` 28`),a(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`,`),a(`span`,{style:{"--shiki-dark":`#4C9A91`,"--shiki-light":`#2F798A`}},` 28`),a(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`)`)]),i(`
2
+ `),a(`span`,{class:`line`}),i(`
3
+ `),a(`span`,{class:`line`},[a(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},`x`),a(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`.`),a(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},`flatten`),a(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`(`),a(`span`,{style:{"--shiki-dark":`#4C9A91`,"--shiki-light":`#2F798A`}},`1`),a(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`).`),a(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},`shape `),a(`span`,{style:{"--shiki-dark":`#758575DD`,"--shiki-light":`#A0ADA0`}},`# (64, 784)`)]),i(`
4
+ `),a(`span`,{class:`line`},[a(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},`x`),a(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`.`),a(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},`view`),a(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`(`),a(`span`,{style:{"--shiki-dark":`#4C9A91`,"--shiki-light":`#2F798A`}},`64`),a(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`,`),a(`span`,{style:{"--shiki-dark":`#CB7676`,"--shiki-light":`#AB5959`}},` -`),a(`span`,{style:{"--shiki-dark":`#4C9A91`,"--shiki-light":`#2F798A`}},`1`),a(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`).`),a(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},`shape `),a(`span`,{style:{"--shiki-dark":`#758575DD`,"--shiki-light":`#A0ADA0`}},`# (64, 784)`)]),i(`
5
+ `),a(`span`,{class:`line`},[a(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},`x`),a(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`.`),a(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},`reshape`),a(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`(`),a(`span`,{style:{"--shiki-dark":`#CB7676`,"--shiki-light":`#AB5959`}},`-`),a(`span`,{style:{"--shiki-dark":`#4C9A91`,"--shiki-light":`#2F798A`}},`1`),a(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`).`),a(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},`shape `),a(`span`,{style:{"--shiki-dark":`#758575DD`,"--shiki-light":`#A0ADA0`}},`# (50176,) — oops`)])])],-1)]]),_:1})])),[[C]])])])]),_:1},16)}}};export{b as default};
lecture-03/assets/md-BJWJAX7h.js ADDED
@@ -0,0 +1 @@
 
 
1
+ import{B as e,Ct as t,D as n,T as r,U as i,_ as a,b as o,et as s,v as c,xt as l,y as u,yt as d}from"./modules/shiki-CJZsCeMT.js";import{t as f}from"./_plugin-vue_export-helper-BDNMzG2s.js";import{n as p,t as m}from"./slidev/context-DB-9afGB.js";var h={class:`slidev-layout dl-end`},g={class:`dl-end__body`},_={class:`dl-end__meta`},v={key:0,class:`dl-end__next`},y=[`href`],b=f(r({__name:`end`,props:{email:{},next:{}},setup(n){let{$slidev:r,$nav:s,$clicksContext:c,$clicks:l,$page:d,$renderContext:f,$frontmatter:m}=p(),b=n;return(n,r)=>(e(),o(`div`,h,[a(`div`,g,[i(n.$slots,`default`,{},void 0,!0)]),r[0]||=a(`div`,{class:`dl-rule`},null,-1),a(`div`,_,[b.next?(e(),o(`span`,v,`Next: `+t(b.next),1)):u(`v-if`,!0),b.email?(e(),o(`a`,{key:1,href:`mailto:${b.email}`},t(b.email),9,y)):u(`v-if`,!0)])]))}}),[[`__scopeId`,`data-v-f8d31aa3`]]),x={__name:`slides.md__slidev_46`,setup(t){let{$slidev:r,$nav:i,$clicksContext:o,$clicks:u,$page:f,$renderContext:h,$frontmatter:g}=p();return o.setup(),(t,r)=>(e(),c(b,l(n(d(m)(d(g),45))),{default:s(()=>[...r[0]||=[a(`h1`,null,`To be continued…`,-1)]]),_:1},16))}};export{x as default};
lecture-03/assets/md-BJc_Ngxk.js ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import{B as e,C as t,D as n,G as r,N as i,S as a,_ as o,b as s,et as c,tt as l,v as u,xt as d,yt as f}from"./modules/shiki-CJZsCeMT.js";import{n as p,t as m}from"./slidev/context-DB-9afGB.js";import{t as h}from"./slidev/CodeBlockWrapper-DqFdVwPK.js";import{t as g}from"./default-IV3yhGVf.js";var _={class:`mt-3 dl-secondary`},v={__name:`slides.md__slidev_10`,setup(v){let{$slidev:y,$nav:b,$clicksContext:x,$clicks:S,$page:C,$renderContext:w,$frontmatter:T}=p();return x.setup(),(p,v)=>{let y=h,b=r(`click`);return e(),u(g,d(n(f(m)(f(T),9))),{default:c(()=>[v[2]||=o(`h1`,null,`Making one`,-1),t(y,i({lines:!0},{title:``,ranges:[`all`,`1`,`3-4`,`6-7`,`9-10`,`12-13`,`all`]}),{default:c(()=>[...v[0]||=[o(`pre`,{class:`shiki shiki-themes vitesse-dark vitesse-light slidev-code`,style:{"--shiki-dark":`#dbd7caee`,"--shiki-light":`#393a34`,"--shiki-dark-bg":`#121212`,"--shiki-light-bg":`#ffffff`}},[o(`code`,{class:`language-python`},[o(`span`,{class:`line`},[o(`span`,{style:{"--shiki-dark":`#4D9375`,"--shiki-light":`#1E754F`}},`import`),o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},` torch`)]),a(`
2
+ `),o(`span`,{class:`line`}),a(`
3
+ `),o(`span`,{class:`line`},[o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},`x `),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`=`),o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},` torch`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`.`),o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},`tensor`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`([[`),o(`span`,{style:{"--shiki-dark":`#4C9A91`,"--shiki-light":`#2F798A`}},`1`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`.,`),o(`span`,{style:{"--shiki-dark":`#4C9A91`,"--shiki-light":`#2F798A`}},` 2`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`.,`),o(`span`,{style:{"--shiki-dark":`#4C9A91`,"--shiki-light":`#2F798A`}},` 3`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`.],`),o(`span`,{style:{"--shiki-dark":`#758575DD`,"--shiki-light":`#A0ADA0`}},` # from a Python list`)]),a(`
4
+ `),o(`span`,{class:`line`},[o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},` [`),o(`span`,{style:{"--shiki-dark":`#4C9A91`,"--shiki-light":`#2F798A`}},`4`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`.,`),o(`span`,{style:{"--shiki-dark":`#4C9A91`,"--shiki-light":`#2F798A`}},` 5`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`.,`),o(`span`,{style:{"--shiki-dark":`#4C9A91`,"--shiki-light":`#2F798A`}},` 6`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`.]])`),o(`span`,{style:{"--shiki-dark":`#758575DD`,"--shiki-light":`#A0ADA0`}},` # shape (2, 3)`)]),a(`
5
+ `),o(`span`,{class:`line`}),a(`
6
+ `),o(`span`,{class:`line`},[o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},`zeros `),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`=`),o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},` torch`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`.`),o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},`zeros`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`(`),o(`span`,{style:{"--shiki-dark":`#4C9A91`,"--shiki-light":`#2F798A`}},`64`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`,`),o(`span`,{style:{"--shiki-dark":`#4C9A91`,"--shiki-light":`#2F798A`}},` 10`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`)`),o(`span`,{style:{"--shiki-dark":`#758575DD`,"--shiki-light":`#A0ADA0`}},` # a shape, filled with 0.0`)]),a(`
7
+ `),o(`span`,{class:`line`},[o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},`ones `),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`=`),o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},` torch`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`.`),o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},`ones`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`(`),o(`span`,{style:{"--shiki-dark":`#4C9A91`,"--shiki-light":`#2F798A`}},`3`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`)`),o(`span`,{style:{"--shiki-dark":`#758575DD`,"--shiki-light":`#A0ADA0`}},` # (3,) of 1.0`)]),a(`
8
+ `),o(`span`,{class:`line`}),a(`
9
+ `),o(`span`,{class:`line`},[o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},`steps `),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`=`),o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},` torch`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`.`),o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},`arange`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`(`),o(`span`,{style:{"--shiki-dark":`#4C9A91`,"--shiki-light":`#2F798A`}},`0`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`,`),o(`span`,{style:{"--shiki-dark":`#4C9A91`,"--shiki-light":`#2F798A`}},` 10`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`,`),o(`span`,{style:{"--shiki-dark":`#4C9A91`,"--shiki-light":`#2F798A`}},` 2`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`)`),o(`span`,{style:{"--shiki-dark":`#758575DD`,"--shiki-light":`#A0ADA0`}},` # 0 2 4 6 8 — like range()`)]),a(`
10
+ `),o(`span`,{class:`line`},[o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},`grid `),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`=`),o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},` torch`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`.`),o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},`linspace`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`(`),o(`span`,{style:{"--shiki-dark":`#CB7676`,"--shiki-light":`#AB5959`}},`-`),o(`span`,{style:{"--shiki-dark":`#4C9A91`,"--shiki-light":`#2F798A`}},`1`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`,`),o(`span`,{style:{"--shiki-dark":`#4C9A91`,"--shiki-light":`#2F798A`}},` 1`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`,`),o(`span`,{style:{"--shiki-dark":`#4C9A91`,"--shiki-light":`#2F798A`}},` 5`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`)`),o(`span`,{style:{"--shiki-dark":`#758575DD`,"--shiki-light":`#A0ADA0`}},` # 5 points, endpoints included`)]),a(`
11
+ `),o(`span`,{class:`line`}),a(`
12
+ `),o(`span`,{class:`line`},[o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},`noise `),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`=`),o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},` torch`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`.`),o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},`randn`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`(`),o(`span`,{style:{"--shiki-dark":`#4C9A91`,"--shiki-light":`#2F798A`}},`2`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`,`),o(`span`,{style:{"--shiki-dark":`#4C9A91`,"--shiki-light":`#2F798A`}},` 3`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`)`),o(`span`,{style:{"--shiki-dark":`#758575DD`,"--shiki-light":`#A0ADA0`}},` # standard normal`)]),a(`
13
+ `),o(`span`,{class:`line`},[o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},`same `),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`=`),o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},` torch`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`.`),o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},`from_numpy`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`(`),o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},`np_array`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`)`),o(`span`,{style:{"--shiki-dark":`#758575DD`,"--shiki-light":`#A0ADA0`}},` # shares memory with NumPy`)])])],-1)]]),_:1},16),l((e(),s(`div`,_,[...v[1]||=[o(`p`,null,[o(`code`,null,`torch.tensor`),a(` copies data you already have. Everything else takes a `),o(`strong`,null,`shape`),a(` and invents the contents. That is the whole API.`)],-1)]])),[[b]])]),_:1},16)}}};export{v as default};
lecture-03/assets/md-BPSetbzY.js ADDED
@@ -0,0 +1 @@
 
 
1
+ import{B as e,C as t,Ct as n,D as r,H as i,S as a,St as o,T as s,_ as c,b as l,bt as u,dt as d,et as f,g as p,m,v as h,xt as g,y as _,yt as v}from"./modules/shiki-CJZsCeMT.js";import{t as y}from"./_plugin-vue_export-helper-BDNMzG2s.js";import{n as b,t as x}from"./slidev/context-DB-9afGB.js";import{t as S}from"./interactive-CBN7ZXLe.js";var C={class:`dl-syllabus`},w=[`title`,`onClick`],T={class:`dl-syllabus__num`},E={class:`dl-syllabus__detail`},D={class:`dl-syllabus__heading`},O={class:`dl-syllabus__weeklabel`},k=y(s({__name:`SyllabusTimeline`,props:{entries:{default:()=>[{section:`Introduction to DL`,description:`Course content, evaluation and exams. What is deep learning, where it is applied, the frameworks, and getting a environment running in Colab or Jupyter.`,weeks:[1]},{section:`Basics of Neural Networks`,description:`Artificial neurons and neural networks; implementing and training a multilayer network from scratch.`,weeks:[2]},{section:`PyTorch for DL`,description:`What PyTorch is and why. Tensors for data representation, the PyTorch training pipeline, and an ANN built with it.`,weeks:[3]},{section:`Deep Convolutional Neural Networks`,description:`What a CNN is and where it applies. Telling classification, detection and segmentation apart. Implementing CNN models in PyTorch.`,weeks:[4,5]},{section:`Recurrent Networks, Transformers and LLMs`,description:`What an RNN is and where it applies; the mechanism, and an implementation in PyTorch. What a transformer is, and the original architecture. Then large language models: how one is trained, how one is adapted, and how to build on top of one.`,weeks:[6,7,8]},{section:`Generative Adversarial Networks`,description:`Generative models and autoencoders. Implementing a GAN in Colab, improving synthetic data quality, and the main GAN variants and applications.`,weeks:[9,10]},{section:`Deep Reinforcement Learning`,description:`What reinforcement learning is and why. RL algorithm basics, implementations, and deep Q-learning in PyTorch.`,weeks:[11,12]}]},totalWeeks:{default:12},currentWeek:{default:null}},setup(t){let{$slidev:r,$nav:a,$clicksContext:s,$clicks:f,$page:h,$renderContext:g,$frontmatter:v}=b(),y=t,x=d(Math.max(0,y.entries.findIndex(e=>e.weeks.includes(y.currentWeek??0)))),S=p(()=>y.entries[x.value]);function k(e){return e.weeks.length===1?`Week ${e.weeks[0]}`:`Weeks ${e.weeks[0]}–${e.weeks[e.weeks.length-1]}`}return(t,r)=>(e(),l(`div`,C,[c(`div`,{class:`dl-syllabus__track`,style:o({gridTemplateColumns:`repeat(${y.totalWeeks}, 1fr)`})},[(e(!0),l(m,null,i(y.entries,(t,r)=>(e(),l(`button`,{key:t.section,type:`button`,class:u([`dl-syllabus__block`,{"is-selected":r===x.value}]),style:o({gridColumn:`${t.weeks[0]} / span ${t.weeks.length}`}),title:t.section,onClick:e=>x.value=r},[c(`span`,T,n(r+1),1)],14,w))),128)),y.currentWeek?(e(),l(`div`,{key:0,class:`dl-syllabus__now`,style:o({gridColumn:`${y.currentWeek} / span 1`})},null,4)):_(`v-if`,!0)],4),c(`div`,{class:`dl-syllabus__weeks`,style:o({gridTemplateColumns:`repeat(${y.totalWeeks}, 1fr)`})},[(e(!0),l(m,null,i(y.totalWeeks,t=>(e(),l(`span`,{key:t},n(t),1))),128))],4),c(`div`,E,[c(`div`,D,[c(`span`,O,n(k(S.value)),1),c(`h3`,null,n(S.value.section),1)]),c(`p`,null,n(S.value.description),1)])]))}}),[[`__scopeId`,`data-v-45e850fb`]]),A={__name:`slides.md__slidev_2`,setup(n){let{$slidev:i,$nav:o,$clicksContext:s,$clicks:l,$page:u,$renderContext:d,$frontmatter:p}=b();return s.setup(),(n,i)=>{let o=k;return e(),h(S,g(r(v(x)(v(p),1))),{aside:f(e=>[...i[0]||=[c(`p`,null,`One week, one library.`,-1),c(`p`,null,[a(`Nothing new is learned about `),c(`em`,null,`neural networks`),a(` today. Everything learned today is about writing down the network we already understand — and then letting the machine do the calculus.`)],-1)]]),default:f(()=>[t(o,{"current-week":3})]),_:1},16)}}};export{A as default};
lecture-03/assets/md-BV7tqBmU.css ADDED
@@ -0,0 +1 @@
 
 
1
+ .dl-syllabus[data-v-45e850fb]{width:100%}.dl-syllabus__track[data-v-45e850fb]{align-items:stretch;gap:4px;display:grid;position:relative}.dl-syllabus__block[data-v-45e850fb]{border:1px solid var(--dl-border);background:var(--dl-surface);cursor:pointer;border-radius:5px;height:2.6rem;padding:0;transition:background .15s,border-color .15s,transform .15s;position:relative}.dl-syllabus__block[data-v-45e850fb]:hover{border-color:var(--dl-accent);transform:translateY(-2px)}.dl-syllabus__block.is-selected[data-v-45e850fb]{background:var(--dl-accent);border-color:var(--dl-accent-strong)}.dl-syllabus__num[data-v-45e850fb]{color:var(--dl-muted);font-size:.8rem;font-weight:700}.dl-syllabus__block.is-selected .dl-syllabus__num[data-v-45e850fb]{color:#fff}.dl-syllabus__now[data-v-45e850fb]{border:2px solid var(--dl-danger);pointer-events:none;border-radius:5px;grid-row:1}.dl-syllabus__weeks[data-v-45e850fb]{color:var(--dl-muted);text-align:center;font-variant-numeric:tabular-nums;gap:4px;margin-top:.3rem;font-size:.7rem;display:grid}.dl-syllabus__detail[data-v-45e850fb]{min-height:6.5rem;margin-top:1.2rem}.dl-syllabus__heading[data-v-45e850fb]{align-items:baseline;gap:.8rem;display:flex}.dl-syllabus__weeklabel[data-v-45e850fb]{letter-spacing:.08em;text-transform:uppercase;color:var(--dl-accent);flex-shrink:0;font-size:.78rem;font-weight:700}.dl-syllabus__detail h3[data-v-45e850fb]{margin:0;font-size:1.45rem}.dl-syllabus__detail p[data-v-45e850fb]{max-width:68ch;margin:.45rem 0 0;font-size:1.05rem;line-height:1.5}
lecture-03/assets/md-BZuzz048.js ADDED
@@ -0,0 +1 @@
 
 
1
+ import{B as e,C as t,D as n,G as r,S as i,_ as a,b as o,et as s,tt as c,v as l,xt as u,yt as d}from"./modules/shiki-CJZsCeMT.js";import{n as f,t as p}from"./slidev/context-DB-9afGB.js";import{t as m}from"./interactive-CBN7ZXLe.js";import{t as h}from"./AutogradGraph-D9pug6h-.js";var g={class:`mt-3 dl-callout`},_={__name:`slides.md__slidev_22`,setup(_){let{$slidev:v,$nav:y,$clicksContext:b,$clicks:x,$page:S,$renderContext:C,$frontmatter:w}=f();return b.setup(),(f,_)=>{let v=h,y=r(`click`);return e(),l(m,u(n(d(p)(d(w),21))),{aside:s(t=>[_[1]||=a(`p`,null,`One neuron and a squared error — Lecture 02’s Adaline plus a sigmoid.`,-1),_[2]||=a(`div`,{class:`mt-2 dl-secondary`},[a(`p`,null,[a(`strong`,null,`Step`),i(` three times for the forward pass, which computes the numbers `),a(`em`,null,`and`),i(` records where each came from. Three more for the backward pass, which walks the same graph in reverse.`)])],-1),c((e(),o(`div`,g,[..._[0]||=[a(`p`,null,[i(`Nobody derived `),a(`span`,{class:`katex`},[a(`span`,{class:`katex-mathml`},[a(`math`,{xmlns:`http://www.w3.org/1998/Math/MathML`},[a(`semantics`,null,[a(`mrow`,null,[a(`mi`,{mathvariant:`normal`},`∂`),a(`mi`,null,`L`),a(`mi`,{mathvariant:`normal`},`/`),a(`mi`,{mathvariant:`normal`},`∂`),a(`mi`,null,`w`)]),a(`annotation`,{encoding:`application/x-tex`},`\\partial L/\\partial w`)])])]),a(`span`,{class:`katex-html`,"aria-hidden":`true`},[a(`span`,{class:`katex-base`},[a(`span`,{class:`katex-strut`,style:{height:`1em`,"vertical-align":`-0.25em`}}),a(`span`,{class:`mord`,style:{"margin-right":`0.0556em`}},`∂`),a(`span`,{class:`mord mathnormal`},`L`),a(`span`,{class:`mord`},`/`),a(`span`,{class:`mord`,style:{"margin-right":`0.0556em`}},`∂`),a(`span`,{class:`mord mathnormal`,style:{"margin-right":`0.0269em`}},`w`)])])]),i(`. It was multiplied along a path.`)],-1)]])),[[y]])]),default:s(()=>[t(v)]),_:1},16)}}};export{_ as default};
lecture-03/assets/md-Be9Z9nVr.js ADDED
@@ -0,0 +1 @@
 
 
1
+ import{B as e,C as t,D as n,G as r,S as i,_ as a,b as o,et as s,tt as c,v as l,xt as u,yt as d}from"./modules/shiki-CJZsCeMT.js";import{n as f,t as p}from"./slidev/context-DB-9afGB.js";import{t as m}from"./interactive-CBN7ZXLe.js";import{t as h}from"./ConfusionMatrix-CloAXvtZ.js";var g={class:`mt-3 dl-callout`},_={__name:`slides.md__slidev_40`,setup(_){let{$slidev:v,$nav:y,$clicksContext:b,$clicks:x,$page:S,$renderContext:C,$frontmatter:w}=f();return b.setup(),(f,_)=>{let v=h,y=r(`click`);return e(),l(m,u(n(d(p)(d(w),39))),{aside:s(t=>[_[1]||=a(`p`,null,[a(`strong`,null,`98.2%.`),i(` The useful question: `),a(`em`,null,`which`),i(` 180 did it get wrong?`)],-1),_[2]||=a(`div`,{class:`mt-2 dl-secondary`},[a(`p`,null,`A row is one true digit, a column is what the model said. The diagonal has its own colour scale — 981 beside 16 would flatten everything else to nothing.`)],-1),c((e(),o(`div`,g,[..._[0]||=[a(`p`,null,[i(`Press `),a(`strong`,null,`the 4/9 pair`),i(`: 31 of the 180 errors are those two digits.`)],-1)]])),[[y]])]),default:s(()=>[t(v)]),_:1},16)}}};export{_ as default};
lecture-03/assets/md-BfELaV__.js ADDED
@@ -0,0 +1 @@
 
 
1
+ import{B as e,C as t,Ct as n,D as r,G as i,H as a,S as o,St as s,T as c,_ as l,b as u,bt as d,d as f,dt as p,et as m,f as h,g,m as _,tt as ee,v,xt as y,y as b,yt as x}from"./modules/shiki-CJZsCeMT.js";import{t as te}from"./_plugin-vue_export-helper-BDNMzG2s.js";import{n as S,t as C}from"./slidev/context-DB-9afGB.js";import{t as w}from"./WidgetFrame-DHgK6j2H.js";import{n as T,r as E}from"./useTensorLayout-BsTHvbKs.js";import{t as D}from"./interactive-CBN7ZXLe.js";var ne=[`viewBox`,`aria-label`],re=[`x`,`y`],ie={class:`dl-reshape__cells is-strip`},ae=[`aria-label`,`onClick`,`onKeydown`],oe=[`x`,`y`],se=[`x`,`y`],ce={class:`dl-reshape__link`},le=[`x1`,`y1`,`x2`,`y2`],ue=[`d`],de=[`x`,`y`],fe=[`x`,`y`,`width`,`height`],O={class:`dl-reshape__cells`},k=[`aria-label`,`onClick`,`onKeydown`],A=[`x`,`y`,`width`,`height`],j=[`x`,`y`],M=[`x`,`y`],N=[`onClick`],P={class:`dl-reshape__facts`},F={key:0},I={key:1},L={class:`dl-reshape__note`},R=24,z=18,B=26,pe=16,V=te(c({__name:`ReshapeLab`,setup(t){let{$slidev:r,$nav:i,$clicksContext:c,$clicks:ee,$page:y,$renderContext:te,$frontmatter:C}=S(),D=[{call:`t.reshape(24)`,dims:[24],note:"Flat. This is what `flatten()` gives you, and it is the first thing our MNIST network does to an image: 28 x 28 pixels become a vector of 784."},{call:`t.reshape(4, 6)`,dims:[4,6],note:`Four rows of six. The strip is cut every six elements — element 6 starts row 1 because the last axis is the one that moves fastest.`},{call:`t.reshape(6, 4)`,dims:[6,4],note:`Six rows of four. Same 24 numbers, same order in memory, a different reading of them. Nothing was transposed: compare where element 4 sits here and in (4, 6).`},{call:`t.reshape(2, 3, 4)`,dims:[2,3,4],note:`Rank 3 from the same strip: two groups of three rows of four. 2 x 3 x 4 = 24, which is the only condition reshape ever asks of you.`},{call:`t.reshape(-1, 6)`,dims:[4,6],note:`-1 means "work it out". 24 elements in six columns can only be four rows. Use it for the batch dimension, whose size you often do not want to hardcode.`},{call:`t.reshape(5, 5)`,dims:[],note:`RuntimeError: shape [5, 5] is invalid for input of size 24. Reshape never invents or discards elements, so the product of the new shape must be exactly 24.`}],V=p(1),H=g(()=>D[V.value]),U=g(()=>H.value.dims.length===0),W=p(null),G=g(()=>E(H.value.dims,{cell:B,gap:3,framePad:5})),K=g(()=>({w:Math.max(478,G.value.width)+20,h:74+Math.max(G.value.height,B)+10})),q=g(()=>(K.value.w-478)/2),J=g(()=>(K.value.w-G.value.width)/2),Y=g(()=>74);function X(e){return .16+e/23*.62}let me=g(()=>Array.from({length:R},(e,t)=>({flat:t,x:q.value+t*20,y:pe}))),Z=g(()=>G.value.cells.map(e=>({...e,x:e.x+J.value,y:e.y+Y.value}))),he=g(()=>G.value.frames.map(e=>({...e,x:e.x+J.value,y:e.y+Y.value})));function Q(e){W.value=W.value===e?null:e}let $=g(()=>W.value===null?null:Z.value.find(e=>e.flat===W.value)??null);return(t,r)=>{let i=w;return e(),v(i,{"max-width":`44rem`},{controls:m(()=>[(e(),u(_,null,a(D,(e,t)=>l(`button`,{key:e.call,type:`button`,class:d([`dl-reshape__tab`,{"is-active":t===V.value,"is-bad":e.dims.length===0}]),onClick:e=>V.value=t},n(e.call.replace(`t.reshape`,``)),11,N)),64))]),readout:m(()=>[l(`div`,P,[l(`span`,null,[l(`code`,null,n(H.value.call),1)]),U.value?b(`v-if`,!0):(e(),u(`span`,F,[r[0]||=o(`shape `,-1),l(`strong`,null,n(x(T)(H.value.dims)),1)])),U.value?b(`v-if`,!0):(e(),u(`span`,I,[r[1]||=o(`numel `,-1),l(`strong`,null,n(H.value.dims.reduce((e,t)=>e*t,1)),1)]))]),l(`div`,L,[$.value?(e(),u(_,{key:0},[r[2]||=o(` Element `,-1),l(`strong`,null,n($.value.flat),1),r[3]||=o(` never moved. Under this shape you reach it with `,-1),l(`code`,null,`t[`+n($.value.index.join(`, `))+`]`,1),r[4]||=o(`. `,-1)],64)):(e(),u(_,{key:1},[o(n(H.value.note),1)],64))])]),default:m(()=>[(e(),u(`svg`,{class:`dl-reshape`,viewBox:`0 0 ${K.value.w} ${K.value.h}`,preserveAspectRatio:`xMidYMid meet`,role:`img`,"aria-label":`24 elements in memory, read as shape ${x(T)(H.value.dims)}`},[l(`text`,{class:`dl-reshape__caption`,x:q.value,y:11},`memory — 24 numbers, contiguous, unchanged by every button below`,8,re),l(`g`,ie,[(e(!0),u(_,null,a(me.value,t=>(e(),u(`g`,{key:`s${t.flat}`,class:d({"is-selected":t.flat===W.value}),tabindex:`0`,role:`button`,"aria-label":`element ${t.flat}`,onClick:e=>Q(t.flat),onKeydown:[f(h(e=>Q(t.flat),[`prevent`]),[`enter`]),f(h(e=>Q(t.flat),[`prevent`]),[`space`])]},[l(`rect`,{x:t.x,y:t.y,width:z,height:z,rx:`2`,style:s({fill:`color-mix(in srgb, var(--dl-accent) ${Math.round(X(t.flat)*100)}%, var(--dl-surface))`})},null,12,oe),l(`text`,{x:t.x+z/2,y:t.y+z/2+3.5,"text-anchor":`middle`},n(t.flat),9,se)],42,ae))),128))]),U.value?(e(),u(`text`,{key:1,class:`dl-reshape__error`,x:K.value.w/2,y:Y.value+30,"text-anchor":`middle`},` RuntimeError — 5 x 5 = 25, and there are only 24 elements `,8,M)):(e(),u(_,{key:0},[l(`g`,ce,[l(`line`,{x1:K.value.w/2,y1:42,x2:K.value.w/2,y2:Y.value-10},null,8,le),l(`path`,{d:`M ${K.value.w/2} ${Y.value-10} l -4 -6 h 8 z`},null,8,ue),l(`text`,{x:K.value.w/2+8,y:Y.value-16},n(H.value.call),9,de)]),(e(!0),u(_,null,a(he.value,(t,n)=>(e(),u(`rect`,{key:`f${n}`,class:`dl-reshape__frame`,x:t.x,y:t.y,width:t.w,height:t.h,rx:`4`},null,8,fe))),128)),l(`g`,O,[(e(!0),u(_,null,a(Z.value,t=>(e(),u(`g`,{key:`g${t.flat}`,class:d({"is-selected":t.flat===W.value}),tabindex:`0`,role:`button`,"aria-label":`element ${t.flat} at index ${t.index.join(`, `)}`,onClick:e=>Q(t.flat),onKeydown:[f(h(e=>Q(t.flat),[`prevent`]),[`enter`]),f(h(e=>Q(t.flat),[`prevent`]),[`space`])]},[l(`rect`,{x:t.x,y:t.y,width:t.w,height:t.h,rx:`3`,style:s({fill:`color-mix(in srgb, var(--dl-accent) ${Math.round(X(t.flat)*100)}%, var(--dl-surface))`})},null,12,A),l(`text`,{x:t.x+t.w/2,y:t.y+t.h/2+4,"text-anchor":`middle`},n(t.flat),9,j)],42,k))),128))])],64))],8,ne))]),_:1})}}}),[[`__scopeId`,`data-v-d56f641c`]]),H={class:`mt-3 dl-callout`},U={__name:`slides.md__slidev_13`,setup(n){let{$slidev:a,$nav:s,$clicksContext:c,$clicks:d,$page:f,$renderContext:p,$frontmatter:h}=S();return c.setup(),(n,a)=>{let s=V,c=i(`click`);return e(),v(D,y(r(x(C)(x(h),12))),{aside:m(t=>[a[1]||=l(`p`,null,`The strip at the top is the tensor: 24 numbers, side by side in memory.`,-1),a[2]||=l(`div`,{class:`mt-2 dl-secondary`},[l(`p`,null,`Every button below re-reads that same strip. Click an element and watch it stay exactly where it is while the grid rearranges around it.`)],-1),ee((e(),u(`div`,H,[...a[0]||=[l(`p`,null,[o(`So the only thing `),l(`code`,null,`reshape`),o(` can refuse is a shape whose product is not 24.`)],-1)]])),[[c]])]),default:m(()=>[t(s)]),_:1},16)}}};export{U as default};
lecture-03/assets/md-BhW511Ut.js ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ import{B as e,C as t,D as n,G as r,S as i,_ as a,b as o,et as s,tt as c,v as l,xt as u,yt as d}from"./modules/shiki-CJZsCeMT.js";import{n as f,t as p}from"./slidev/context-DB-9afGB.js";import{t as m}from"./slidev/CodeBlockWrapper-DqFdVwPK.js";import{t as h}from"./default-IV3yhGVf.js";import{t as g}from"./slidev/VClicks-DYiBHOPb.js";var _={class:`grid grid-cols-2 gap-8 mt-2`},v={class:`dl-callout`},y={class:`mt-3 dl-secondary`},b={__name:`slides.md__slidev_26`,setup(b){let{$slidev:x,$nav:S,$clicksContext:C,$clicks:w,$page:T,$renderContext:E,$frontmatter:D}=f();return C.setup(),(f,b)=>{let x=g,S=m,C=r(`click`);return e(),l(h,u(n(d(p)(d(D),25))),{default:s(()=>[b[4]||=a(`h1`,null,[i(`Three rules for `),a(`code`,null,`requires_grad`)],-1),a(`div`,_,[a(`div`,null,[t(x,null,{default:s(()=>[...b[0]||=[a(`ul`,null,[a(`li`,null,[a(`strong`,null,`Leaves opt in.`),i(` Data is `),a(`code`,null,`False`),i(`; parameters are `),a(`code`,null,`True`),i(`, set for you by `),a(`code`,null,`nn.Parameter`)]),a(`li`,null,[a(`strong`,null,`Results inherit.`),i(` Any tensor computed from one that requires gradients requires them too, and carries a `),a(`code`,null,`grad_fn`)]),a(`li`,null,[a(`strong`,null,[a(`code`,null,`.grad`),i(` only fills in on leaves.`)]),i(` Intermediate tensors are differentiated `),a(`em`,null,`through`),i(`, not `),a(`em`,null,`for`)])],-1)]]),_:1})]),a(`div`,null,[c((e(),o(`div`,v,[t(S,{title:``,ranges:[]},{default:s(()=>[...b[1]||=[a(`pre`,{class:`shiki shiki-themes vitesse-dark vitesse-light slidev-code`,style:{"--shiki-dark":`#dbd7caee`,"--shiki-light":`#393a34`,"--shiki-dark-bg":`#121212`,"--shiki-light-bg":`#ffffff`}},[a(`code`,{class:`language-python`},[a(`span`,{class:`line`},[a(`span`,{style:{"--shiki-dark":`#4D9375`,"--shiki-light":`#1E754F`}},`with`),a(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},` torch`),a(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`.`),a(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},`no_grad`),a(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`():`)]),i(`
2
+ `),a(`span`,{class:`line`},[a(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},` logits `),a(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`=`),a(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},` model`),a(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`(`),a(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},`images`),a(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`)`),a(`span`,{style:{"--shiki-dark":`#758575DD`,"--shiki-light":`#A0ADA0`}},` # no graph built`)])])],-1)]]),_:1}),b[2]||=a(`p`,null,[i(`Use it whenever you are not about to call `),a(`code`,null,`backward()`),i(`: evaluation, and inspection. Less memory, faster.`)],-1)])),[[C]]),c((e(),o(`div`,y,[...b[3]||=[a(`p`,null,[a(`code`,null,`t.detach()`),i(` is the same idea for one tensor: same numbers, cut out of the graph.`)],-1)]])),[[C]])])])]),_:1},16)}}};export{b as default};
lecture-03/assets/md-BjlkbSdd2.js ADDED
@@ -0,0 +1 @@
 
 
1
+ import{B as e,C as t,D as n,G as r,S as i,_ as a,b as o,et as s,tt as c,v as l,xt as u,yt as d}from"./modules/shiki-CJZsCeMT.js";import{n as f,t as p}from"./slidev/context-DB-9afGB.js";import{t as m}from"./default-IV3yhGVf.js";import{t as h}from"./slidev/VClicks-DYiBHOPb.js";var g={class:`grid grid-cols-2 gap-8 mt-2`},_={class:`mt-4 dl-callout`},v={__name:`slides.md__slidev_35`,setup(v){let{$slidev:y,$nav:b,$clicksContext:x,$clicks:S,$page:C,$renderContext:w,$frontmatter:T}=f();return x.setup(),(f,v)=>{let y=h,b=r(`click`);return e(),l(m,u(n(d(p)(d(T),34))),{default:s(()=>[v[3]||=a(`h1`,null,`Why flatten, and why no softmax`,-1),a(`div`,g,[a(`div`,null,[t(y,null,{default:s(()=>[...v[0]||=[a(`ul`,null,[a(`li`,null,[a(`code`,null,`nn.Linear`),i(` takes a `),a(`strong`,null,`vector`),i(` per sample, so the image must be flattened: `),a(`code`,null,`(1, 28, 28)`),i(` becomes `),a(`code`,null,`(784,)`)]),a(`li`,null,[i(`Flattening throws away which pixels were neighbours. The network has to rediscover that from data — `),a(`strong`,null,`and that is what Lecture 04 fixes`)])],-1)]]),_:1})]),a(`div`,null,[t(y,null,{default:s(()=>[...v[1]||=[a(`ul`,null,[a(`li`,null,[i(`The last layer outputs 10 raw numbers, called `),a(`strong`,null,`logits`),i(`. Bigger means more confident`)]),a(`li`,null,[a(`code`,null,`nn.CrossEntropyLoss`),i(` applies `),a(`code`,null,`log_softmax`),i(),a(`strong`,null,`itself`),i(`. Add your own softmax and you have applied it twice`)])],-1)]]),_:1}),c((e(),o(`div`,_,[...v[2]||=[a(`p`,null,`Softmax twice does not crash. It trains slowly and badly, which is worse.`,-1)]])),[[b]])])])]),_:1},16)}}};export{v as default};
lecture-03/assets/md-Bx7fJlZr2.js ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import{B as e,C as t,D as n,G as r,N as i,S as a,_ as o,b as s,et as c,tt as l,v as u,xt as d,yt as f}from"./modules/shiki-CJZsCeMT.js";import{n as p,t as m}from"./slidev/context-DB-9afGB.js";import{t as h}from"./slidev/CodeBlockWrapper-DqFdVwPK.js";import{t as g}from"./default-IV3yhGVf.js";var _={class:`mt-2 dl-secondary`},v={__name:`slides.md__slidev_37`,setup(v){let{$slidev:y,$nav:b,$clicksContext:x,$clicks:S,$page:C,$renderContext:w,$frontmatter:T}=p();return x.setup(),(p,v)=>{let y=h,b=r(`click`);return e(),u(g,d(n(f(m)(f(T),36))),{default:c(()=>[v[2]||=o(`h1`,null,`The training loop`,-1),t(y,i({lines:!0},{title:``,ranges:[`all`,`1-3`,`5-6`,`7-9`,`10-11`,`12-14`,`all`]}),{default:c(()=>[...v[0]||=[o(`pre`,{class:`shiki shiki-themes vitesse-dark vitesse-light slidev-code`,style:{"--shiki-dark":`#dbd7caee`,"--shiki-light":`#393a34`,"--shiki-dark-bg":`#121212`,"--shiki-light-bg":`#ffffff`}},[o(`code`,{class:`language-python`},[o(`span`,{class:`line`},[o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},`model `),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`=`),o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},` MnistFCNN`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`().`),o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},`to`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`(`),o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},`device`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`)`)]),a(`
2
+ `),o(`span`,{class:`line`},[o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},`loss_fn `),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`=`),o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},` nn`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`.`),o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},`CrossEntropyLoss`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`()`)]),a(`
3
+ `),o(`span`,{class:`line`},[o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},`optimiser `),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`=`),o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},` torch`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`.`),o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},`optim`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`.`),o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},`Adam`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`(`),o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},`model`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`.`),o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},`parameters`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`(),`),o(`span`,{style:{"--shiki-dark":`#BD976A`,"--shiki-light":`#B07D48`}},` lr`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`=`),o(`span`,{style:{"--shiki-dark":`#4C9A91`,"--shiki-light":`#2F798A`}},`1e-3`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`)`)]),a(`
4
+ `),o(`span`,{class:`line`}),a(`
5
+ `),o(`span`,{class:`line`},[o(`span`,{style:{"--shiki-dark":`#4D9375`,"--shiki-light":`#1E754F`}},`for`),o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},` epoch `),o(`span`,{style:{"--shiki-dark":`#4D9375`,"--shiki-light":`#1E754F`}},`in`),o(`span`,{style:{"--shiki-dark":`#B8A965`,"--shiki-light":`#998418`}},` range`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`(`),o(`span`,{style:{"--shiki-dark":`#4C9A91`,"--shiki-light":`#2F798A`}},`10`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`):`)]),a(`
6
+ `),o(`span`,{class:`line`},[o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},` model`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`.`),o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},`train`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`()`),o(`span`,{style:{"--shiki-dark":`#758575DD`,"--shiki-light":`#A0ADA0`}},` # training mode, every epoch`)]),a(`
7
+ `),o(`span`,{class:`line`},[o(`span`,{style:{"--shiki-dark":`#4D9375`,"--shiki-light":`#1E754F`}},` for`),o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},` images`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`,`),o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},` labels `),o(`span`,{style:{"--shiki-dark":`#4D9375`,"--shiki-light":`#1E754F`}},`in`),o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},` train_loader`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`:`),o(`span`,{style:{"--shiki-dark":`#758575DD`,"--shiki-light":`#A0ADA0`}},` # one batch`)]),a(`
8
+ `),o(`span`,{class:`line`},[o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},` images `),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`=`),o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},` images`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`.`),o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},`to`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`(`),o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},`device`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`)`)]),a(`
9
+ `),o(`span`,{class:`line`},[o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},` labels `),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`=`),o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},` labels`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`.`),o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},`to`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`(`),o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},`device`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`)`)]),a(`
10
+ `),o(`span`,{class:`line`},[o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},` logits `),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`=`),o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},` model`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`(`),o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},`images`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`)`),o(`span`,{style:{"--shiki-dark":`#758575DD`,"--shiki-light":`#A0ADA0`}},` # forward`)]),a(`
11
+ `),o(`span`,{class:`line`},[o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},` loss `),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`=`),o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},` loss_fn`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`(`),o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},`logits`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`,`),o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},` labels`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`)`),o(`span`,{style:{"--shiki-dark":`#758575DD`,"--shiki-light":`#A0ADA0`}},` # one scalar`)]),a(`
12
+ `),o(`span`,{class:`line`},[o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},` optimiser`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`.`),o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},`zero_grad`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`()`),o(`span`,{style:{"--shiki-dark":`#758575DD`,"--shiki-light":`#A0ADA0`}},` # clear last batch's gradients`)]),a(`
13
+ `),o(`span`,{class:`line`},[o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},` loss`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`.`),o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},`backward`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`()`),o(`span`,{style:{"--shiki-dark":`#758575DD`,"--shiki-light":`#A0ADA0`}},` # fill every .grad`)]),a(`
14
+ `),o(`span`,{class:`line`},[o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},` optimiser`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`.`),o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},`step`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`()`),o(`span`,{style:{"--shiki-dark":`#758575DD`,"--shiki-light":`#A0ADA0`}},` # change every parameter`)])])],-1)]]),_:1},16),l((e(),s(`div`,_,[...v[1]||=[o(`p`,null,[a(`Four lines do the work: `),o(`strong`,null,`forward, loss, backward, step`),a(`. They are in that order in every PyTorch program ever written.`)],-1)]])),[[b]])]),_:1},16)}}};export{v as default};
lecture-03/assets/md-C20K91iw.css ADDED
@@ -0,0 +1 @@
 
 
1
+ .dl-bcast[data-v-cfd50364]{width:100%;height:100%}.dl-bcast__ladder text[data-v-cfd50364]{fill:var(--dl-body);font-variant-numeric:tabular-nums;font-size:11px}.dl-bcast__ladder text.is-implied[data-v-cfd50364]{fill:var(--dl-muted)}.dl-bcast__ladder text.is-out[data-v-cfd50364]{fill:var(--dl-accent);font-weight:700}.dl-bcast__ladder text.is-verdict[data-v-cfd50364]{fill:var(--dl-muted);font-size:7.5px}.dl-bcast__ladder line[data-v-cfd50364]{stroke:var(--dl-border);stroke-width:1px}.dl-bcast__ladder g.is-error text.is-out[data-v-cfd50364],.dl-bcast__ladder g.is-error text.is-verdict[data-v-cfd50364]{fill:var(--dl-danger)}.dl-bcast__cells rect[data-v-cfd50364]{fill:var(--dl-surface);stroke:var(--dl-border);stroke-width:.8px}.dl-bcast__cells text[data-v-cfd50364]{fill:var(--dl-body);font-variant-numeric:tabular-nums;font-size:10px}.dl-bcast__cells g.is-ghost rect[data-v-cfd50364]{fill:none;stroke-dasharray:3 2}.dl-bcast__cells g.is-ghost text[data-v-cfd50364]{fill:var(--dl-muted)}.dl-bcast__cells.is-out rect[data-v-cfd50364]{fill:var(--dl-accent-soft);stroke:var(--dl-accent)}.dl-bcast__cells.is-out text[data-v-cfd50364]{fill:var(--dl-heading);font-weight:600}.dl-bcast__op[data-v-cfd50364]{fill:var(--dl-muted);font-size:15px}.dl-bcast__error[data-v-cfd50364]{fill:var(--dl-danger);font-size:12px;font-family:var(--slidev-code-font-family,monospace)}.dl-bcast__tab[data-v-cfd50364]{border:1px solid var(--dl-border);font-family:var(--slidev-code-font-family,monospace);color:var(--dl-body);cursor:pointer;background:0 0;border-radius:6px;padding:.24rem .6rem;font-size:.76rem}.dl-bcast__tab[data-v-cfd50364]:hover{border-color:var(--dl-accent);color:var(--dl-accent)}.dl-bcast__tab.is-active[data-v-cfd50364]{background:var(--dl-accent);border-color:var(--dl-accent);color:#fff;font-weight:600}.dl-bcast__tab.is-bad.is-active[data-v-cfd50364]{background:var(--dl-danger);border-color:var(--dl-danger)}.dl-bcast__tab[data-v-cfd50364]:focus-visible{outline:2px solid var(--dl-accent);outline-offset:2px}.dl-bcast__facts[data-v-cfd50364]{margin-bottom:.2rem}.dl-bcast__facts strong[data-v-cfd50364]{color:var(--dl-accent);font-size:1rem}.dl-bcast__msg[data-v-cfd50364]{color:var(--dl-danger);font-family:var(--slidev-code-font-family,monospace);font-size:.74rem}.dl-bcast__note[data-v-cfd50364]{line-height:1.35}
lecture-03/assets/md-C246a0Zo.js ADDED
@@ -0,0 +1 @@
 
 
1
+ import{B as e,C as t,D as n,G as r,S as i,_ as a,b as o,et as s,tt as c,v as l,xt as u,yt as d}from"./modules/shiki-CJZsCeMT.js";import{n as f,t as p}from"./slidev/context-DB-9afGB.js";import{t as m}from"./default-IV3yhGVf.js";import{t as h}from"./slidev/VClicks-DYiBHOPb.js";var g={class:`grid grid-cols-2 gap-10 mt-2`},_={class:`mt-2 dl-callout`},v={__name:`slides.md__slidev_45`,setup(v){let{$slidev:y,$nav:b,$clicksContext:x,$clicks:S,$page:C,$renderContext:w,$frontmatter:T}=f();return x.setup(),(f,v)=>{let y=h,b=r(`click`);return e(),l(m,u(n(d(p)(d(T),44))),{default:s(()=>[v[3]||=a(`h1`,null,`Where we got to`,-1),a(`div`,g,[a(`div`,null,[t(y,null,{default:s(()=>[...v[0]||=[a(`ul`,null,[a(`li`,null,[i(`A tensor is an array `),a(`strong`,null,`plus a shape`),i(`, and reshape only changes the shape`)]),a(`li`,null,[a(`code`,null,`dim`),i(` is the axis that disappears; broadcasting aligns from the right`)]),a(`li`,null,[i(`The graph is recorded as you compute, so `),a(`code`,null,`backward()`),i(` needs no algebra`)])],-1)]]),_:1})]),a(`div`,null,[t(y,null,{default:s(()=>[...v[1]||=[a(`ul`,null,[a(`li`,null,`Five pieces: data, model, loss, optimiser, loop`),a(`li`,null,`Four lines: forward, loss, backward, step`),a(`li`,null,`An evaluation is a matrix and two curves, not one number`)],-1)]]),_:1})])]),c((e(),o(`div`,_,[...v[2]||=[a(`p`,null,`98% on MNIST, from a network that discards which pixels were neighbours. Next week we stop.`,-1)]])),[[b]])]),_:1},16)}}};export{v as default};
lecture-03/assets/md-C2rUqOeQ.js ADDED
@@ -0,0 +1 @@
 
 
1
+ import{B as e,Ct as t,D as n,T as r,U as i,_ as a,b as o,et as s,v as c,xt as l,y as u,yt as d}from"./modules/shiki-CJZsCeMT.js";import{t as f}from"./_plugin-vue_export-helper-BDNMzG2s.js";import{n as p,t as m}from"./slidev/context-DB-9afGB.js";var h={class:`slidev-layout dl-title`},g={class:`dl-title__eyebrow`},_={key:0,class:`dl-title__code`},v={key:1,class:`dl-title__lecture`},y={class:`dl-title__body`},b={class:`dl-title__meta`},x={key:0,class:`dl-title__author`},S=[`href`],C={key:2,class:`dl-title__date`},w=f(r({__name:`title`,props:{courseCode:{},lecture:{},author:{},email:{},date:{}},setup(n){let{$slidev:r,$nav:s,$clicksContext:c,$clicks:l,$page:d,$renderContext:f,$frontmatter:m}=p(),w=n;return(n,r)=>(e(),o(`div`,h,[a(`div`,g,[w.courseCode?(e(),o(`span`,_,t(w.courseCode),1)):u(`v-if`,!0),w.lecture?(e(),o(`span`,v,`Lecture `+t(w.lecture),1)):u(`v-if`,!0)]),a(`div`,y,[i(n.$slots,`default`,{},void 0,!0)]),r[0]||=a(`div`,{class:`dl-rule dl-title__rule`},null,-1),a(`div`,b,[w.author?(e(),o(`div`,x,t(w.author),1)):u(`v-if`,!0),w.email?(e(),o(`a`,{key:1,href:`mailto:${w.email}`,class:`dl-title__email`},t(w.email),9,S)):u(`v-if`,!0),w.date?(e(),o(`div`,C,t(w.date),1)):u(`v-if`,!0)])]))}}),[[`__scopeId`,`data-v-dc59a472`]]),T={__name:`slides.md__slidev_1`,setup(t){let{$slidev:r,$nav:i,$clicksContext:o,$clicks:u,$page:f,$renderContext:h,$frontmatter:g}=p();return o.setup(),(t,r)=>(e(),c(w,l(n(d(m)(d(g),0))),{default:s(()=>[...r[0]||=[a(`h1`,null,`PyTorch for Deep Learning`,-1),a(`p`,null,`A tensor is an array that remembers how it was computed. Everything else in PyTorch is built on that one fact. By the end of today, it will have trained a network for you.`,-1)]]),_:1},16))}};export{T as default};
lecture-03/assets/md-C6zLxdHH.js ADDED
@@ -0,0 +1 @@
 
 
1
+ import{B as e,C as t,Ct as n,D as r,G as i,H as a,S as o,T as s,_ as c,b as l,bt as u,dt as d,et as f,g as p,m,tt as h,v as g,xt as _,y as v,yt as y}from"./modules/shiki-CJZsCeMT.js";import{t as b}from"./_plugin-vue_export-helper-BDNMzG2s.js";import{n as x,t as S}from"./slidev/context-DB-9afGB.js";import{t as C}from"./WidgetFrame-DHgK6j2H.js";import{t as w}from"./interactive-CBN7ZXLe.js";import{t as T}from"./StepButton-DD4XxENU.js";var E=[`viewBox`,`aria-label`],D=[`x`,`y`,`width`,`height`],O={class:`dl-reduce__head`},k=[`x`,`y`],A=[`x`,`y`],j={class:`dl-reduce__cells`},ee=[`x`,`y`],te=[`x`,`y`],ne=[`x`,`y`,`width`,`height`],re={class:`dl-reduce__cells is-result`},ie=[`x`,`y`],ae=[`x`,`y`],oe=[`onClick`],se=[`onClick`],ce={class:`dl-reduce__facts`},M={class:`dl-reduce__note`},N=32,P=3,F=18,I=16,L=20,R=b(s({__name:`ReduceDim`,setup(r){let{$slidev:i,$nav:s,$clicksContext:h,$clicks:_,$page:b,$renderContext:S,$frontmatter:w}=x(),R=[[3,8,1,6],[7,2,9,4],[5,0,2,8]],z=R.length,B=R[0].length,V=[`sum`,`mean`,`max`,`argmax`],H=d(`sum`),U=d(0),W=d(!1);function le(e){switch(H.value){case`sum`:return e.reduce((e,t)=>e+t,0);case`mean`:return e.reduce((e,t)=>e+t,0)/e.length;case`max`:return Math.max(...e);case`argmax`:return e.indexOf(Math.max(...e))}}let ue=p(()=>U.value===`none`?[R.flat()]:U.value===0?Array.from({length:B},(e,t)=>R.map(e=>e[t])):R.map(e=>[...e])),de=p(()=>ue.value.map(le)),G=p(()=>W.value&&U.value!==`none`),K=p(()=>U.value===`none`?[]:U.value===0?G.value?[1,B]:[B]:G.value?[z,1]:[z]);function fe(e){return H.value===`mean`?e.toFixed(2):String(e)}let q=B*N+(B-1)*P,J=z*N+(z-1)*P,Y={w:F+q+L+N+6,h:I+J+L+N+6},X=p(()=>{let e=[];for(let t=0;t<z;t++)for(let n=0;n<B;n++){let r=H.value===`argmax`||H.value===`max`?U.value===`none`?R[t][n]===Math.max(...R.flat()):U.value===0?R[t][n]===Math.max(...R.map(e=>e[n])):R[t][n]===Math.max(...R[t]):!0;e.push({r:t,c:n,x:F+n*35,y:I+t*35,v:R[t][n],lit:r})}return e}),pe=p(()=>U.value===`none`?[{x:15,y:13,w:q+6,h:J+6}]:U.value===0?Array.from({length:B},(e,t)=>({x:F+t*35-2,y:13,w:36,h:J+6})):Array.from({length:z},(e,t)=>({x:15,y:I+t*35-2,w:q+6,h:36}))),Z=p(()=>de.value.map((e,t)=>U.value===`none`?{x:F+q+L,y:I+J+L,v:e}:U.value===0?{x:F+t*35,y:I+J+L,v:e}:{x:F+q+L,y:I+t*35,v:e})),Q=p(()=>{if(!G.value)return null;let e=Z.value[0],t=Z.value[Z.value.length-1];return{x:e.x-3,y:e.y-3,w:t.x-e.x+N+6,h:t.y-e.y+N+6}}),$=p(()=>{let e=[];return U.value!==`none`&&e.push(`dim=${U.value}`),G.value&&e.push(`keepdim=True`),`t.${H.value}(${e.join(`, `)})`}),me={sum:`Add up everything along that axis. The axis is gone from the result — that is what reducing means.`,mean:`The same collapse, divided by how many elements went into it. This is how a per-batch loss becomes one number.`,max:`The largest value along the axis. Note that PyTorch actually returns two things here — the values and their indices.`,argmax:"Not the value but its *position*. `logits.argmax(dim=1)` turns a (64, 10) batch of scores into 64 predicted class labels, which is exactly how you score a classifier."},he=p(()=>U.value===`none`?`No dim at all: every axis collapses and you get a 0-D tensor.`:G.value?`keepdim=True keeps dim ${U.value} as a length-1 axis, so the result still has rank 2 and still broadcasts against the original.`:`dim=${U.value} means dim ${U.value} disappears. What is left is ${U.value===0?`one answer per column, ${B} of them`:`one answer per row, ${z} of them`}.`);return(r,i)=>{let s=T,d=C;return e(),g(d,{"max-width":`34rem`},{controls:f(()=>[(e(),l(m,null,a(V,e=>c(`button`,{key:e,type:`button`,class:u([`dl-reduce__tab`,{"is-active":H.value===e}]),onClick:t=>H.value=e},n(e),11,oe)),64)),i[1]||=c(`span`,{class:`dl-reduce__sep`,"aria-hidden":`true`},null,-1),(e(),l(m,null,a([`none`,0,1],e=>c(`button`,{key:`d${e}`,type:`button`,class:u([`dl-reduce__tab`,{"is-active":U.value===e}]),onClick:t=>U.value=e},n(e===`none`?`no dim`:`dim=${e}`),11,se)),64)),t(s,{label:G.value?`keepdim=True`:`keepdim=False`,variant:G.value?`primary`:`ghost`,disabled:U.value===`none`,onClick:i[0]||=e=>W.value=!W.value},null,8,[`label`,`variant`,`disabled`])]),readout:f(()=>[c(`div`,ce,[c(`span`,null,[c(`code`,null,n($.value),1)]),c(`span`,null,[i[2]||=o(`shape `,-1),c(`strong`,null,n(K.value.length===0?`()`:`(${K.value.join(`, `)})`),1)])]),c(`div`,M,n(he.value)+` `+n(me[H.value]),1)]),default:f(()=>[(e(),l(`svg`,{class:`dl-reduce`,viewBox:`0 0 ${Y.w} ${Y.h}`,preserveAspectRatio:`xMidYMid meet`,role:`img`,"aria-label":`${$.value} on a 3 by 4 tensor`},[(e(!0),l(m,null,a(pe.value,(t,n)=>(e(),l(`rect`,{key:`b${n}`,class:`dl-reduce__band`,x:t.x,y:t.y,width:t.w,height:t.h,rx:`4`},null,8,D))),128)),c(`g`,O,[(e(!0),l(m,null,a(y(B),t=>(e(),l(`text`,{key:`hc${t}`,x:F+(t-1)*35+N/2,y:10,"text-anchor":`middle`},n(t-1),9,k))),128)),(e(!0),l(m,null,a(y(z),t=>(e(),l(`text`,{key:`hr${t}`,x:12,y:I+(t-1)*35+N/2+4,"text-anchor":`end`},n(t-1),9,A))),128))]),c(`g`,j,[(e(!0),l(m,null,a(X.value,t=>(e(),l(`g`,{key:`${t.r}-${t.c}`,class:u({"is-dim":!t.lit})},[c(`rect`,{x:t.x,y:t.y,width:N,height:N,rx:`3`},null,8,ee),c(`text`,{x:t.x+N/2,y:t.y+N/2+4,"text-anchor":`middle`},n(t.v),9,te)],2))),128))]),Q.value?(e(),l(`rect`,{key:0,class:`dl-reduce__keep`,x:Q.value.x,y:Q.value.y,width:Q.value.w,height:Q.value.h,rx:`4`},null,8,ne)):v(`v-if`,!0),c(`g`,re,[(e(!0),l(m,null,a(Z.value,(t,r)=>(e(),l(`g`,{key:`r${r}`},[c(`rect`,{x:t.x,y:t.y,width:N,height:N,rx:`3`},null,8,ie),c(`text`,{x:t.x+N/2,y:t.y+N/2+4,"text-anchor":`middle`},n(fe(t.v)),9,ae)]))),128))])],8,E))]),_:1})}}}),[[`__scopeId`,`data-v-e6eef546`]]),z={class:`mt-3 dl-callout`},B={class:`mt-3`},V={__name:`slides.md__slidev_16`,setup(n){let{$slidev:a,$nav:s,$clicksContext:u,$clicks:d,$page:p,$renderContext:m,$frontmatter:v}=x();return u.setup(),(n,a)=>{let s=R,u=i(`click`);return e(),g(w,_(r(y(S)(y(v),15))),{aside:f(t=>[a[2]||=c(`div`,{class:`dl-secondary`},[c(`p`,null,[o(`Pick a `),c(`code`,null,`dim`),o(`, then predict the shape that comes back.`)])],-1),h((e(),l(`div`,z,[...a[0]||=[c(`p`,null,[c(`code`,null,`dim`),o(` is the axis that `),c(`strong`,null,`disappears`),o(`. Over dim 0 the answers land under their columns; over dim 1, beside their rows. `),c(`code`,null,`keepdim=True`),o(` keeps the axis at length 1.`)],-1)]])),[[u]]),h((e(),l(`div`,B,[...a[1]||=[c(`p`,null,[o(`Try `),c(`strong`,null,`argmax`),o(` with `),c(`strong`,null,`dim=1`),o(`: on a batch of logits, one predicted digit per image.`)],-1)]])),[[u]])]),default:f(()=>[t(s)]),_:1},16)}}};export{V as default};
lecture-03/assets/md-C9B1QIfs.css ADDED
@@ -0,0 +1 @@
 
 
1
+ .dl-reduce[data-v-e6eef546]{width:100%;height:100%}.dl-reduce__band[data-v-e6eef546]{fill:var(--dl-accent-soft);stroke:var(--dl-accent);stroke-width:.7px;stroke-dasharray:3 2}.dl-reduce__head text[data-v-e6eef546]{fill:var(--dl-muted);font-variant-numeric:tabular-nums;font-size:10px}.dl-reduce__cells rect[data-v-e6eef546]{fill:var(--dl-bg);stroke:var(--dl-border);stroke-width:.9px}.dl-reduce__cells text[data-v-e6eef546]{fill:var(--dl-heading);font-variant-numeric:tabular-nums;font-size:12px}.dl-reduce__cells g.is-dim rect[data-v-e6eef546]{fill:var(--dl-bg)}.dl-reduce__cells g.is-dim text[data-v-e6eef546]{fill:var(--dl-muted)}.dl-reduce__cells.is-result rect[data-v-e6eef546]{fill:var(--dl-accent);stroke:var(--dl-accent-strong)}.dl-reduce__cells.is-result text[data-v-e6eef546]{fill:#fff;font-size:11px;font-weight:700}.dl-reduce__keep[data-v-e6eef546]{fill:none;stroke:var(--dl-heading);stroke-width:1.2px;stroke-dasharray:4 2}.dl-reduce__tab[data-v-e6eef546]{border:1px solid var(--dl-border);font-family:var(--slidev-code-font-family,monospace);color:var(--dl-body);cursor:pointer;background:0 0;border-radius:6px;padding:.24rem .6rem;font-size:.76rem}.dl-reduce__tab[data-v-e6eef546]:hover{border-color:var(--dl-accent);color:var(--dl-accent)}.dl-reduce__tab.is-active[data-v-e6eef546]{background:var(--dl-accent);border-color:var(--dl-accent);color:#fff;font-weight:600}.dl-reduce__tab[data-v-e6eef546]:focus-visible{outline:2px solid var(--dl-accent);outline-offset:2px}.dl-reduce__sep[data-v-e6eef546]{background:var(--dl-border);width:1px;height:1.1rem}.dl-reduce__facts[data-v-e6eef546]{gap:1.4rem;margin-bottom:.2rem;display:flex}.dl-reduce__facts strong[data-v-e6eef546]{color:var(--dl-accent);font-size:1rem}.dl-reduce__facts code[data-v-e6eef546]{background:var(--dl-code-bg);border-radius:3px;padding:.05rem .25rem;font-size:.8rem}.dl-reduce__note[data-v-e6eef546]{line-height:1.35}
lecture-03/assets/md-CATIlakB.js ADDED
@@ -0,0 +1 @@
 
 
1
+ import{B as e,C as t,D as n,S as r,_ as i,et as a,v as o,xt as s,yt as c}from"./modules/shiki-CJZsCeMT.js";import{n as l,t as u}from"./slidev/context-DB-9afGB.js";import{t as d}from"./interactive-CBN7ZXLe.js";import{t as f}from"./TensorLadder-CuthEwW0.js";var p={__name:`slides.md__slidev_9`,setup(p){let{$slidev:m,$nav:h,$clicksContext:g,$clicks:_,$page:v,$renderContext:y,$frontmatter:b}=l();return g.setup(),(l,p)=>{let m=f;return e(),o(d,s(n(c(u)(c(b),8))),{aside:a(e=>[...p[0]||=[i(`p`,null,`Every tensor in the second half of today has this shape, or comes from it:`,-1),i(`div`,{class:`mt-2 dl-callout`},[i(`p`,null,[i(`code`,null,`images.shape`),r(),i(`span`,{"aria-hidden":`true`},`→`),r(),i(`code`,null,`(64, 1, 28, 28)`)]),i(`p`,null,`64 images · 1 channel · 28 rows · 28 columns`)],-1),i(`div`,{class:`mt-3 dl-secondary`},[i(`p`,null,[r(`Batch first, channels before the spatial axes — `),i(`strong`,null,`NCHW`),r(` (number, channels, height, width).`)])],-1)]]),default:a(()=>[t(m,{start:`batch`})]),_:1},16)}}};export{p as default};
lecture-03/assets/md-CDHWFGeQ2.js ADDED
@@ -0,0 +1 @@
 
 
1
+ import{B as e,D as t,_ as n,et as r,v as i,xt as a,yt as o}from"./modules/shiki-CJZsCeMT.js";import{n as s,t as c}from"./slidev/context-DB-9afGB.js";import{t as l}from"./section-CqA-0pFf.js";var u={__name:`slides.md__slidev_38`,setup(u){let{$slidev:d,$nav:f,$clicksContext:p,$clicks:m,$page:h,$renderContext:g,$frontmatter:_}=s();return p.setup(),(s,u)=>(e(),i(l,a(t(o(c)(o(_),37))),{default:r(()=>[...u[0]||=[n(`h1`,null,`Did it work?`,-1)]]),_:1},16))}};export{u as default};
lecture-03/assets/md-CI1ql4wp.js ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ import{B as e,C as t,D as n,G as r,N as i,S as a,_ as o,b as s,et as c,tt as l,v as u,xt as d,yt as f}from"./modules/shiki-CJZsCeMT.js";import{n as p,t as m}from"./slidev/context-DB-9afGB.js";import{t as h}from"./slidev/CodeBlockWrapper-DqFdVwPK.js";import{t as g}from"./default-IV3yhGVf.js";import{t as _}from"./slidev/VClicks-DYiBHOPb.js";var v={class:`mt-3 dl-callout`},y={__name:`slides.md__slidev_17`,setup(y){let{$slidev:b,$nav:x,$clicksContext:S,$clicks:C,$page:w,$renderContext:T,$frontmatter:E}=p();return S.setup(),(p,y)=>{let b=h,x=_,S=r(`click`);return e(),u(g,d(n(f(m)(f(E),16))),{default:c(()=>[y[3]||=o(`h1`,null,`Matrix multiply is a linear layer`,-1),t(b,i({lines:!0},{title:``,ranges:[`all`,`1-3`,`4`,`5`,`all`]}),{default:c(()=>[...y[0]||=[o(`pre`,{class:`shiki shiki-themes vitesse-dark vitesse-light slidev-code`,style:{"--shiki-dark":`#dbd7caee`,"--shiki-light":`#393a34`,"--shiki-dark-bg":`#121212`,"--shiki-light-bg":`#ffffff`}},[o(`code`,{class:`language-python`},[o(`span`,{class:`line`},[o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},`X `),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`=`),o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},` torch`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`.`),o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},`randn`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`(`),o(`span`,{style:{"--shiki-dark":`#4C9A91`,"--shiki-light":`#2F798A`}},`64`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`,`),o(`span`,{style:{"--shiki-dark":`#4C9A91`,"--shiki-light":`#2F798A`}},` 784`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`)`),o(`span`,{style:{"--shiki-dark":`#758575DD`,"--shiki-light":`#A0ADA0`}},` # a batch of 64 flattened images`)]),a(`
2
+ `),o(`span`,{class:`line`},[o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},`W `),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`=`),o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},` torch`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`.`),o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},`randn`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`(`),o(`span`,{style:{"--shiki-dark":`#4C9A91`,"--shiki-light":`#2F798A`}},`128`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`,`),o(`span`,{style:{"--shiki-dark":`#4C9A91`,"--shiki-light":`#2F798A`}},` 784`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`)`),o(`span`,{style:{"--shiki-dark":`#758575DD`,"--shiki-light":`#A0ADA0`}},` # 128 hidden units, one row of weights each`)]),a(`
3
+ `),o(`span`,{class:`line`},[o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},`b `),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`=`),o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},` torch`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`.`),o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},`randn`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`(`),o(`span`,{style:{"--shiki-dark":`#4C9A91`,"--shiki-light":`#2F798A`}},`128`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`)`),o(`span`,{style:{"--shiki-dark":`#758575DD`,"--shiki-light":`#A0ADA0`}},` # one bias per unit`)]),a(`
4
+ `),o(`span`,{class:`line`},[o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},`Z `),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`=`),o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},` X `),o(`span`,{style:{"--shiki-dark":`#CB7676`,"--shiki-light":`#AB5959`}},`@`),o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},` W`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`.`),o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},`T `),o(`span`,{style:{"--shiki-dark":`#CB7676`,"--shiki-light":`#AB5959`}},`+`),o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},` b `),o(`span`,{style:{"--shiki-dark":`#758575DD`,"--shiki-light":`#A0ADA0`}},`# (64, 784) @ (784, 128) -> (64, 128), + (128,)`)]),a(`
5
+ `),o(`span`,{class:`line`},[o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},`A `),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`=`),o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},` torch`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`.`),o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},`relu`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`(`),o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},`Z`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`)`),o(`span`,{style:{"--shiki-dark":`#758575DD`,"--shiki-light":`#A0ADA0`}},` # element-wise, shape unchanged`)])])],-1)]]),_:1},16),t(x,null,{default:c(()=>[...y[1]||=[o(`ul`,null,[o(`li`,null,[a(`The inner dimensions must agree: `),o(`code`,null,`(64, **784**) @ (**784**, 128)`),a(`. That is the only rule`)]),o(`li`,null,[a(`The outer ones survive: 64 samples in, 64 out. `),o(`code`,null,`+ b`),a(` broadcasts, `),o(`code`,null,`relu`),a(` is element-wise — neither changes the shape`)])],-1)]]),_:1}),l((e(),s(`div`,v,[...y[2]||=[o(`p`,null,[a(`Those lines are `),o(`code`,null,`nn.Linear(784, 128)`),a(` then `),o(`code`,null,`nn.ReLU()`),a(`. Nothing is hidden in a layer except `),o(`code`,null,`W`),a(` and `),o(`code`,null,`b`),a(`.`)],-1)]])),[[S]])]),_:1},16)}}};export{y as default};
lecture-03/assets/md-CIaX1C6P.js ADDED
@@ -0,0 +1 @@
 
 
1
+ import{B as e,C as t,Ct as n,D as r,G as i,H as a,S as o,T as s,_ as c,b as l,dt as u,et as d,g as f,m as p,tt as m,v as h,xt as g,y as _,yt as v}from"./modules/shiki-CJZsCeMT.js";import{t as y}from"./_plugin-vue_export-helper-BDNMzG2s.js";import{n as b,t as x}from"./slidev/context-DB-9afGB.js";import{t as S}from"./WidgetFrame-DHgK6j2H.js";import{t as C}from"./interactive-CBN7ZXLe.js";import{t as w}from"./StepButton-DD4XxENU.js";import{t as T}from"./Slider-C2M0Z0oG.js";import{t as E}from"./useRandom-C9hJeQcV.js";var D={class:`dl-loader`},O={class:`dl-loader__row`},k={class:`dl-loader__strip`},A={class:`dl-loader__row is-batches`},j={class:`dl-loader__batches`},M={class:`dl-loader__batchLabel`},N={class:`dl-loader__strip`},P={key:0,class:`dl-loader__batch is-dropped`},F={class:`dl-loader__strip`},I={class:`dl-loader__facts`},L={class:`dl-loader__note`},R=y(s({__name:`BatchLoader`,setup(r){let{$slidev:i,$nav:s,$clicksContext:m,$clicks:g,$page:v,$renderContext:y,$frontmatter:x}=b(),C=[5,0,4,1,9,2,1,3,1,4,3,5],R=C.length,z=u(4),B=u(!0),V=u(!1),H=u(1),U=f(()=>{let e=Array.from({length:R},(e,t)=>t);if(!B.value)return e;let t=E(H.value*7919+13);for(let n=R-1;n>0;n--){let r=Math.floor(t()*(n+1));[e[n],e[r]]=[e[r],e[n]]}return e}),W=f(()=>{let e=[];for(let t=0;t<U.value.length;t+=z.value)e.push(U.value.slice(t,t+z.value));return V.value&&e.length&&e[e.length-1].length<z.value&&e.pop(),e}),G=f(()=>{let e=W.value[W.value.length-1];return e&&e.length<z.value}),K=f(()=>R-W.value.reduce((e,t)=>e+t.length,0)),q=f(()=>G.value?`12 does not divide by ${z.value}, so the last batch has only ${W.value[W.value.length-1].length} samples. Never hardcode the batch size inside your model — read it off the tensor instead.`:K.value>0?`drop_last=True threw away ${K.value} sample${K.value===1?``:`s`} so every batch is the same size. Fine for training, wrong for evaluation — you would be scoring on less than the whole test set.`:B.value?`Press next epoch: the order changes again. shuffle=True reshuffles at the start of every epoch, so the model never sees the same batch composition twice.`:`shuffle=False keeps the dataset order. If the file happens to be sorted by class, every batch is one digit and training will not work. Shuffle the training set, never the test set.`);return(r,i)=>{let s=T,u=w,f=S;return e(),h(f,{"max-width":`40rem`},{controls:d(()=>[t(s,{modelValue:z.value,"onUpdate:modelValue":i[0]||=e=>z.value=e,label:`batch_size`,min:1,max:6,step:1,precision:0},null,8,[`modelValue`]),t(u,{label:`shuffle=${B.value?`True`:`False`}`,variant:B.value?`primary`:`ghost`,onClick:i[1]||=e=>B.value=!B.value},null,8,[`label`,`variant`]),t(u,{label:`drop_last=${V.value?`True`:`False`}`,variant:V.value?`primary`:`ghost`,onClick:i[2]||=e=>V.value=!V.value},null,8,[`label`,`variant`]),t(u,{label:`next epoch`,variant:`ghost`,glyph:`↻`,disabled:!B.value,onClick:i[3]||=e=>H.value+=1},null,8,[`disabled`])]),readout:d(()=>[c(`div`,I,[c(`span`,null,[i[7]||=o(`epoch `,-1),c(`strong`,null,n(H.value),1)]),c(`span`,null,[i[8]||=c(`code`,null,`len(train_loader)`,-1),i[9]||=o(),c(`strong`,null,n(W.value.length),1)]),c(`span`,null,[i[10]||=o(`a full iteration yields `,-1),i[11]||=c(`code`,null,`images`,-1),i[12]||=o(),c(`strong`,null,`(`+n(z.value)+`, 1, 28, 28)`,1),i[13]||=o(` and `,-1),i[14]||=c(`code`,null,`labels`,-1),i[15]||=o(),c(`strong`,null,`(`+n(z.value)+`,)`,1)])]),c(`div`,L,n(q.value),1)]),default:d(()=>[c(`div`,D,[c(`div`,O,[i[4]||=c(`span`,{class:`dl-loader__side`},`train_set`,-1),c(`div`,k,[(e(),l(p,null,a(C,(e,t)=>c(`span`,{key:t,class:`dl-loader__chip is-plain`},[c(`em`,null,n(e),1),c(`small`,null,n(t),1)])),64))])]),c(`div`,A,[i[6]||=c(`span`,{class:`dl-loader__side`},`train_loader`,-1),c(`div`,j,[(e(!0),l(p,null,a(W.value,(t,r)=>(e(),l(`div`,{key:r,class:`dl-loader__batch`},[c(`div`,M,`iteration `+n(r),1),c(`div`,N,[(e(!0),l(p,null,a(t,t=>(e(),l(`span`,{key:t,class:`dl-loader__chip`},[c(`em`,null,n(C[t]),1),c(`small`,null,n(t),1)]))),128))])]))),128)),K.value>0?(e(),l(`div`,P,[i[5]||=c(`div`,{class:`dl-loader__batchLabel`},`dropped`,-1),c(`div`,F,[(e(!0),l(p,null,a(U.value.slice(U.value.length-K.value),t=>(e(),l(`span`,{key:t,class:`dl-loader__chip is-ghost`},[c(`em`,null,n(C[t]),1),c(`small`,null,n(t),1)]))),128))])])):_(`v-if`,!0)])])])]),_:1})}}}),[[`__scopeId`,`data-v-11b7a992`]]),z={class:`mt-3 dl-callout`},B={__name:`slides.md__slidev_29`,setup(n){let{$slidev:a,$nav:s,$clicksContext:u,$clicks:f,$page:p,$renderContext:_,$frontmatter:y}=b();return u.setup(),(n,a)=>{let s=R,u=i(`click`);return e(),h(C,g(r(v(x)(v(y),28))),{aside:d(t=>[a[1]||=c(`p`,null,[o(`A `),c(`strong`,null,`Dataset`),o(` fetches sample `),c(`em`,null,`i`),o(`. A `),c(`strong`,null,`DataLoader`),o(` turns that into batches.`)],-1),a[2]||=c(`div`,{class:`mt-2 dl-secondary`},[c(`p`,null,[o(`Drag `),c(`code`,null,`batch_size`),o(` to 5: two batches of five and one of two. A short last batch is normal — never hardcode a batch size in your model.`)])],-1),m((e(),l(`div`,z,[...a[0]||=[c(`p`,null,[c(`code`,null,`shuffle=True`),o(` reshuffles every epoch.`)],-1)]])),[[u]])]),default:d(()=>[t(s)]),_:1},16)}}};export{B as default};
lecture-03/assets/md-CYXxUBJM.css ADDED
@@ -0,0 +1 @@
 
 
1
+ .dl-title[data-v-dc59a472]{flex-direction:column;justify-content:center;padding-left:4rem;padding-right:4rem;display:flex}.dl-title__eyebrow[data-v-dc59a472]{font-size:var(--dl-fs-secondary);letter-spacing:.14em;text-transform:uppercase;align-items:center;gap:.9rem;margin-bottom:1.1rem;display:flex}.dl-title__code[data-v-dc59a472]{color:var(--dl-accent);font-weight:700}.dl-title__lecture[data-v-dc59a472]{color:var(--dl-muted)}.dl-title__body[data-v-dc59a472] h1{font-size:var(--dl-fs-title);margin:0;line-height:1.05}.dl-title__body[data-v-dc59a472] p{font-size:var(--dl-fs-body);color:var(--dl-muted);max-width:34ch;margin-top:.7rem}.dl-title__rule[data-v-dc59a472]{margin:1.6rem 0 1.2rem}.dl-title__meta[data-v-dc59a472]{font-size:var(--dl-fs-secondary);line-height:1.7}.dl-title__author[data-v-dc59a472]{color:var(--dl-heading);font-weight:600}.dl-title__email[data-v-dc59a472]{color:var(--dl-accent)}.dl-title__date[data-v-dc59a472]{color:var(--dl-muted)}
lecture-03/assets/md-Cb-WM6X62.js ADDED
@@ -0,0 +1 @@
 
 
1
+ import{B as e,C as t,Ct as n,D as r,G as i,H as a,S as o,St as s,T as c,_ as l,b as u,bt as d,dt as f,et as p,g as m,m as h,tt as g,v as _,xt as v,y,yt as b}from"./modules/shiki-CJZsCeMT.js";import{t as x}from"./_plugin-vue_export-helper-BDNMzG2s.js";import{n as S,t as C}from"./slidev/context-DB-9afGB.js";import{t as w}from"./WidgetFrame-DHgK6j2H.js";import{t as T}from"./interactive-CBN7ZXLe.js";import{t as E}from"./Slider-C2M0Z0oG.js";var D={class:`dl-fcnn`},O=[`aria-label`],k={key:0,class:`dl-fcnn__arrow`},A={class:`dl-fcnn__ledger`},j={class:`is-num`},M={key:0,class:`dl-fcnn__bar`},N={class:`is-num`},P={class:`dl-fcnn__facts`},F={class:`dl-fcnn__note`},I=784,L=10,R=64,z=x(c({__name:`FcnnBuilder`,setup(r){let{$slidev:i,$nav:c,$clicksContext:g,$clicks:v,$page:b,$renderContext:x,$frontmatter:C}=S(),T=f(128),z=f(64),B=m(()=>[I,...z.value>0?[T.value,z.value]:[T.value],L]),V=m(()=>{let e=[{call:`nn.Flatten()`,shape:`(${R}, ${I})`,params:0,detail:`28 × 28 pixels in a row`}],t=B.value;for(let n=0;n<t.length-1;n++){let r=t[n],i=t[n+1];e.push({call:`nn.Linear(${r}, ${i})`,shape:`(${R}, ${i})`,params:r*i+i,detail:`${r} × ${i} + ${i}`}),n<t.length-2&&e.push({call:`nn.ReLU()`,shape:`(${R}, ${i})`,params:0,detail:`nothing to learn`})}return e}),H=m(()=>V.value.reduce((e,t)=>e+t.params,0));function U(e){return e.toString().replace(/\B(?=(\d{3})+(?!\d))/g,`,`)}let W=m(()=>(H.value*4/1024/1024).toFixed(2)),G=m(()=>B.value.map((e,t)=>({n:e,width:`${(2.3+3.4*Math.sqrt(e/I)).toFixed(2)}rem`,role:t===0?`input`:t===B.value.length-1?`output`:`hidden`,next:t<B.value.length-1?t<B.value.length-2?`Linear → ReLU`:`Linear`:null}))),K=m(()=>Math.max(...V.value.map(e=>e.params),1));return(r,i)=>{let c=E,f=w;return e(),_(f,{"max-width":`46rem`},{controls:p(()=>[t(c,{modelValue:T.value,"onUpdate:modelValue":i[0]||=e=>T.value=e,label:`hidden 1`,min:16,max:256,step:16,precision:0},null,8,[`modelValue`]),t(c,{modelValue:z.value,"onUpdate:modelValue":i[1]||=e=>z.value=e,label:`hidden 2 (0 = none)`,min:0,max:128,step:16,precision:0},null,8,[`modelValue`])]),readout:p(()=>[l(`div`,P,[l(`span`,null,[i[6]||=l(`code`,null,`sum(p.numel() for p in model.parameters())`,-1),i[7]||=o(),l(`strong`,null,n(U(H.value)),1)])]),l(`div`,F,` Lecture 02's hand-written MLP had 50 hidden units and `+n(U(39760))+` parameters. Widen hidden 1 and watch the cost: that layer is wired to all 784 pixels, so it dominates everything else on the table. `,1)]),default:p(()=>[l(`div`,D,[l(`div`,{class:`dl-fcnn__chain`,role:`img`,"aria-label":`A network ${B.value.join(` to `)} with ${H.value} parameters`},[(e(!0),u(h,null,a(G.value,(t,r)=>(e(),u(h,{key:r},[l(`div`,{class:d([`dl-fcnn__pill`,`is-${t.role}`]),style:s({width:t.width})},n(t.n),7),t.next?(e(),u(`div`,k,[l(`span`,null,n(t.next),1),i[2]||=l(`em`,{"aria-hidden":`true`},`→`,-1)])):y(`v-if`,!0)],64))),128))],8,O),i[5]||=l(`div`,{class:`dl-fcnn__roles`},[l(`span`,null,`pixels`),l(`span`,null,`hidden units`),l(`span`,null,`logits, one per digit`)],-1),l(`table`,A,[i[4]||=l(`thead`,null,[l(`tr`,null,[l(`th`,null,`layer`),l(`th`,null,`output shape`),l(`th`,null,`parameters`),l(`th`,null,`in × out + out`)])],-1),l(`tbody`,null,[(e(!0),u(h,null,a(V.value,(t,r)=>(e(),u(`tr`,{key:r,class:d({"is-free":t.params===0})},[l(`td`,null,[l(`code`,null,n(t.call),1)]),l(`td`,null,[l(`code`,null,n(t.shape),1)]),l(`td`,j,n(t.params===0?`—`:U(t.params)),1),l(`td`,null,[t.params>0?(e(),u(`span`,M,[l(`span`,{style:s({width:`${100*t.params/K.value}%`})},null,4)])):y(`v-if`,!0),l(`small`,null,n(t.detail),1)])],2))),128))]),l(`tfoot`,null,[l(`tr`,null,[i[3]||=l(`td`,{colspan:`2`},`total`,-1),l(`td`,N,n(U(H.value)),1),l(`td`,null,n(W.value)+` MB in float32`,1)])])])])]),_:1})}}}),[[`__scopeId`,`data-v-1f9f310f`]]),B={class:`mt-3 dl-callout`},V={__name:`slides.md__slidev_34`,setup(n){let{$slidev:a,$nav:s,$clicksContext:c,$clicks:d,$page:f,$renderContext:m,$frontmatter:h}=S();return c.setup(),(n,a)=>{let s=z,c=i(`click`);return e(),_(T,v(r(b(C)(b(h),33))),{aside:p(t=>[a[1]||=l(`p`,null,`The same network, as a shape ledger you can write down before running anything.`,-1),a[2]||=l(`div`,{class:`mt-2 dl-secondary`},[l(`p`,null,[o(`Each `),l(`code`,null,`Linear`),o(` costs `),l(`code`,null,`in × out + out`),o(`. `),l(`code`,null,`ReLU`),o(` and `),l(`code`,null,`Flatten`),o(` cost nothing — they have no parameters to learn.`)])],-1),g((e(),u(`div`,B,[...a[0]||=[l(`p`,null,[o(`Drag `),l(`strong`,null,`hidden 1`),o(`. It is wired to all 784 pixels, so it dominates the bill.`)],-1)]])),[[c]])]),default:p(()=>[t(s)]),_:1},16)}}};export{V as default};
lecture-03/assets/md-Ceq69z99.js ADDED
@@ -0,0 +1 @@
 
 
1
+ import{B as e,C as t,D as n,G as r,S as i,_ as a,b as o,et as s,tt as c,v as l,xt as u,yt as d}from"./modules/shiki-CJZsCeMT.js";import{n as f,t as p}from"./slidev/context-DB-9afGB.js";import{t as m}from"./default-IV3yhGVf.js";import{t as h}from"./slidev/VClicks-DYiBHOPb.js";var g={class:`grid grid-cols-2 gap-x-10 gap-y-1 mt-3 dl-tight`},_={class:`mt-5 dl-callout`},v={__name:`slides.md__slidev_20`,setup(v){let{$slidev:y,$nav:b,$clicksContext:x,$clicks:S,$page:C,$renderContext:w,$frontmatter:T}=f();return x.setup(),(f,v)=>{let y=h,b=r(`click`);return e(),l(m,u(n(d(p)(d(T),19))),{default:s(()=>[v[3]||=a(`h1`,null,`Your turn — six shapes`,-1),v[4]||=a(`p`,null,[a(`code`,null,`x`),i(` is `),a(`code`,null,`(64, 1, 28, 28)`),i(`. What comes back?`)],-1),a(`div`,g,[a(`div`,null,[t(y,null,{default:s(()=>[...v[0]||=[a(`ul`,null,[a(`li`,null,[a(`code`,null,`x[0].shape`),i(),a(`span`,{"aria-hidden":`true`},`→`),i(),a(`code`,null,`(1, 28, 28)`)]),a(`li`,null,[a(`code`,null,`x[:, 0].shape`),i(),a(`span`,{"aria-hidden":`true`},`→`),i(),a(`code`,null,`(64, 28, 28)`)]),a(`li`,null,[a(`code`,null,`x.flatten(1).shape`),i(),a(`span`,{"aria-hidden":`true`},`→`),i(),a(`code`,null,`(64, 784)`)])],-1)]]),_:1})]),a(`div`,null,[t(y,null,{default:s(()=>[...v[1]||=[a(`ul`,null,[a(`li`,null,[a(`code`,null,`x.mean(dim=(2, 3)).shape`),i(),a(`span`,{"aria-hidden":`true`},`→`),i(),a(`code`,null,`(64, 1)`)]),a(`li`,null,[a(`code`,null,`x.reshape(64, -1).shape`),i(),a(`span`,{"aria-hidden":`true`},`→`),i(),a(`code`,null,`(64, 784)`)]),a(`li`,null,[a(`code`,null,`(x + torch.ones(28)).shape`),i(),a(`span`,{"aria-hidden":`true`},`→`),i(),a(`code`,null,`(64, 1, 28, 28)`)])],-1)]]),_:1})])]),c((e(),o(`div`,_,[...v[2]||=[a(`p`,null,`Six answers, three rules. An integer index drops its axis. A reduction drops the axes it names. Broadcasting aligns shapes from the right.`,-1)]])),[[b]])]),_:1},16)}}};export{v as default};
lecture-03/assets/md-Cqra_90r2.js ADDED
@@ -0,0 +1 @@
 
 
1
+ import{B as e,C as t,Ct as n,D as r,H as i,N as a,S as o,St as s,T as c,U as l,_ as u,b as d,bt as f,et as p,g as m,m as h,v as g,x as _,xt as v,y,yt as b}from"./modules/shiki-CJZsCeMT.js";import{t as x}from"./_plugin-vue_export-helper-BDNMzG2s.js";import{n as S,t as C}from"./slidev/context-DB-9afGB.js";import{t as w}from"./DeckFooter-BMnt3Ksi.js";import{t as T}from"./Citation-CcKhBxpe.js";var E=[`viewBox`,`aria-label`],D={class:`dl-mnist__label-path`},O={x:`52`,y:`57`,"text-anchor":`middle`,class:`dl-mnist__digit`},k={class:`dl-mnist__onehot`},A=[`x`,`y`,`width`,`height`],j=[`x`,`y`],M=[`x`,`y`],N={x:`178`,y:`60`,class:`dl-mnist__cap`},P={class:`dl-mnist__tile`},F=[`x`,`y`,`width`,`height`],I=[`x`,`y`,`width`,`height`],L=[`x`],R=[`x`],z=[`x`],B=[`x`],V=[`x`],H=[`x`],U=[`x`],W={x:`498`,y:`248`,class:`dl-mnist__count`},G={x:`498`,y:`262`,class:`dl-mnist__sub`},K=700,q=420,J=x(c({__name:`MnistPipeline`,props:{size:{default:28},hidden:{default:50},classes:{default:10},label:{default:7}},setup(t){let{$slidev:r,$nav:o,$clicksContext:c,$clicks:l,$page:p,$renderContext:g,$frontmatter:v}=S(),b=t,x=m(()=>b.size*b.size);function C(e,t,n,r,i,a){let o=i-n,s=a-r,c=o*o+s*s,l=c===0?0:Math.max(0,Math.min(1,((e-n)*o+(t-r)*s)/c));return Math.hypot(e-(n+l*o),t-(r+l*s))}let w=[[7.5,7,20,7],[20,7,11,22],[9.5,15,17,15]],T=m(()=>{let e=[];for(let t=0;t<b.size;t++)for(let n=0;n<b.size;n++){let r=1/0;for(let[e,i,a,o]of w)r=Math.min(r,C(n+.5,t+.5,e,i,a,o));let i=Math.max(0,Math.min(1,1.6-r));i>.02&&e.push({x:n,y:t,v:i})}return e}),J={x:24,y:196,size:96},Y=m(()=>J.size/b.size),X={input:{x:196,y:150,width:14,height:190},hidden:{x:312,y:178,width:14,height:134},output:{x:424,y:200,width:14,height:90}},Z={x:150,y:8,w:20,cell:9},Q=m(()=>Array.from({length:b.classes},(e,t)=>({i:t,y:Z.y+t*Z.cell,on:t===b.label})));return(t,r)=>(e(),d(`svg`,{class:`dl-mnist`,viewBox:`0 0 ${K} ${q}`,preserveAspectRatio:`xMidYMid meet`,role:`img`,"aria-label":`An MNIST image of ${b.label} reshaped to ${x.value} inputs, through a hidden layer of ${b.hidden} units to ${b.classes} outputs`},[r[5]||=_(`<defs data-v-8c4f21b8><marker id="dl-mnist-arrow" markerWidth="8" markerHeight="8" refX="7" refY="3.2" orient="auto" data-v-8c4f21b8><path d="M0,0 L7,3.2 L0,6.4 z" class="dl-mnist__head" data-v-8c4f21b8></path></marker><marker id="dl-mnist-arrow-fwd" markerWidth="8" markerHeight="8" refX="7" refY="3.2" orient="auto" data-v-8c4f21b8><path d="M0,0 L7,3.2 L0,6.4 z" class="dl-mnist__head is-fwd" data-v-8c4f21b8></path></marker><marker id="dl-mnist-arrow-back" markerWidth="8" markerHeight="8" refX="7" refY="3.2" orient="auto" data-v-8c4f21b8><path d="M0,0 L7,3.2 L0,6.4 z" class="dl-mnist__head is-back" data-v-8c4f21b8></path></marker></defs>`,1),y(` The label path: 7 -> one-hot target vector. `),u(`g`,D,[r[0]||=u(`rect`,{x:`35`,y:`33`,width:`34`,height:`34`,rx:`3`,class:`dl-mnist__box`},null,-1),u(`text`,O,n(b.label),1),r[1]||=u(`text`,{x:`52`,y:`86`,"text-anchor":`middle`,class:`dl-mnist__cap`},`class label`,-1),r[2]||=u(`line`,{x1:`78`,y1:`50`,x2:`138`,y2:`50`,"marker-end":`url(#dl-mnist-arrow)`,class:`dl-mnist__arrow`},null,-1),r[3]||=u(`text`,{x:`108`,y:`41`,"text-anchor":`middle`,class:`dl-mnist__op`},`encode`,-1),u(`g`,k,[(e(!0),d(h,null,i(Q.value,t=>(e(),d(h,{key:t.i},[u(`rect`,{x:Z.x,y:t.y,width:Z.w,height:Z.cell,class:f({"is-on":t.on})},null,10,A),u(`text`,{x:Z.x+Z.w/2,y:t.y+Z.cell-2.2,"text-anchor":`middle`,class:f({"is-on":t.on})},n(+!!t.on),11,j),u(`text`,{x:Z.x-4,y:t.y+Z.cell-2.2,"text-anchor":`end`,class:`dl-mnist__idx`},n(t.i),9,M)],64))),128))]),r[4]||=u(`text`,{x:`178`,y:`46`,class:`dl-mnist__cap`},`one-hot target,`,-1),u(`text`,N,n(b.classes)+` entries`,1)]),y(` The two directions the same graph is walked in. `),r[6]||=u(`line`,{x1:`440`,y1:`118`,x2:`176`,y2:`118`,"marker-end":`url(#dl-mnist-arrow-back)`,class:`dl-mnist__arrow is-back`},null,-1),r[7]||=u(`text`,{x:`308`,y:`110`,"text-anchor":`middle`,class:`dl-mnist__code is-back`},`.backward() — loss back to every weight`,-1),r[8]||=u(`line`,{x1:`196`,y1:`392`,x2:`440`,y2:`392`,"marker-end":`url(#dl-mnist-arrow-fwd)`,class:`dl-mnist__arrow is-fwd`},null,-1),r[9]||=u(`text`,{x:`318`,y:`408`,"text-anchor":`middle`,class:`dl-mnist__code`},`.forward() — image to probabilities`,-1),y(` The data path: image -> 784 -> 50 -> 10. `),u(`g`,P,[u(`rect`,{x:J.x,y:J.y,width:J.size,height:J.size,class:`dl-mnist__box`},null,8,F),(e(!0),d(h,null,i(T.value,(t,n)=>(e(),d(`rect`,{key:n,x:J.x+t.x*Y.value,y:J.y+t.y*Y.value,width:Y.value+.4,height:Y.value+.4,class:`dl-mnist__ink`,style:s({opacity:t.v})},null,12,I))),128))]),u(`text`,{x:J.x+J.size/2,y:`312`,"text-anchor":`middle`,class:`dl-mnist__cap`},n(b.size)+` × `+n(b.size)+` greyscale image `,9,L),r[10]||=u(`line`,{x1:`128`,y1:`244`,x2:`182`,y2:`244`,"marker-end":`url(#dl-mnist-arrow)`,class:`dl-mnist__arrow`},null,-1),r[11]||=u(`text`,{x:`155`,y:`234`,"text-anchor":`middle`,class:`dl-mnist__op`},`reshape`,-1),u(`rect`,a(X.input,{class:`dl-mnist__bar`}),null,16),u(`text`,{x:X.input.x+7,y:`356`,"text-anchor":`middle`,class:`dl-mnist__cap`},n(x.value)+` inputs`,9,R),u(`text`,{x:X.input.x+7,y:`370`,"text-anchor":`middle`,class:`dl-mnist__sub`},`one per pixel`,8,z),r[12]||=u(`line`,{x1:`218`,y1:`244`,x2:`298`,y2:`244`,"marker-end":`url(#dl-mnist-arrow)`,class:`dl-mnist__arrow`},null,-1),r[13]||=u(`text`,{x:`258`,y:`222`,"text-anchor":`middle`,class:`dl-mnist__op`},`net input`,-1),r[14]||=u(`text`,{x:`258`,y:`234`,"text-anchor":`middle`,class:`dl-mnist__op`},`+ sigmoid`,-1),u(`rect`,a(X.hidden,{class:`dl-mnist__bar is-live`}),null,16),u(`text`,{x:X.hidden.x+7,y:`356`,"text-anchor":`middle`,class:`dl-mnist__cap`},`hidden layer`,8,B),u(`text`,{x:X.hidden.x+7,y:`370`,"text-anchor":`middle`,class:`dl-mnist__sub`},n(b.hidden)+` units`,9,V),r[15]||=u(`line`,{x1:`330`,y1:`244`,x2:`410`,y2:`244`,"marker-end":`url(#dl-mnist-arrow)`,class:`dl-mnist__arrow`},null,-1),r[16]||=u(`text`,{x:`370`,y:`222`,"text-anchor":`middle`,class:`dl-mnist__op`},`net input`,-1),r[17]||=u(`text`,{x:`370`,y:`234`,"text-anchor":`middle`,class:`dl-mnist__op`},`+ sigmoid`,-1),u(`rect`,a(X.output,{class:`dl-mnist__bar is-live`}),null,16),u(`text`,{x:X.output.x+7,y:`356`,"text-anchor":`middle`,class:`dl-mnist__cap`},`output layer`,8,H),u(`text`,{x:X.output.x+7,y:`370`,"text-anchor":`middle`,class:`dl-mnist__sub`},n(b.classes)+` units`,9,U),r[18]||=_(`<line x1="440" y1="208" x2="492" y2="178" class="dl-mnist__leader" data-v-8c4f21b8></line><text x="498" y="170" class="dl-mnist__cap" data-v-8c4f21b8>class-membership</text><text x="498" y="184" class="dl-mnist__cap" data-v-8c4f21b8>probabilities</text><text x="498" y="202" class="dl-mnist__sub" data-v-8c4f21b8>compared with the one-hot</text><text x="498" y="214" class="dl-mnist__sub" data-v-8c4f21b8>target to give the loss</text>`,5),u(`text`,W,n((x.value*b.hidden+b.hidden*b.classes).toLocaleString())+` weights `,1),u(`text`,G,` + `+n((b.hidden+b.classes).toLocaleString())+` biases — every one of them learned `,1)],8,E))}}),[[`__scopeId`,`data-v-8c4f21b8`]]),Y={class:`slidev-layout dl-figure`},X={key:0,class:`dl-figure__title`},Z={class:`dl-figure__footer`},Q={class:`dl-figure__caption`},$={class:`dl-figure__citation`},ee=x(c({__name:`figure`,props:{heading:{},maxHeight:{}},setup(r){let{$slidev:i,$nav:a,$clicksContext:o,$clicks:c,$page:f,$renderContext:p,$frontmatter:m}=S(),h=r;return(r,i)=>{let a=w;return e(),d(`div`,Y,[h.heading?(e(),d(`h1`,X,n(h.heading),1)):y(`v-if`,!0),u(`div`,{class:`dl-figure__canvas`,style:s({maxHeight:h.maxHeight})},[l(r.$slots,`default`,{},void 0,!0)],4),u(`div`,Z,[u(`div`,Q,[l(r.$slots,`caption`,{},void 0,!0)]),u(`div`,$,[l(r.$slots,`citation`,{},void 0,!0)])]),t(a)])}}}),[[`__scopeId`,`data-v-8876733c`]]),te={__name:`slides.md__slidev_30`,setup(n){let{$slidev:i,$nav:a,$clicksContext:s,$clicks:c,$page:l,$renderContext:d,$frontmatter:f}=S();return s.setup(),(n,i)=>{let a=J,s=T;return e(),g(ee,v(r(b(C)(b(f),29))),{caption:p(e=>[...i[0]||=[u(`p`,null,[o(`70 000 handwritten digits, 28×28 pixels, grey-scale. One sample is a `),u(`strong`,null,`tensor`),o(` of shape `),u(`code`,null,`(1, 28, 28)`),o(` and an `),u(`strong`,null,`integer`),o(` label 0–9, not a one-hot vector.`)],-1)]]),citation:p(e=>[t(s,{source:`LeCun, Cortes & Burges, The MNIST database`,url:`https://yann.lecun.com/exdb/mnist/`})]),default:p(()=>[t(a)]),_:1},16)}}};export{te as default};
lecture-03/assets/md-Cw0ZpuKK.js ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ import{B as e,C as t,D as n,G as r,S as i,_ as a,b as o,et as s,tt as c,v as l,xt as u,yt as d}from"./modules/shiki-CJZsCeMT.js";import{n as f,t as p}from"./slidev/context-DB-9afGB.js";import{t as m}from"./slidev/CodeBlockWrapper-DqFdVwPK.js";import{t as h}from"./default-IV3yhGVf.js";import{t as g}from"./slidev/VClicks-DYiBHOPb.js";var _={class:`grid grid-cols-2 gap-8 mt-2`},v={class:`dl-callout`},y={class:`mt-3 dl-secondary`},b={__name:`slides.md__slidev_11`,setup(b){let{$slidev:x,$nav:S,$clicksContext:C,$clicks:w,$page:T,$renderContext:E,$frontmatter:D}=f();return C.setup(),(f,b)=>{let x=g,S=m,C=r(`click`);return e(),l(h,u(n(d(p)(d(D),10))),{default:s(()=>[b[4]||=a(`h1`,null,[a(`code`,null,`dtype`),i(`, and the two that bite`)],-1),a(`div`,_,[a(`div`,null,[t(x,null,{default:s(()=>[...b[0]||=[a(`ul`,null,[a(`li`,null,[a(`strong`,null,[a(`code`,null,`torch.float32`)]),i(` — every image, every weight, every activation. The default for `),a(`code`,null,`randn`),i(`, `),a(`code`,null,`zeros`),i(` and float lists`)]),a(`li`,null,[a(`strong`,null,[a(`code`,null,`torch.int64`)]),i(` — class labels, and only class labels. The default for integer lists`)]),a(`li`,null,[a(`code`,null,`torch.float64`),i(` exists and you never want it: twice the memory, slow on a GPU`)])],-1)]]),_:1})]),a(`div`,null,[c((e(),o(`div`,v,[t(S,{title:``,ranges:[]},{default:s(()=>[...b[1]||=[a(`pre`,{class:`shiki shiki-themes vitesse-dark vitesse-light slidev-code`,style:{"--shiki-dark":`#dbd7caee`,"--shiki-light":`#393a34`,"--shiki-dark-bg":`#121212`,"--shiki-light-bg":`#ffffff`}},[a(`code`,{class:`language-text`},[a(`span`,{class:`line`},[a(`span`,null,`RuntimeError: expected scalar type`)]),i(`
2
+ `),a(`span`,{class:`line`},[a(`span`,null,`Long but found Float`)])])],-1)]]),_:1}),b[2]||=a(`p`,null,[a(`code`,null,`nn.CrossEntropyLoss`),i(` wants labels as `),a(`strong`,null,`integers`),i(`, not as floats and not one-hot. `),a(`code`,null,`.long()`),i(` fixes it.`)],-1)])),[[C]]),c((e(),o(`div`,y,[...b[3]||=[a(`p`,null,[i(`The mirror image — `),a(`code`,null,`... Float but found Long`),i(` — means an integer tensor stayed integral. `),a(`code`,null,`.float()`),i(` fixes it.`)],-1)]])),[[C]])])])]),_:1},16)}}};export{b as default};
lecture-03/assets/md-CxLxpOf2.js ADDED
@@ -0,0 +1 @@
 
 
1
+ import{B as e,C as t,D as n,G as r,S as i,_ as a,b as o,et as s,tt as c,v as l,xt as u,yt as d}from"./modules/shiki-CJZsCeMT.js";import{n as f,t as p}from"./slidev/context-DB-9afGB.js";import{t as m}from"./interactive-CBN7ZXLe.js";import{t as h}from"./ConfusionMatrix-CloAXvtZ.js";var g={class:`mt-3 dl-callout`},_={__name:`slides.md__slidev_41`,setup(_){let{$slidev:v,$nav:y,$clicksContext:b,$clicks:x,$page:S,$renderContext:C,$frontmatter:w}=f();return b.setup(),(f,_)=>{let v=h,y=r(`click`);return e(),l(m,u(n(d(p)(d(w),40))),{aside:s(t=>[_[1]||=a(`div`,null,[a(`p`,null,[a(`strong`,null,`precision`),i(` — when it said 9, was it right?`)]),a(`p`,null,[a(`strong`,null,`recall`),i(` — of the real 9s, how many did it find?`)])],-1),_[2]||=a(`div`,{class:`mt-3 dl-secondary`},[a(`p`,null,`The same 100 numbers, read two ways. F1 (their harmonic mean) combines them.`)],-1),c((e(),o(`div`,g,[..._[0]||=[a(`p`,null,[i(`Report this table, not just the accuracy — three lines with `),a(`code`,null,`classification_report`),i(`.`)],-1)]])),[[y]])]),default:s(()=>[t(v,{mode:`metrics`})]),_:1},16)}}};export{_ as default};
lecture-03/assets/md-CyDkwqZf.js ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ import{B as e,C as t,D as n,G as r,N as i,S as a,_ as o,b as s,et as c,tt as l,v as u,xt as d,yt as f}from"./modules/shiki-CJZsCeMT.js";import{n as p,t as m}from"./slidev/context-DB-9afGB.js";import{t as h}from"./slidev/CodeBlockWrapper-DqFdVwPK.js";import{t as g}from"./default-IV3yhGVf.js";import{t as _}from"./slidev/VClicks-DYiBHOPb.js";var v={class:`mt-4 dl-callout`},y={__name:`slides.md__slidev_19`,setup(y){let{$slidev:b,$nav:x,$clicksContext:S,$clicks:C,$page:w,$renderContext:T,$frontmatter:E}=p();return S.setup(),(p,y)=>{let b=h,x=_,S=r(`click`);return e(),u(g,d(n(f(m)(f(E),18))),{default:c(()=>[y[3]||=o(`h1`,null,`Devices`,-1),t(b,i({lines:!0},{title:``,ranges:[`all`,`1`,`3-5`,`all`]}),{default:c(()=>[...y[0]||=[o(`pre`,{class:`shiki shiki-themes vitesse-dark vitesse-light slidev-code`,style:{"--shiki-dark":`#dbd7caee`,"--shiki-light":`#393a34`,"--shiki-dark-bg":`#121212`,"--shiki-light-bg":`#ffffff`}},[o(`code`,{class:`language-python`},[o(`span`,{class:`line`},[o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},`device `),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`=`),o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},` torch`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`.`),o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},`device`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`(`),o(`span`,{style:{"--shiki-dark":`#C98A7D77`,"--shiki-light":`#B5695977`}},`"`),o(`span`,{style:{"--shiki-dark":`#C98A7D`,"--shiki-light":`#B56959`}},`cuda`),o(`span`,{style:{"--shiki-dark":`#C98A7D77`,"--shiki-light":`#B5695977`}},`"`),o(`span`,{style:{"--shiki-dark":`#4D9375`,"--shiki-light":`#1E754F`}},` if`),o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},` torch`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`.`),o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},`cuda`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`.`),o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},`is_available`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`()`),o(`span`,{style:{"--shiki-dark":`#4D9375`,"--shiki-light":`#1E754F`}},` else`),o(`span`,{style:{"--shiki-dark":`#C98A7D77`,"--shiki-light":`#B5695977`}},` "`),o(`span`,{style:{"--shiki-dark":`#C98A7D`,"--shiki-light":`#B56959`}},`cpu`),o(`span`,{style:{"--shiki-dark":`#C98A7D77`,"--shiki-light":`#B5695977`}},`"`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`)`)]),a(`
2
+ `),o(`span`,{class:`line`}),a(`
3
+ `),o(`span`,{class:`line`},[o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},`model `),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`=`),o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},` model`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`.`),o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},`to`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`(`),o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},`device`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`)`),o(`span`,{style:{"--shiki-dark":`#758575DD`,"--shiki-light":`#A0ADA0`}},` # moves the parameters, in place`)]),a(`
4
+ `),o(`span`,{class:`line`},[o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},`images `),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`=`),o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},` images`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`.`),o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},`to`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`(`),o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},`device`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`)`),o(`span`,{style:{"--shiki-dark":`#758575DD`,"--shiki-light":`#A0ADA0`}},` # returns a *new* tensor on the device`)]),a(`
5
+ `),o(`span`,{class:`line`},[o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},`labels `),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`=`),o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},` labels`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`.`),o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},`to`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`(`),o(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},`device`),o(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`)`)])])],-1)]]),_:1},16),t(x,null,{default:c(()=>[...y[1]||=[o(`ul`,null,[o(`li`,null,[a(`One line at the top of the notebook, then `),o(`code`,null,`.to(device)`),a(` on the model and on every batch`)]),o(`li`,null,[o(`strong`,null,`A model and its input must be on the same device.`),a(` Nothing else about your code changes`)])],-1)]]),_:1}),l((e(),s(`div`,v,[t(b,{title:``,ranges:[]},{default:c(()=>[...y[2]||=[o(`pre`,{class:`shiki shiki-themes vitesse-dark vitesse-light slidev-code`,style:{"--shiki-dark":`#dbd7caee`,"--shiki-light":`#393a34`,"--shiki-dark-bg":`#121212`,"--shiki-light-bg":`#ffffff`}},[o(`code`,{class:`language-text`},[o(`span`,{class:`line`},[o(`span`,null,`RuntimeError: Expected all tensors to be on the same device,`)]),a(`
6
+ `),o(`span`,{class:`line`},[o(`span`,null,`but found at least two devices, cuda:0 and cpu!`)])])],-1)]]),_:1})])),[[S]])]),_:1},16)}}};export{y as default};
lecture-03/assets/md-D1FObvji.js ADDED
@@ -0,0 +1 @@
 
 
1
+ import{B as e,C as t,D as n,G as r,S as i,_ as a,b as o,et as s,tt as c,v as l,xt as u,yt as d}from"./modules/shiki-CJZsCeMT.js";import{n as f,t as p}from"./slidev/context-DB-9afGB.js";import{t as m}from"./interactive-CBN7ZXLe.js";import{t as h}from"./AutogradGraph-D9pug6h-.js";var g={class:`mt-3 dl-callout`},_={__name:`slides.md__slidev_25`,setup(_){let{$slidev:v,$nav:y,$clicksContext:b,$clicks:x,$page:S,$renderContext:C,$frontmatter:w}=f();return b.setup(),(f,_)=>{let v=h,y=r(`click`);return e(),l(m,u(n(d(p)(d(w),24))),{aside:s(t=>[_[1]||=a(`p`,null,[a(`code`,null,`.grad`),i(` is `),a(`strong`,null,`added into`),i(`, never overwritten.`)],-1),_[2]||=a(`div`,{class:`mt-2 dl-secondary`},[a(`p`,null,[i(`Press `),a(`code`,null,`loss.backward()`),i(` twice without zeroing, and the gradient is twice what it should be. The optimiser steps twice too far, the loss stops falling, and nothing errors.`)])],-1),c((e(),o(`div`,g,[..._[0]||=[a(`p`,null,`Hence one line in every training loop:`,-1),a(`p`,null,[a(`code`,null,`optimiser.zero_grad()`)],-1)]])),[[y]])]),default:s(()=>[t(v,{mode:`accumulate`})]),_:1},16)}}};export{_ as default};
lecture-03/assets/md-D7KY7dJ8.css ADDED
@@ -0,0 +1 @@
 
 
1
+ .dl-plot[data-v-515e2759]{width:100%;height:100%;font-family:inherit;overflow:visible}.dl-plot__grid line[data-v-515e2759]{stroke:var(--dl-border);stroke-width:1px}.dl-plot__axes line[data-v-515e2759]{stroke:var(--dl-muted);stroke-width:1.5px}.dl-plot__ticks line[data-v-515e2759]{stroke:var(--dl-muted);stroke-width:1px}.dl-plot__ticks text[data-v-515e2759]{fill:var(--dl-muted);font-variant-numeric:tabular-nums;font-size:11px}.dl-plot__label[data-v-515e2759]{fill:var(--dl-body);font-size:12px}.dl-lc__tab[data-v-ca520819]{border:1px solid var(--dl-border);font:inherit;color:var(--dl-body);cursor:pointer;background:0 0;border-radius:6px;padding:.24rem .66rem;font-size:.78rem}.dl-lc__tab[data-v-ca520819]:hover{border-color:var(--dl-accent);color:var(--dl-accent)}.dl-lc__tab.is-active[data-v-ca520819]{background:var(--dl-accent);border-color:var(--dl-accent);color:#fff;font-weight:600}.dl-lc__tab[data-v-ca520819]:focus-visible{outline:2px solid var(--dl-accent);outline-offset:2px}.dl-lc__sep[data-v-ca520819]{background:var(--dl-border);width:1px;height:1.1rem}.dl-lc__legend[data-v-ca520819]{flex-wrap:wrap;align-items:center;gap:.2rem 1.1rem;margin-bottom:.2rem;display:flex}.dl-lc__legend i[data-v-ca520819]{vertical-align:middle;border-top-width:2.4px;width:1.1rem;height:0;margin-right:.35rem;display:inline-block}.dl-lc__legend i.is-train[data-v-ca520819]{border-top-style:solid;border-top-color:var(--dl-accent)}.dl-lc__legend i.is-val[data-v-ca520819]{border-top-style:dashed;border-top-color:var(--dl-heading)}.dl-lc__legend strong[data-v-ca520819]{color:var(--dl-accent);font-variant-numeric:tabular-nums}.dl-lc__note[data-v-ca520819]{line-height:1.35}
lecture-03/assets/md-DE2QGCpb.css ADDED
@@ -0,0 +1 @@
 
 
1
+ .dl-end[data-v-f8d31aa3]{text-align:center;flex-direction:column;justify-content:center;align-items:center;gap:1.2rem;display:flex}.dl-end__body[data-v-f8d31aa3] h1{font-size:var(--dl-fs-section);margin:0}.dl-end__meta[data-v-f8d31aa3]{font-size:var(--dl-fs-secondary);color:var(--dl-muted);gap:1.4rem;display:flex}
lecture-03/assets/md-DEacZnAz2.js ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ import{B as e,C as t,D as n,N as r,S as i,_ as a,et as o,v as s,xt as c,yt as l}from"./modules/shiki-CJZsCeMT.js";import{n as u,t as d}from"./slidev/context-DB-9afGB.js";import{t as f}from"./slidev/CodeBlockWrapper-DqFdVwPK.js";import{t as p}from"./default-IV3yhGVf.js";import{t as m}from"./slidev/VClicks-DYiBHOPb.js";var h={class:`grid grid-cols-2 gap-8 mt-4`},g={__name:`slides.md__slidev_36`,setup(g){let{$slidev:_,$nav:v,$clicksContext:y,$clicks:b,$page:x,$renderContext:S,$frontmatter:C}=u();return y.setup(),(u,g)=>{let _=f,v=m;return e(),s(p,c(n(l(d)(l(C),35))),{default:o(()=>[g[3]||=a(`h1`,null,`Loss and optimiser`,-1),t(_,r({lines:!0},{title:``,ranges:[`all`,`1`,`3`,`4`,`all`]}),{default:o(()=>[...g[0]||=[a(`pre`,{class:`shiki shiki-themes vitesse-dark vitesse-light slidev-code`,style:{"--shiki-dark":`#dbd7caee`,"--shiki-light":`#393a34`,"--shiki-dark-bg":`#121212`,"--shiki-light-bg":`#ffffff`}},[a(`code`,{class:`language-python`},[a(`span`,{class:`line`},[a(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},`loss_fn `),a(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`=`),a(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},` nn`),a(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`.`),a(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},`CrossEntropyLoss`),a(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`()`),a(`span`,{style:{"--shiki-dark":`#758575DD`,"--shiki-light":`#A0ADA0`}},` # logits in, integer labels in, one scalar out`)]),i(`
2
+ `),a(`span`,{class:`line`}),i(`
3
+ `),a(`span`,{class:`line`},[a(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},`optimiser `),a(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`=`),a(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},` torch`),a(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`.`),a(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},`optim`),a(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`.`),a(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},`SGD`),a(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`(`),a(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},`model`),a(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`.`),a(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},`parameters`),a(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`(),`),a(`span`,{style:{"--shiki-dark":`#BD976A`,"--shiki-light":`#B07D48`}},` lr`),a(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`=`),a(`span`,{style:{"--shiki-dark":`#4C9A91`,"--shiki-light":`#2F798A`}},`0.1`),a(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`)`),a(`span`,{style:{"--shiki-dark":`#758575DD`,"--shiki-light":`#A0ADA0`}},` # Lecture 02's rule`)]),i(`
4
+ `),a(`span`,{class:`line`},[a(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},`optimiser `),a(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`=`),a(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},` torch`),a(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`.`),a(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},`optim`),a(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`.`),a(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},`Adam`),a(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`(`),a(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},`model`),a(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`.`),a(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},`parameters`),a(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`(),`),a(`span`,{style:{"--shiki-dark":`#BD976A`,"--shiki-light":`#B07D48`}},` lr`),a(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`=`),a(`span`,{style:{"--shiki-dark":`#4C9A91`,"--shiki-light":`#2F798A`}},`1e-3`),a(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`)`),a(`span`,{style:{"--shiki-dark":`#758575DD`,"--shiki-light":`#A0ADA0`}},` # a per-parameter step size`)])])],-1)]]),_:1},16),a(`div`,h,[a(`div`,null,[t(v,null,{default:o(()=>[...g[1]||=[a(`ul`,null,[a(`li`,null,[a(`strong`,null,[a(`code`,null,`model.parameters()`)]),i(` is the handle. The optimiser holds references to the same tensors the model uses`)]),a(`li`,null,[a(`strong`,null,[a(`code`,null,`lr`)]),i(` is the single most important number in the file. Too big diverges, too small crawls`)])],-1)]]),_:1})]),a(`div`,null,[t(v,null,{default:o(()=>[...g[2]||=[a(`ul`,null,[a(`li`,null,[a(`strong`,null,`SGD`),i(` (stochastic gradient descent) is exactly the update from Lecture 02: subtract `),a(`code`,null,`lr`),i(` times the gradient`)]),a(`li`,null,[a(`strong`,null,`Adam`),i(` keeps a running scale per parameter, so it needs far less tuning. Start with `),a(`code`,null,`Adam(lr=1e-3)`)])],-1)]]),_:1})])])]),_:1},16)}}};export{g as default};
lecture-03/assets/md-DLy5QXlk.css ADDED
@@ -0,0 +1 @@
 
 
1
+ .dl-fcnn[data-v-1f9f310f]{flex-direction:column;gap:.15rem;width:100%;display:flex}.dl-fcnn__chain[data-v-1f9f310f]{justify-content:space-between;align-items:center;gap:.3rem;display:flex}.dl-fcnn__pill[data-v-1f9f310f]{text-align:center;border:1.5px solid var(--dl-accent);background:var(--dl-accent-soft);color:var(--dl-heading);font-variant-numeric:tabular-nums;border-radius:6px;flex:none;padding:.4rem .2rem;font-size:1rem;font-weight:700}.dl-fcnn__pill.is-input[data-v-1f9f310f]{border-color:var(--dl-border);background:var(--dl-surface)}.dl-fcnn__pill.is-output[data-v-1f9f310f]{background:var(--dl-accent);border-color:var(--dl-accent-strong);color:#fff}.dl-fcnn__arrow[data-v-1f9f310f]{min-width:0;color:var(--dl-muted);white-space:nowrap;flex:auto;justify-content:center;align-items:center;gap:.3rem;font-size:.72rem;display:flex}.dl-fcnn__arrow span[data-v-1f9f310f]{font-family:var(--slidev-code-font-family,monospace)}.dl-fcnn__arrow em[data-v-1f9f310f]{color:var(--dl-accent);font-size:1rem;font-style:normal}.dl-fcnn__roles[data-v-1f9f310f]{color:var(--dl-muted);justify-content:space-between;margin-bottom:.5rem;font-size:.66rem;display:flex}.dl-fcnn__ledger[data-v-1f9f310f]{border-collapse:collapse;width:100%;color:var(--dl-body);font-size:.8rem}.dl-fcnn__ledger th[data-v-1f9f310f]{text-align:left;color:var(--dl-muted);text-transform:uppercase;letter-spacing:.04em;border-bottom:1px solid var(--dl-border);padding:0 .6rem .15rem 0;font-size:.62rem;font-weight:600}.dl-fcnn__ledger td[data-v-1f9f310f]{vertical-align:baseline;font-variant-numeric:tabular-nums;padding:.12rem .6rem .12rem 0}.dl-fcnn__ledger td.is-num[data-v-1f9f310f]{text-align:right;color:var(--dl-heading);font-weight:600}.dl-fcnn__ledger code[data-v-1f9f310f]{color:var(--dl-heading);font-size:.78rem}.dl-fcnn__ledger tr.is-free[data-v-1f9f310f],.dl-fcnn__ledger tr.is-free code[data-v-1f9f310f],.dl-fcnn__ledger tr.is-free td.is-num[data-v-1f9f310f]{color:var(--dl-muted)}.dl-fcnn__ledger small[data-v-1f9f310f]{color:var(--dl-muted);white-space:nowrap;margin-left:.4rem;font-size:.66rem}.dl-fcnn__bar[data-v-1f9f310f]{background:var(--dl-surface);border:1px solid var(--dl-border);vertical-align:middle;border-radius:2px;width:16%;height:.45rem;display:inline-block;overflow:hidden}.dl-fcnn__bar>span[data-v-1f9f310f]{background:var(--dl-accent);height:100%;display:block}.dl-fcnn__ledger tfoot td[data-v-1f9f310f]{border-top:1px solid var(--dl-border);color:var(--dl-accent);padding-top:.25rem;font-weight:700}.dl-fcnn__ledger tfoot td[data-v-1f9f310f]:last-child{color:var(--dl-muted);font-size:.72rem;font-weight:400}.dl-fcnn__facts[data-v-1f9f310f]{flex-wrap:wrap;gap:.2rem 1.2rem;margin-bottom:.2rem;display:flex}.dl-fcnn__facts strong[data-v-1f9f310f]{color:var(--dl-accent)}.dl-fcnn__facts code[data-v-1f9f310f],.dl-fcnn__note code[data-v-1f9f310f]{background:var(--dl-code-bg);border-radius:3px;padding:.05rem .22rem;font-size:.72rem}.dl-fcnn__note[data-v-1f9f310f]{line-height:1.35}
lecture-03/assets/md-DSqY0rZq.js ADDED
@@ -0,0 +1 @@
 
 
1
+ import{B as e,C as t,Ct as n,D as r,H as i,S as a,T as o,_ as s,b as c,bt as l,dt as u,et as d,g as f,m as p,v as m,xt as h,yt as g}from"./modules/shiki-CJZsCeMT.js";import{t as _}from"./_plugin-vue_export-helper-BDNMzG2s.js";import{n as v,t as y}from"./slidev/context-DB-9afGB.js";import{t as b}from"./WidgetFrame-DHgK6j2H.js";import{n as x,r as S}from"./useTensorLayout-BsTHvbKs.js";import{t as C}from"./interactive-CBN7ZXLe.js";var w=[`viewBox`,`aria-label`],ee={class:`dl-slicer__head`},te=[`x`,`y`],ne=[`x`,`y`],re={class:`dl-slicer__grid`},T=[`x`,`y`],E=[`x`,`y`],D={class:`dl-slicer__arrow`},O=[`x1`,`y1`,`x2`,`y2`],k=[`d`],ie=[`x`,`y`],A={class:`dl-slicer__grid is-result`},j=[`x`,`y`,`width`,`height`],M=[`x`,`y`],N=[`onClick`],P={class:`dl-slicer__facts`},F={class:`dl-slicer__note`},I=4,L=6,R=30,z=3,B=15,V=_(o({__name:`TensorSlicer`,setup(t){let{$slidev:r,$nav:o,$clicksContext:h,$clicks:_,$page:y,$renderContext:C,$frontmatter:V}=v(),H=[{expr:`t[1]`,rowSpec:{kind:`int`,i:1},colSpec:{kind:`all`},note:"One integer picks row 1 and the row axis disappears. The result is 1-D — the same thing as `t[1, :]`, which is what PyTorch fills in for you."},{expr:`t[1:2]`,rowSpec:{kind:`slice`,a:1,b:2},colSpec:{kind:`all`},note:"The same six numbers as `t[1]`, but a slice keeps its axis, so this is 2-D with a length-1 first dimension. This is the one that bites."},{expr:`t[:, 2]`,rowSpec:{kind:`all`},colSpec:{kind:`int`,i:2},note:`A colon means "every index along this axis". Column 2 of every row — one number per sample, which is how you pull a single feature out of a batch.`},{expr:`t[1:3, 2:5]`,rowSpec:{kind:`slice`,a:1,b:3},colSpec:{kind:`slice`,a:2,b:5},note:`Slices on both axes: rows 1 and 2, columns 2, 3 and 4. The stop index is never included, so 1:3 is two rows, not three.`},{expr:`t[:, -1]`,rowSpec:{kind:`all`},colSpec:{kind:`int`,i:5},note:`Negative indices count from the end, so -1 is the last column. Handy, and the reason an off-by-one bug can silently return real numbers.`},{expr:`t[0, 0]`,rowSpec:{kind:`int`,i:0},colSpec:{kind:`int`,i:0},note:"Both axes indexed with integers, so both disappear: the result is a 0-D tensor. Call `.item()` on it to get a Python float."}],U=u(0),W=f(()=>H[U.value]);function G(e,t){return e.kind===`int`?[e.i]:e.kind===`all`?Array.from({length:t},(e,t)=>t):Array.from({length:e.b-e.a},(t,n)=>e.a+n)}let K=f(()=>G(W.value.rowSpec,I)),q=f(()=>G(W.value.colSpec,L)),J=f(()=>{let e=[];return W.value.rowSpec.kind!==`int`&&e.push(K.value.length),W.value.colSpec.kind!==`int`&&e.push(q.value.length),e}),Y=f(()=>K.value.flatMap(e=>q.value.map(t=>10*e+t))),ae=f(()=>{let e=[];for(let t=0;t<I;t++)for(let n=0;n<L;n++)e.push({r:t,c:n,x:B+n*33,y:B+t*33,v:10*t+n,on:K.value.includes(t)&&q.value.includes(n)});return e}),X=f(()=>S(J.value,{cell:R,gap:z,framePad:0})),Z=f(()=>256),oe=f(()=>X.value.cells.map(e=>({...e,x:e.x+Z.value,y:e.y+B+Math.max(0,(129-X.value.height)/2),v:Y.value[e.flat]}))),Q=f(()=>({w:Z.value+Math.max(X.value.width,R)+8,h:152})),$=f(()=>79.5);return(t,r)=>{let o=b;return e(),m(o,{"max-width":`44rem`},{controls:d(()=>[(e(),c(p,null,i(H,(e,t)=>s(`button`,{key:e.expr,type:`button`,class:l([`dl-slicer__tab`,{"is-active":t===U.value}]),onClick:e=>U.value=t},n(e.expr),11,N)),64))]),readout:d(()=>[s(`div`,P,[s(`span`,null,[r[0]||=a(`result `,-1),s(`strong`,null,n(g(x)(J.value)),1)]),s(`span`,null,n(Y.value.length)+` element`+n(Y.value.length===1?``:`s`),1),s(`span`,null,[r[1]||=a(`rank 2 `,-1),r[2]||=s(`span`,{"aria-hidden":`true`},`→`,-1),a(` rank `+n(J.value.length),1)])]),s(`div`,F,n(W.value.note),1)]),default:d(()=>[(e(),c(`svg`,{class:`dl-slicer`,viewBox:`0 0 ${Q.value.w} ${Q.value.h}`,preserveAspectRatio:`xMidYMid meet`,role:`img`,"aria-label":`${W.value.expr} selects ${Y.value.length} elements and returns shape ${g(x)(J.value)}`},[s(`g`,ee,[(e(),c(p,null,i(L,e=>s(`text`,{key:`c${e}`,x:B+(e-1)*33+R/2,y:11,"text-anchor":`middle`},n(e-1),9,te)),64)),(e(),c(p,null,i(I,e=>s(`text`,{key:`r${e}`,x:11,y:B+(e-1)*33+R/2+4,"text-anchor":`end`},n(e-1),9,ne)),64))]),s(`g`,re,[(e(!0),c(p,null,i(ae.value,t=>(e(),c(`g`,{key:`${t.r}-${t.c}`,class:l({"is-on":t.on})},[s(`rect`,{x:t.x,y:t.y,width:R,height:R,rx:`3`},null,8,T),s(`text`,{x:t.x+R/2,y:t.y+R/2+4,"text-anchor":`middle`},n(t.v),9,E)],2))),128))]),s(`g`,D,[s(`line`,{x1:220,y1:$.value,x2:Z.value-10,y2:$.value},null,8,O),s(`path`,{d:`M ${Z.value-10} ${$.value} l -6 -4 v 8 z`},null,8,k),s(`text`,{x:(210+Z.value)/2,y:$.value-8,"text-anchor":`middle`},n(W.value.expr),9,ie)]),s(`g`,A,[(e(!0),c(p,null,i(oe.value,t=>(e(),c(`g`,{key:`o${t.flat}`,class:`is-on`},[s(`rect`,{x:t.x,y:t.y,width:t.w,height:t.h,rx:`3`},null,8,j),s(`text`,{x:t.x+t.w/2,y:t.y+t.h/2+4,"text-anchor":`middle`},n(t.v),9,M)]))),128))])],8,w))]),_:1})}}}),[[`__scopeId`,`data-v-7d62ffa3`]]),H={__name:`slides.md__slidev_12`,setup(n){let{$slidev:i,$nav:o,$clicksContext:c,$clicks:l,$page:u,$renderContext:f,$frontmatter:p}=v();return c.setup(),(n,i)=>{let o=V;return e(),m(C,h(r(g(y)(g(p),11))),{aside:d(e=>[...i[0]||=[s(`p`,null,`Same syntax as NumPy, same syntax as Python lists.`,-1),s(`div`,{class:`mt-2 dl-callout`},[s(`p`,null,[a(`An integer index `),s(`strong`,null,`removes`),a(` an axis. A slice `),s(`strong`,null,`keeps`),a(` it.`)])],-1),s(`div`,{class:`mt-3 dl-secondary`},[s(`p`,null,[a(`Compare `),s(`code`,null,`t[1]`),a(` with `),s(`code`,null,`t[1:2]`),a(`: same six numbers, different ranks. That difference is what makes a broadcast fail three lines later.`)])],-1)]]),default:d(()=>[t(o)]),_:1},16)}}};export{H as default};
lecture-03/assets/md-DV4Jznr4.js ADDED
@@ -0,0 +1 @@
 
 
1
+ import{B as e,D as t,_ as n,et as r,v as i,xt as a,yt as o}from"./modules/shiki-CJZsCeMT.js";import{n as s,t as c}from"./slidev/context-DB-9afGB.js";import{t as l}from"./section-CqA-0pFf.js";var u={__name:`slides.md__slidev_21`,setup(u){let{$slidev:d,$nav:f,$clicksContext:p,$clicks:m,$page:h,$renderContext:g,$frontmatter:_}=s();return p.setup(),(s,u)=>(e(),i(l,a(t(o(c)(o(_),20))),{default:r(()=>[...u[0]||=[n(`h1`,null,`Autograd`,-1)]]),_:1},16))}};export{u as default};
lecture-03/assets/md-DcE0WCje.js ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ import{A as e,B as t,C as n,Ct as r,D as i,G as a,H as o,S as s,St as c,T as l,U as u,V as d,_ as f,b as p,bt as m,dt as h,et as g,g as _,gt as v,m as y,q as b,tt as x,v as S,xt as C,y as w,yt as T}from"./modules/shiki-CJZsCeMT.js";import{t as E}from"./_plugin-vue_export-helper-BDNMzG2s.js";import{n as D,t as O}from"./slidev/context-DB-9afGB.js";import{t as k}from"./WidgetFrame-DHgK6j2H.js";import{t as A}from"./interactive-CBN7ZXLe.js";import{t as j}from"./StepButton-DD4XxENU.js";import{t as M}from"./Slider-C2M0Z0oG.js";import{t as N}from"./useRandom-C9hJeQcV.js";var P=Symbol(`dl-plot`);function F(){let t=e(P,null);if(!t)throw Error(`This component must be used inside a <Plot2D>`);return t}function I(e,t,n=6){if(!Number.isFinite(e)||!Number.isFinite(t)||e===t)return[e];let r=(t-e)/Math.max(n,1),i=10**Math.floor(Math.log10(r)),a=r/i,o=(a>=5?10:a>=2?5:a>=1?2:1)*i,s=[],c=Math.ceil(e/o)*o;for(let e=c;e<=t+o*1e-9;e+=o)s.push(Math.abs(e)<o*1e-9?0:e);return s}function L(e){if(e===0)return`0`;let t=Math.abs(e);return t>=1e5||t<1e-4?e.toExponential(0):String(Number(e.toFixed(6)))}var R=[`viewBox`],z={key:0,class:`dl-plot__grid`},B=[`x1`,`x2`,`y1`,`y2`],ee=[`x1`,`x2`,`y1`,`y2`],te={class:`dl-plot__axes`},ne=[`x1`,`x2`,`y1`,`y2`],re=[`x1`,`x2`,`y1`,`y2`],ie={class:`dl-plot__ticks`},V=[`x1`,`x2`,`y1`,`y2`],H=[`x`,`y`],U=[`x1`,`x2`,`y1`,`y2`],W=[`x`,`y`],G=[`x`,`y`,`width`,`height`],K=[`clip-path`],q=[`x`,`y`],J=[`x`],Y=E(l({__name:`Plot2D`,props:{xDomain:{default:()=>[0,1]},yDomain:{default:()=>[0,1]},width:{default:520},height:{default:320},xLabel:{},yLabel:{},xTicks:{default:6},yTicks:{default:5},grid:{type:Boolean,default:!0},originAxes:{type:Boolean,default:!1},padding:{}},setup(e,{expose:n}){let{$slidev:i,$nav:a,$clicksContext:s,$clicks:c,$page:l,$renderContext:m,$frontmatter:g}=D(),x=e,S=_(()=>({top:x.padding?.top??14,right:x.padding?.right??16,bottom:x.padding?.bottom??(x.xLabel?42:28),left:x.padding?.left??(x.yLabel?52:40)})),C=_(()=>({x:S.value.left,y:S.value.top,width:Math.max(x.width-S.value.left-S.value.right,1),height:Math.max(x.height-S.value.top-S.value.bottom,1)})),E=e=>{let[t,n]=x.xDomain;return C.value.x+(e-t)/(n-t||1)*C.value.width},O=e=>{let[t,n]=x.yDomain;return C.value.y+(1-(e-t)/(n-t||1))*C.value.height},k=e=>{let[t,n]=x.xDomain;return t+(e-C.value.x)/C.value.width*(n-t)},A=e=>{let[t,n]=x.yDomain;return t+(1-(e-C.value.y)/C.value.height)*(n-t)};d(P,{sx:E,sy:O,ix:k,iy:A,xDomain:v(x,`xDomain`),yDomain:v(x,`yDomain`),inner:C});let j=_(()=>Array.isArray(x.xTicks)?x.xTicks:I(x.xDomain[0],x.xDomain[1],x.xTicks)),M=_(()=>Array.isArray(x.yTicks)?x.yTicks:I(x.yDomain[0],x.yDomain[1],x.yTicks)),N=_(()=>x.originAxes?O(Math.min(Math.max(0,x.yDomain[0]),x.yDomain[1])):C.value.y+C.value.height),F=_(()=>x.originAxes?E(Math.min(Math.max(0,x.xDomain[0]),x.xDomain[1])):C.value.x),Y=h(null),X=`dl-plot-clip-${b()}`;function Z(e){let t=Y.value;if(!t)return null;let n=t.getBoundingClientRect(),r=(e.clientX-n.left)/n.width*x.width,i=(e.clientY-n.top)/n.height*x.height;return{x:k(r),y:A(i)}}return n({dataAt:Z,sx:E,sy:O,ix:k,iy:A}),(e,n)=>(t(),p(`svg`,{ref_key:`svg`,ref:Y,class:`dl-plot`,viewBox:`0 0 ${x.width} ${x.height}`,preserveAspectRatio:`xMidYMid meet`,role:`img`},[x.grid?(t(),p(`g`,z,[(t(!0),p(y,null,o(j.value,e=>(t(),p(`line`,{key:`gx${e}`,x1:E(e),x2:E(e),y1:C.value.y,y2:C.value.y+C.value.height},null,8,B))),128)),(t(!0),p(y,null,o(M.value,e=>(t(),p(`line`,{key:`gy${e}`,x1:C.value.x,x2:C.value.x+C.value.width,y1:O(e),y2:O(e)},null,8,ee))),128))])):w(`v-if`,!0),f(`g`,te,[f(`line`,{x1:C.value.x,x2:C.value.x+C.value.width,y1:N.value,y2:N.value},null,8,ne),f(`line`,{x1:F.value,x2:F.value,y1:C.value.y,y2:C.value.y+C.value.height},null,8,re)]),w(`
2
+ Tick *marks* sit on the axis, which may run through the origin; tick
3
+ *labels* always sit on the frame edge. Letting labels follow a
4
+ through-origin axis buries them in the middle of the data and collides the
5
+ two zeros on top of each other.
6
+ `),f(`g`,ie,[(t(!0),p(y,null,o(j.value,e=>(t(),p(y,{key:`tx${e}`},[f(`line`,{x1:E(e),x2:E(e),y1:N.value,y2:N.value+5},null,8,V),f(`text`,{x:E(e),y:C.value.y+C.value.height+17,"text-anchor":`middle`},r(T(L)(e)),9,H)],64))),128)),(t(!0),p(y,null,o(M.value,e=>(t(),p(y,{key:`ty${e}`},[f(`line`,{x1:F.value-5,x2:F.value,y1:O(e),y2:O(e)},null,8,U),f(`text`,{x:C.value.x-9,y:O(e)+4,"text-anchor":`end`},r(T(L)(e)),9,W)],64))),128))]),w(`
7
+ Marks are clipped to the plot area. A decision boundary or a diverging
8
+ trajectory legitimately runs off the domain, and without this it paints
9
+ straight across the rest of the slide.
10
+ `),f(`defs`,null,[f(`clipPath`,{id:X},[f(`rect`,{x:C.value.x,y:C.value.y,width:C.value.width,height:C.value.height},null,8,G)])]),f(`g`,{"clip-path":`url(#${X})`},[u(e.$slots,`default`,{},void 0,!0)],8,K),w(` Annotations that are allowed to sit outside the axes. `),u(e.$slots,`overlay`,{},void 0,!0),x.xLabel?(t(),p(`text`,{key:1,class:`dl-plot__label`,x:C.value.x+C.value.width/2,y:x.height-6,"text-anchor":`middle`},r(x.xLabel),9,q)):w(`v-if`,!0),x.yLabel?(t(),p(`text`,{key:2,class:`dl-plot__label`,x:-(C.value.y+C.value.height/2),y:13,"text-anchor":`middle`,transform:`rotate(-90)`},r(x.yLabel),9,J)):w(`v-if`,!0)],8,R))}}),[[`__scopeId`,`data-v-515e2759`]]),X={class:`dl-plot-label`},Z=[`x1`,`y1`,`x2`,`y2`,`stroke`],ae=[`x`,`y`,`text-anchor`,`fill`,`font-size`,`font-weight`],oe=l({__name:`PlotLabel`,props:{at:{},text:{},dx:{default:8},dy:{default:-8},anchor:{default:`start`},color:{},size:{default:12},leader:{type:Boolean,default:!1},bold:{type:Boolean,default:!1}},setup(e){let{$slidev:n,$nav:i,$clicksContext:a,$clicks:o,$page:c,$renderContext:l,$frontmatter:d}=D(),m=e,h=F(),g=_(()=>({x:h.sx(m.at[0]),y:h.sy(m.at[1])})),v=_(()=>({x:g.value.x+m.dx,y:g.value.y+m.dy}));return(e,n)=>(t(),p(`g`,X,[m.leader?(t(),p(`line`,{key:0,x1:g.value.x,y1:g.value.y,x2:v.value.x-(m.anchor===`end`?-4:4),y2:v.value.y+3,stroke:m.color??`var(--dl-muted)`,"stroke-width":`1`},null,8,Z)):w(`v-if`,!0),f(`text`,{x:v.value.x,y:v.value.y,"text-anchor":m.anchor,fill:m.color??`var(--dl-body)`,"font-size":m.size,"font-weight":m.bold?600:400},[u(e.$slots,`default`,{},()=>[s(r(m.text),1)])],8,ae)]))}}),se={class:`dl-curve`},ce=[`d`,`fill`],le=[`d`,`stroke`,`stroke-width`,`stroke-dasharray`],ue=l({__name:`PlotCurve`,props:{fn:{},points:{},samples:{default:160},color:{},width:{default:2.5},dashed:{type:Boolean,default:!1},fillTo:{},opacity:{default:1}},setup(e){let{$slidev:n,$nav:r,$clicksContext:i,$clicks:a,$page:s,$renderContext:l,$frontmatter:u}=D(),d=e,f=F(),m=_(()=>{if(d.points)return d.points.map(e=>Array.isArray(e)?{x:e[0],y:e[1]}:e);if(!d.fn)return[];let[e,t]=f.xDomain.value,n=Math.max(d.samples,2),r=[];for(let i=0;i<n;i++){let a=e+(t-e)*i/(n-1);r.push({x:a,y:d.fn(a)})}return r}),h=_(()=>{let[e,t]=f.yDomain.value,n=(t-e)*4,r=[],i=[];for(let a of m.value){if(!(Number.isFinite(a.y)&&a.y>e-n&&a.y<t+n)){i.length>1&&r.push(i.join(` `)),i=[];continue}i.push(`${i.length?`L`:`M`}${f.sx(a.x).toFixed(2)},${f.sy(a.y).toFixed(2)}`)}return i.length>1&&r.push(i.join(` `)),r}),g=_(()=>{if(d.fillTo===void 0||!m.value.length)return null;let[e,t]=f.yDomain.value,n=m.value.filter(e=>Number.isFinite(e.y));if(n.length<2)return null;let r=n=>Math.min(Math.max(n,e),t),i=n.map((e,t)=>`${t?`L`:`M`}${f.sx(e.x).toFixed(2)},${f.sy(r(e.y)).toFixed(2)}`).join(` `),a=f.sy(r(d.fillTo)).toFixed(2);return`${i} L${f.sx(n[n.length-1].x).toFixed(2)},${a} L${f.sx(n[0].x).toFixed(2)},${a} Z`});return(e,n)=>(t(),p(`g`,se,[g.value?(t(),p(`path`,{key:0,d:g.value,fill:d.color??`var(--dl-accent)`,style:c({opacity:.12*d.opacity}),stroke:`none`},null,12,ce)):w(`v-if`,!0),(t(!0),p(y,null,o(h.value,(e,n)=>(t(),p(`path`,{key:n,d:e,fill:`none`,stroke:d.color??`var(--dl-accent)`,"stroke-width":d.width,"stroke-dasharray":d.dashed?`6 5`:void 0,style:c({opacity:d.opacity}),"stroke-linecap":`round`,"stroke-linejoin":`round`},null,12,le))),128))]))}}),de={key:0},fe=[`fill`],Q=[`x1`,`y1`,`x2`,`y2`,`stroke`,`stroke-width`,`stroke-dasharray`,`marker-end`],pe=l({__name:`PlotLine`,props:{from:{},to:{},color:{},width:{default:2},dashed:{type:Boolean,default:!1},arrow:{type:Boolean,default:!1},opacity:{default:1}},setup(e){let{$slidev:n,$nav:r,$clicksContext:i,$clicks:a,$page:o,$renderContext:s,$frontmatter:l}=D(),u=e,d=F(),m=`dl-arrow-${b()}`,h=_(()=>({x:d.sx(u.from[0]),y:d.sy(u.from[1])})),g=_(()=>({x:d.sx(u.to[0]),y:d.sy(u.to[1])})),v=_(()=>u.color??`var(--dl-heading)`);return(e,n)=>(t(),p(`g`,{class:`dl-line`,style:c({opacity:u.opacity})},[u.arrow?(t(),p(`defs`,de,[f(`marker`,{id:m,markerWidth:`7`,markerHeight:`7`,refX:`6`,refY:`3.5`,orient:`auto`},[f(`path`,{d:`M0,0 L7,3.5 L0,7 Z`,fill:v.value},null,8,fe)])])):w(`v-if`,!0),f(`line`,{x1:h.value.x,y1:h.value.y,x2:g.value.x,y2:g.value.y,stroke:v.value,"stroke-width":u.width,"stroke-dasharray":u.dashed?`6 5`:void 0,"marker-end":u.arrow?`url(#${m})`:void 0,"stroke-linecap":`round`},null,8,Q)],4))}}),me=[`onClick`],he={class:`dl-lc__legend`},ge={class:`dl-lc__note`},$=20,_e=E(l({__name:`LearningCurves`,setup(e){let{$slidev:i,$nav:a,$clicksContext:c,$clicks:l,$page:u,$renderContext:d,$frontmatter:v}=D(),b=[{key:`underfit`,tab:`underfitting`},{key:`good`,tab:`about right`},{key:`overfit`,tab:`overfitting`}],x=h(`good`),C=h(`loss`),w=h($),T=e=>{let t=N(e);return Array.from({length:$},()=>(t()-.5)*2)},E={underfit:[T(11),T(12)],good:[T(21),T(22)],overfit:[T(31),T(32)]};function O(e,t){let n=Array.from({length:$},(e,t)=>t+1),[r,i]=E[e];return{train:n.map((n,i)=>{let a=t===`loss`?e===`underfit`?1.3*Math.exp(-.34*n)+.7:e===`good`?.36*Math.exp(-.28*n)+.048:.42*Math.exp(-.46*n)+.004:e===`underfit`?.805-.3*Math.exp(-.34*n):e===`good`?.985-.3*Math.exp(-.32*n):.999-.34*Math.exp(-.52*n),o=t===`loss`?.012:.004;return{x:n,y:a+r[i]*o}}),val:n.map((n,r)=>{let a=t===`loss`?e===`underfit`?1.3*Math.exp(-.32*n)+.735:e===`good`?.37*Math.exp(-.26*n)+.076:.34*Math.exp(-.5*n)+.061+.0105*Math.max(0,n-7)**1.35:e===`underfit`?.796-.3*Math.exp(-.32*n):e===`good`?.977-.3*Math.exp(-.3*n):.976-.32*Math.exp(-.52*n)-.0018*Math.max(0,n-7),o=t===`loss`?.014:.005;return{x:n,y:a+i[r]*o}})}}let A=_(()=>O(x.value,C.value)),P=_(()=>{let{val:e}=A.value;return C.value===`loss`?e.reduce((e,t)=>t.y<e.y?t:e):e.reduce((e,t)=>t.y>e.y?t:e)}),F=_(()=>{if(C.value===`accuracy`)return[0,1];let e=Math.max(...A.value.train.map(e=>e.y),...A.value.val.map(e=>e.y));return[0,Math.ceil(e*11)/10]}),I=_(()=>({train:A.value.train[w.value-1],val:A.value.val[w.value-1]})),L=_(()=>I.value.val.y-I.value.train.y),R={underfit:`Both curves are high and nearly flat: the model cannot fit even the data it is shown. Nothing here is a generalisation problem — the fix is a bigger network, a higher learning rate, or more epochs, and no amount of regularisation will help.`,good:`Both curves fall and level off together, with a small steady gap. This is what you are aiming for. Training longer will buy very little; the next gain comes from a better model, which for images means Lecture 04.`,overfit:`Training loss keeps falling while validation loss turns and climbs. From that turning point on, the network is memorising the training set. Stop at the marked epoch, or add regularisation — and note that training accuracy still looks wonderful throughout.`},z=e=>e.toFixed(3),B=_(()=>P.value.x>$*.55);return(e,i)=>{let a=pe,c=ue,l=oe,u=Y,d=j,h=M,_=k;return t(),S(_,{"max-width":`38rem`},{controls:g(()=>[(t(),p(y,null,o(b,e=>f(`button`,{key:e.key,type:`button`,class:m([`dl-lc__tab`,{"is-active":x.value===e.key}]),onClick:t=>x.value=e.key},r(e.tab),11,me)),64)),i[2]||=f(`span`,{class:`dl-lc__sep`,"aria-hidden":`true`},null,-1),n(d,{label:C.value===`loss`?`loss`:`accuracy`,variant:`ghost`,glyph:`⇄`,onClick:i[0]||=e=>C.value=C.value===`loss`?`accuracy`:`loss`},null,8,[`label`]),n(h,{modelValue:w.value,"onUpdate:modelValue":i[1]||=e=>w.value=e,label:`epoch`,min:1,max:$,step:1,precision:0},null,8,[`modelValue`])]),readout:g(()=>[f(`div`,he,[i[5]||=f(`span`,null,[f(`i`,{class:`is-train`}),s(`training`)],-1),i[6]||=f(`span`,null,[f(`i`,{class:`is-val`}),s(`validation`)],-1),f(`span`,null,[s(`epoch `+r(w.value)+` — train `,1),f(`strong`,null,r(z(I.value.train.y)),1),i[3]||=s(`, validation `,-1),f(`strong`,null,r(z(I.value.val.y)),1),i[4]||=s(`, gap `,-1),f(`strong`,null,r((C.value===`loss`?L.value:-L.value).toFixed(3)),1)])]),f(`div`,ge,r(R[x.value]),1)]),default:g(()=>[n(u,{"x-domain":[1,$],"y-domain":F.value,width:520,height:270,"x-label":`epoch`,"y-label":C.value===`loss`?`loss`:`accuracy`,"x-ticks":[1,5,10,15,20]},{default:g(()=>[n(a,{from:[P.value.x,F.value[0]],to:[P.value.x,F.value[1]],color:`var(--dl-danger)`,width:1.2,dashed:``},null,8,[`from`,`to`]),n(c,{points:A.value.train,color:`var(--dl-accent)`,width:2.4},null,8,[`points`]),n(c,{points:A.value.val,color:`var(--dl-heading)`,width:2.4,dashed:``},null,8,[`points`]),n(a,{from:[w.value,F.value[0]],to:[w.value,F.value[1]],color:`var(--dl-muted)`,width:1},null,8,[`from`,`to`]),n(l,{at:[P.value.x,C.value===`loss`?F.value[1]:F.value[0]],dx:B.value?-6:6,dy:C.value===`loss`?12:-8,anchor:B.value?`end`:`start`,color:`var(--dl-danger)`,size:11,bold:``,text:`best validation ${C.value} — epoch ${P.value.x}`},null,8,[`at`,`dx`,`dy`,`anchor`,`text`])]),_:1},8,[`x-domain`,`y-domain`,`y-label`])]),_:1})}}}),[[`__scopeId`,`data-v-ca520819`]]),ve={class:`mt-3 dl-callout`},ye={__name:`slides.md__slidev_42`,setup(e){let{$slidev:r,$nav:o,$clicksContext:c,$clicks:l,$page:u,$renderContext:d,$frontmatter:m}=D();return c.setup(),(e,r)=>{let o=_e,c=a(`click`);return t(),S(A,C(i(T(O)(T(m),41))),{aside:g(e=>[r[1]||=f(`p`,null,[s(`The `),f(`strong`,null,`shape of the pair`),s(` is the diagnosis.`)],-1),r[2]||=f(`div`,{class:`mt-2 dl-secondary`},[f(`p`,null,[f(`strong`,null,`underfitting`),s(` — both high and flat. Bigger model, higher lr, more epochs.`)]),f(`p`,null,[f(`strong`,null,`overfitting`),s(` — training falls, validation turns and climbs. Stop at the marker.`)])],-1),x((t(),p(`div`,ve,[...r[0]||=[f(`p`,null,`A final accuracy cannot tell these two apart. They have opposite fixes.`,-1)]])),[[c]])]),default:g(()=>[n(o)]),_:1},16)}}};export{ye as default};
lecture-03/assets/md-DfVty-xn2.js ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import{B as e,C as t,D as n,N as r,S as i,_ as a,et as o,v as s,xt as c,yt as l}from"./modules/shiki-CJZsCeMT.js";import{n as u,t as d}from"./slidev/context-DB-9afGB.js";import{t as f}from"./slidev/CodeBlockWrapper-DqFdVwPK.js";import{t as p}from"./default-IV3yhGVf.js";import{t as m}from"./slidev/VClicks-DYiBHOPb.js";var h={__name:`slides.md__slidev_31`,setup(h){let{$slidev:g,$nav:_,$clicksContext:v,$clicks:y,$page:b,$renderContext:x,$frontmatter:S}=u();return v.setup(),(u,h)=>{let g=f,_=m;return e(),s(p,c(n(l(d)(l(S),30))),{default:o(()=>[h[2]||=a(`h1`,null,[a(`code`,null,`transforms`),i(` — two lines that matter`)],-1),t(g,r({lines:!0},{title:``,ranges:[`all`,`1`,`3-6`,`8-11`,`all`]}),{default:o(()=>[...h[0]||=[a(`pre`,{class:`shiki shiki-themes vitesse-dark vitesse-light slidev-code`,style:{"--shiki-dark":`#dbd7caee`,"--shiki-light":`#393a34`,"--shiki-dark-bg":`#121212`,"--shiki-light-bg":`#ffffff`}},[a(`code`,{class:`language-python`},[a(`span`,{class:`line`},[a(`span`,{style:{"--shiki-dark":`#4D9375`,"--shiki-light":`#1E754F`}},`from`),a(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},` torchvision `),a(`span`,{style:{"--shiki-dark":`#4D9375`,"--shiki-light":`#1E754F`}},`import`),a(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},` datasets`),a(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`,`),a(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},` transforms`)]),i(`
2
+ `),a(`span`,{class:`line`}),i(`
3
+ `),a(`span`,{class:`line`},[a(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},`transform `),a(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`=`),a(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},` transforms`),a(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`.`),a(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},`Compose`),a(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`([`)]),i(`
4
+ `),a(`span`,{class:`line`},[a(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},` transforms`),a(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`.`),a(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},`ToTensor`),a(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`(),`),a(`span`,{style:{"--shiki-dark":`#758575DD`,"--shiki-light":`#A0ADA0`}},` # PIL image -> (1, 28, 28) float32 in [0, 1]`)]),i(`
5
+ `),a(`span`,{class:`line`},[a(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},` transforms`),a(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`.`),a(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},`Normalize`),a(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`((`),a(`span`,{style:{"--shiki-dark":`#4C9A91`,"--shiki-light":`#2F798A`}},`0.1307`),a(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`,),`),a(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},` (`),a(`span`,{style:{"--shiki-dark":`#4C9A91`,"--shiki-light":`#2F798A`}},`0.3081`),a(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`,)),`),a(`span`,{style:{"--shiki-dark":`#758575DD`,"--shiki-light":`#A0ADA0`}},` # (x - mean) / std, per channel`)]),i(`
6
+ `),a(`span`,{class:`line`},[a(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`])`)]),i(`
7
+ `),a(`span`,{class:`line`}),i(`
8
+ `),a(`span`,{class:`line`},[a(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},`full_train `),a(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`=`),a(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},` datasets`),a(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`.`),a(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},`MNIST`),a(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`(`),a(`span`,{style:{"--shiki-dark":`#BD976A`,"--shiki-light":`#B07D48`}},`root`),a(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`=`),a(`span`,{style:{"--shiki-dark":`#C98A7D77`,"--shiki-light":`#B5695977`}},`"`),a(`span`,{style:{"--shiki-dark":`#C98A7D`,"--shiki-light":`#B56959`}},`data`),a(`span`,{style:{"--shiki-dark":`#C98A7D77`,"--shiki-light":`#B5695977`}},`"`),a(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`,`),a(`span`,{style:{"--shiki-dark":`#BD976A`,"--shiki-light":`#B07D48`}},` train`),a(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`=`),a(`span`,{style:{"--shiki-dark":`#4D9375`,"--shiki-light":`#1E754F`}},`True`),a(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`,`)]),i(`
9
+ `),a(`span`,{class:`line`},[a(`span`,{style:{"--shiki-dark":`#BD976A`,"--shiki-light":`#B07D48`}},` download`),a(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`=`),a(`span`,{style:{"--shiki-dark":`#4D9375`,"--shiki-light":`#1E754F`}},`True`),a(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`,`),a(`span`,{style:{"--shiki-dark":`#BD976A`,"--shiki-light":`#B07D48`}},` transform`),a(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`=`),a(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},`transform`),a(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`)`)]),i(`
10
+ `),a(`span`,{class:`line`},[a(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},`test_set `),a(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`=`),a(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},` datasets`),a(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`.`),a(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},`MNIST`),a(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`(`),a(`span`,{style:{"--shiki-dark":`#BD976A`,"--shiki-light":`#B07D48`}},`root`),a(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`=`),a(`span`,{style:{"--shiki-dark":`#C98A7D77`,"--shiki-light":`#B5695977`}},`"`),a(`span`,{style:{"--shiki-dark":`#C98A7D`,"--shiki-light":`#B56959`}},`data`),a(`span`,{style:{"--shiki-dark":`#C98A7D77`,"--shiki-light":`#B5695977`}},`"`),a(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`,`),a(`span`,{style:{"--shiki-dark":`#BD976A`,"--shiki-light":`#B07D48`}},` train`),a(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`=`),a(`span`,{style:{"--shiki-dark":`#4D9375`,"--shiki-light":`#1E754F`}},`False`),a(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`,`)]),i(`
11
+ `),a(`span`,{class:`line`},[a(`span`,{style:{"--shiki-dark":`#BD976A`,"--shiki-light":`#B07D48`}},` download`),a(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`=`),a(`span`,{style:{"--shiki-dark":`#4D9375`,"--shiki-light":`#1E754F`}},`True`),a(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`,`),a(`span`,{style:{"--shiki-dark":`#BD976A`,"--shiki-light":`#B07D48`}},` transform`),a(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`=`),a(`span`,{style:{"--shiki-dark":`#DBD7CAEE`,"--shiki-light":`#393A34`}},`transform`),a(`span`,{style:{"--shiki-dark":`#666666`,"--shiki-light":`#999999`}},`)`)])])],-1)]]),_:1},16),t(_,null,{default:o(()=>[...h[1]||=[a(`ul`,null,[a(`li`,null,[a(`code`,null,`ToTensor`),i(` does two jobs: rearranges to channels-first, and divides by 255`)]),a(`li`,null,[a(`code`,null,`0.1307`),i(` and `),a(`code`,null,`0.3081`),i(` are MNIST’s own mean and standard deviation. `),a(`strong`,null,`Standardisation, from Lecture 02`),i(` — same idea, one line`)])],-1)]]),_:1})]),_:1},16)}}};export{h as default};
lecture-03/assets/md-DlxdIU0_.js ADDED
@@ -0,0 +1 @@
 
 
1
+ import{B as e,C as t,D as n,G as r,S as i,_ as a,b as o,et as s,tt as c,v as l,xt as u,yt as d}from"./modules/shiki-CJZsCeMT.js";import{n as f,t as p}from"./slidev/context-DB-9afGB.js";import{t as m}from"./default-IV3yhGVf.js";import{t as h}from"./slidev/VClicks-DYiBHOPb.js";var g={class:`dl-tight`},_={class:`mt-5 dl-callout`},v={__name:`slides.md__slidev_43`,setup(v){let{$slidev:y,$nav:b,$clicksContext:x,$clicks:S,$page:C,$renderContext:w,$frontmatter:T}=f();return x.setup(),(f,v)=>{let y=h,b=r(`click`);return e(),l(m,u(n(d(p)(d(T),42))),{default:s(()=>[v[2]||=a(`h1`,null,`Five bugs, and the symptom of each`,-1),a(`div`,g,[t(y,null,{default:s(()=>[...v[0]||=[a(`ul`,null,[a(`li`,null,[a(`strong`,null,[i(`Forgot `),a(`code`,null,`zero_grad()`)]),i(` → loss wanders or explodes, no error message`)]),a(`li`,null,[a(`strong`,null,[i(`Forgot `),a(`code`,null,`.to(device)`),i(` on the batch`)]),i(` → `),a(`code`,null,`Expected all tensors to be on the same device`)]),a(`li`,null,[a(`strong`,null,`Softmax inside the model`),i(),a(`em`,null,`and`),i(),a(`code`,null,`CrossEntropyLoss`),i(` → trains, badly, no error message`)]),a(`li`,null,[a(`strong`,null,`Float labels`),i(` → `),a(`code`,null,`expected scalar type Long but found Float`)]),a(`li`,null,[a(`strong`,null,`Wrong flatten`),i(` → a shape mismatch at the first `),a(`code`,null,`Linear`),i(`, which names both shapes`)])],-1)]]),_:1})]),c((e(),o(`div`,_,[...v[1]||=[a(`p`,null,`Three of the five raise nothing at all. When a model trains but will not learn, check those three before you touch the architecture.`,-1)]])),[[b]])]),_:1},16)}}};export{v as default};
lecture-03/assets/md-DpUFBAFd2.js ADDED
@@ -0,0 +1 @@
 
 
1
+ import{B as e,C as t,D as n,_ as r,et as i,v as a,xt as o,yt as s}from"./modules/shiki-CJZsCeMT.js";import{n as c,t as l}from"./slidev/context-DB-9afGB.js";import{t as u}from"./interactive-CBN7ZXLe.js";import{t as d}from"./PipelineBoard-eTgFcSR7.js";var f={__name:`slides.md__slidev_28`,setup(f){let{$slidev:p,$nav:m,$clicksContext:h,$clicks:g,$page:_,$renderContext:v,$frontmatter:y}=c();return h.setup(),(c,f)=>{let p=d;return e(),a(u,o(n(s(l)(s(y),27))),{aside:i(e=>[...f[0]||=[r(`p`,null,`Click each box. Together they are every training script you will read this semester.`,-1),r(`div`,{class:`mt-3 dl-secondary`},[r(`p`,null,`What the picture says and a list cannot: the loop is not a fifth peer, it is the thing that runs the other four.`)],-1),r(`div`,{class:`mt-3 dl-callout`},[r(`p`,null,`Next week’s CNN changes exactly one box.`)],-1)]]),default:i(()=>[t(p)]),_:1},16)}}};export{f as default};
lecture-03/assets/md-Ds2r8LNq.js ADDED
@@ -0,0 +1 @@
 
 
1
+ import{B as e,C as t,D as n,G as r,_ as i,b as a,et as o,tt as s,v as c,xt as l,yt as u}from"./modules/shiki-CJZsCeMT.js";import{n as d,t as f}from"./slidev/context-DB-9afGB.js";import{t as p}from"./default-IV3yhGVf.js";import{t as m}from"./slidev/VClicks-DYiBHOPb.js";import{t as h}from"./Citation-CcKhBxpe.js";var g={class:`mt-4 dl-callout`},_={class:`mt-2`},v={__name:`slides.md__slidev_6`,setup(v){let{$slidev:y,$nav:b,$clicksContext:x,$clicks:S,$page:C,$renderContext:w,$frontmatter:T}=d();return x.setup(),(d,v)=>{let y=m,b=h,x=r(`click`);return e(),c(p,l(n(u(f)(u(T),5))),{default:o(()=>[v[2]||=i(`h1`,null,`Who uses it, and why that matters to you`,-1),t(y,null,{default:o(()=>[...v[0]||=[i(`ul`,null,[i(`li`,null,`At the three biggest machine-learning conferences, over 80% of the papers that name a framework name PyTorch`),i(`li`,null,`Hugging Face, Lightning, Diffusers, Detectron, nnU-Net — the ecosystem you will want later is PyTorch-first`),i(`li`,null,`Which means: when you get stuck, someone has already asked your question in public`)],-1)]]),_:1}),s((e(),a(`div`,g,[...v[1]||=[i(`p`,null,`The real reason to teach it: after this course, you will learn mostly by reading other people’s models. Those models are in PyTorch.`,-1)]])),[[x]]),i(`div`,_,[t(b,{source:`Framework shares from Papers With Code trends; checked August 2026`,url:`https://pytorch.org/`})])]),_:1},16)}}};export{v as default};