Release lecture-05-v1.0
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- .gitattributes +1 -0
- lecture-05/404.html +30 -0
- lecture-05/_redirects +1 -0
- lecture-05/assets/404-bkedjYjP.css +1 -0
- lecture-05/assets/Citation-BuY_RPc0.js +1 -0
- lecture-05/assets/Citation-rca7ok54.css +1 -0
- lecture-05/assets/DeckFooter-B6vKMo6W.css +1 -0
- lecture-05/assets/DeckFooter-e6C5A3-W.js +1 -0
- lecture-05/assets/DrawingControls-Dhbx0szf.css +1 -0
- lecture-05/assets/EmbeddingLab-XMgvCUup.css +1 -0
- lecture-05/assets/EmbeddingLab-XVnfZGjB.js +1 -0
- lecture-05/assets/GatedCell-BmFrMgAI.js +1 -0
- lecture-05/assets/GatedCell-CMocJDE5.css +1 -0
- lecture-05/assets/GradientFlow-B-uOpJPB.js +1 -0
- lecture-05/assets/GradientFlow-BJ1pHoOj.css +1 -0
- lecture-05/assets/KaTeX_AMS-Regular-BQhdFMY1.woff2 +0 -0
- lecture-05/assets/KaTeX_AMS-Regular-DMm9YOAa.woff +0 -0
- lecture-05/assets/KaTeX_AMS-Regular-DRggAlZN.ttf +0 -0
- lecture-05/assets/KaTeX_Caligraphic-Bold-ATXxdsX0.ttf +0 -0
- lecture-05/assets/KaTeX_Caligraphic-Bold-BEiXGLvX.woff +0 -0
- lecture-05/assets/KaTeX_Caligraphic-Bold-Dq_IR9rO.woff2 +0 -0
- lecture-05/assets/KaTeX_Caligraphic-Regular-CTRA-rTL.woff +0 -0
- lecture-05/assets/KaTeX_Caligraphic-Regular-Di6jR-x-.woff2 +0 -0
- lecture-05/assets/KaTeX_Caligraphic-Regular-wX97UBjC.ttf +0 -0
- lecture-05/assets/KaTeX_Fraktur-Bold-BdnERNNW.ttf +0 -0
- lecture-05/assets/KaTeX_Fraktur-Bold-BsDP51OF.woff +0 -0
- lecture-05/assets/KaTeX_Fraktur-Bold-CL6g_b3V.woff2 +0 -0
- lecture-05/assets/KaTeX_Fraktur-Regular-CB_wures.ttf +0 -0
- lecture-05/assets/KaTeX_Fraktur-Regular-CTYiF6lA.woff2 +0 -0
- lecture-05/assets/KaTeX_Fraktur-Regular-Dxdc4cR9.woff +0 -0
- lecture-05/assets/KaTeX_Main-Bold-Cx986IdX.woff2 +0 -0
- lecture-05/assets/KaTeX_Main-Bold-Jm3AIy58.woff +0 -0
- lecture-05/assets/KaTeX_Main-Bold-waoOVXN0.ttf +0 -0
- lecture-05/assets/KaTeX_Main-BoldItalic-DxDJ3AOS.woff2 +0 -0
- lecture-05/assets/KaTeX_Main-BoldItalic-DzxPMmG6.ttf +0 -0
- lecture-05/assets/KaTeX_Main-BoldItalic-SpSLRI95.woff +0 -0
- lecture-05/assets/KaTeX_Main-Italic-3WenGoN9.ttf +0 -0
- lecture-05/assets/KaTeX_Main-Italic-BMLOBm91.woff +0 -0
- lecture-05/assets/KaTeX_Main-Italic-NWA7e6Wa.woff2 +0 -0
- lecture-05/assets/KaTeX_Main-Regular-B22Nviop.woff2 +0 -0
- lecture-05/assets/KaTeX_Main-Regular-Dr94JaBh.woff +0 -0
- lecture-05/assets/KaTeX_Main-Regular-ypZvNtVU.ttf +0 -0
- lecture-05/assets/KaTeX_Math-BoldItalic-B3XSjfu4.ttf +0 -0
- lecture-05/assets/KaTeX_Math-BoldItalic-CZnvNsCZ.woff2 +0 -0
- lecture-05/assets/KaTeX_Math-BoldItalic-iY-2wyZ7.woff +0 -0
- lecture-05/assets/KaTeX_Math-Italic-DA0__PXp.woff +0 -0
- lecture-05/assets/KaTeX_Math-Italic-flOr_0UB.ttf +0 -0
- lecture-05/assets/KaTeX_Math-Italic-t53AETM-.woff2 +0 -0
- lecture-05/assets/KaTeX_SansSerif-Bold-CFMepnvq.ttf +0 -0
- lecture-05/assets/KaTeX_SansSerif-Bold-D1sUS0GD.woff2 +0 -0
.gitattributes
CHANGED
|
@@ -47,3 +47,4 @@ lecture-01/assets/synthetic-polyp-CIkbWMkW.jpeg filter=lfs diff=lfs merge=lfs -t
|
|
| 47 |
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
|
|
|
|
|
|
| 47 |
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
|
lecture-05/404.html
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="utf-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
| 6 |
+
<title>Recurrent Neural Networks - Slidev</title>
|
| 7 |
+
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Inter:wght@200;400;600&family=Source+Serif+4:wght@200;400;600&family=JetBrains+Mono:wght@200;400;600&display=swap" type="text/css">
|
| 8 |
+
<link rel="icon" href="https://cdn.jsdelivr.net/gh/slidevjs/slidev/assets/favicon.png">
|
| 9 |
+
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
| 10 |
+
<meta property="slidev:version" content="52.19.0">
|
| 11 |
+
<meta name="description" content=""PGR207 Deep Learning 2026 — Lecture 05"">
|
| 12 |
+
<meta name="author" content=""Vajira Thambawita"">
|
| 13 |
+
<meta property="og:title" content="Recurrent Neural Networks - Slidev">
|
| 14 |
+
<meta property="og:description" content=""PGR207 Deep Learning 2026 — Lecture 05""> <script type="module" crossorigin src="./assets/index-CK0S5VQV.js"></script>
|
| 15 |
+
<link rel="modulepreload" crossorigin href="./assets/rolldown-runtime-hePW80VL.js">
|
| 16 |
+
<link rel="modulepreload" crossorigin href="./assets/modules/shiki-CkJq9tSf.js">
|
| 17 |
+
<link rel="modulepreload" crossorigin href="./assets/_plugin-vue_export-helper-BDNMzG2s.js">
|
| 18 |
+
<link rel="modulepreload" crossorigin href="./assets/modules/vue-Dz2ojcKF.js">
|
| 19 |
+
<link rel="modulepreload" crossorigin href="./assets/slidev/context-DnYiQGy6.js">
|
| 20 |
+
<link rel="modulepreload" crossorigin href="./assets/useNav-D6eKrDQR.js">
|
| 21 |
+
<link rel="modulepreload" crossorigin href="./assets/syncState-BCmj5bTl.js">
|
| 22 |
+
<link rel="stylesheet" crossorigin href="./assets/modules/shiki-BrmBd2_v.css">
|
| 23 |
+
<link rel="stylesheet" crossorigin href="./assets/index-Ca92njKe.css">
|
| 24 |
+
</head>
|
| 25 |
+
<body>
|
| 26 |
+
<div id="app"></div>
|
| 27 |
+
<div id="mermaid-rendering-container"></div>
|
| 28 |
+
|
| 29 |
+
</body>
|
| 30 |
+
</html>
|
lecture-05/_redirects
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
./* ./index.html 200
|
lecture-05/assets/404-bkedjYjP.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
.page-link[data-v-b584852f]{background-color:#9ca3af1a;border-radius:.25rem;padding:.5rem 1rem}.page-link[data-v-b584852f]:hover{background-color:#9ca3af33}
|
lecture-05/assets/Citation-BuY_RPc0.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
import{H as e,St as t,b as n,m as r,w as i,x as a,z as o}from"./modules/shiki-CkJq9tSf.js";import{t as s}from"./_plugin-vue_export-helper-BDNMzG2s.js";import{n as c}from"./slidev/context-DnYiQGy6.js";var l={class:`dl-citation`},u=[`href`],d=s(i({__name:`Citation`,props:{source:{},url:{}},setup(i){let{$slidev:s,$nav:d,$clicksContext:f,$clicks:p,$page:m,$renderContext:h,$frontmatter:g}=c(),_=i;return(i,s)=>(o(),n(`span`,l,[_.url?(o(),n(`a`,{key:0,href:_.url,target:`_blank`,rel:`noopener`},t(_.source),9,u)):(o(),n(r,{key:1},[a(t(_.source),1)],64)),e(i.$slots,`default`,{},void 0,!0)]))}}),[[`__scopeId`,`data-v-11a8cabc`]]);export{d as t};
|
lecture-05/assets/Citation-rca7ok54.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
.dl-citation[data-v-11a8cabc]{font-size:var(--dl-fs-citation);color:var(--dl-muted)}.dl-citation a[data-v-11a8cabc]{color:inherit;border-bottom:1px dotted}
|
lecture-05/assets/DeckFooter-B6vKMo6W.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
.dl-footer[data-v-fe908050]{letter-spacing:.04em;color:var(--dl-muted);pointer-events:none;justify-content:space-between;align-items:center;gap:1rem;font-size:.72rem;display:flex;position:absolute;bottom:1rem;left:3rem;right:3rem}.dl-footer__left[data-v-fe908050]{align-items:center;gap:.4rem;min-width:0;display:flex}.dl-footer__code[data-v-fe908050]{color:var(--dl-accent);font-weight:700}.dl-footer__sep[data-v-fe908050]{opacity:.5}.dl-footer__title[data-v-fe908050]{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.dl-footer__right[data-v-fe908050]{font-variant-numeric:tabular-nums;flex-shrink:0}
|
lecture-05/assets/DeckFooter-e6C5A3-W.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
import{St as e,_ as t,b as n,g as r,vt as i,w as a,y as o,z as s}from"./modules/shiki-CkJq9tSf.js";import{t as c}from"./useNav-D6eKrDQR.js";import{t as l}from"./_plugin-vue_export-helper-BDNMzG2s.js";import{n as u}from"./slidev/context-DnYiQGy6.js";import"./slidev/client-BFvXAbq7.js";var d={class:`dl-footer`},f={class:`dl-footer__left`},p={key:0,class:`dl-footer__code`},m={key:1,class:`dl-footer__sep`},h={key:2},g={key:3,class:`dl-footer__sep`},_={key:4,class:`dl-footer__title`},v={class:`dl-footer__right`},y=l(a({__name:`DeckFooter`,setup(a){let{$slidev:l}=u(),y=c(),b=r(()=>l?.themeConfigs??{}),x=r(()=>b.value.courseCode??``),S=r(()=>b.value.lecture??``),C=r(()=>b.value.lectureTitle??``);return(r,a)=>(s(),n(`footer`,d,[t(`div`,f,[x.value?(s(),n(`span`,p,e(x.value),1)):o(`v-if`,!0),S.value?(s(),n(`span`,m,`·`)):o(`v-if`,!0),S.value?(s(),n(`span`,h,`Lecture `+e(S.value),1)):o(`v-if`,!0),C.value?(s(),n(`span`,g,`·`)):o(`v-if`,!0),C.value?(s(),n(`span`,_,e(C.value),1)):o(`v-if`,!0)]),t(`div`,v,e(i(y).currentPage.value)+` / `+e(i(y).total.value),1)]))}}),[[`__scopeId`,`data-v-fe908050`]]);export{y as t};
|
lecture-05/assets/DrawingControls-Dhbx0szf.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
.v-popper--theme-dropdown .v-popper__arrow-inner{border-color:#9ca3af33}
|
lecture-05/assets/EmbeddingLab-XMgvCUup.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
.dl-emb[data-v-83e76071]{font-variant-numeric:tabular-nums;align-items:center;gap:1rem;display:flex}.dl-emb__grid[data-v-83e76071]{grid-template-columns:auto auto auto;align-items:center;gap:.18rem .6rem;display:grid}.dl-emb__head[data-v-83e76071]{color:var(--dl-muted);text-transform:uppercase;letter-spacing:.06em;padding-bottom:.15rem;font-size:.68rem}.dl-emb__head--wide[data-v-83e76071]{text-transform:none;letter-spacing:0}.dl-emb__word[data-v-83e76071]{font:inherit;text-align:right;color:var(--dl-body);cursor:pointer;background:0 0;border:1px solid #0000;border-radius:4px;padding:.1rem .35rem;font-size:.82rem}.dl-emb__word[data-v-83e76071]:hover{border-color:var(--dl-accent);color:var(--dl-accent)}.dl-emb__word.is-selected[data-v-83e76071]{color:var(--dl-accent-strong);font-weight:700}.dl-emb__word[data-v-83e76071]:focus-visible{outline:2px solid var(--dl-accent);outline-offset:1px}.dl-emb__onehot[data-v-83e76071]{border:1px solid var(--dl-border);width:1.7rem;height:1.4rem;color:var(--dl-muted);border-radius:3px;place-items:center;font-size:.8rem;display:grid}.dl-emb__onehot.is-hot[data-v-83e76071]{background:var(--dl-accent);border-color:var(--dl-accent);color:#fff;font-weight:700}.dl-emb__row[data-v-83e76071]{border-radius:3px;gap:0;transition:background .15s;display:flex}.dl-emb__row.is-selected[data-v-83e76071]{background:var(--dl-accent-soft);box-shadow:0 0 0 1.5px var(--dl-accent)}.dl-emb__cell[data-v-83e76071]{border:1px solid var(--dl-border);width:2.7rem;height:1.4rem;color:var(--dl-heading);place-items:center;margin-right:-1px;font-size:.76rem;display:grid}.dl-emb__cell.is-out[data-v-83e76071]{border-color:var(--dl-accent);background:var(--dl-accent-soft);font-weight:600}.dl-emb__result[data-v-83e76071]{flex-direction:column;align-items:center;gap:.4rem;display:flex}.dl-emb__arrow[data-v-83e76071]{color:var(--dl-muted);font-size:1.3rem}.dl-emb__out[data-v-83e76071]{display:flex}.dl-emb__outcap[data-v-83e76071]{color:var(--dl-muted);text-align:center;font-size:.72rem;line-height:1.3}.dl-emb__scale[data-v-83e76071]{margin-top:.2rem}.dl-emb__tabs[data-v-83e76071]{flex-wrap:wrap;gap:.3rem;display:flex}.dl-emb__tabs button[data-v-83e76071]{border:1px solid var(--dl-border);color:var(--dl-body);font:inherit;cursor:pointer;background:0 0;border-radius:6px;padding:.22rem .5rem;font-size:.76rem}.dl-emb__tabs button[data-v-83e76071]:hover{border-color:var(--dl-accent);color:var(--dl-accent)}.dl-emb__tabs button.is-selected[data-v-83e76071]{background:var(--dl-accent);border-color:var(--dl-accent);color:#fff}.dl-emb__tabs button[data-v-83e76071]:focus-visible{outline:2px solid var(--dl-accent);outline-offset:2px}
|
lecture-05/assets/EmbeddingLab-XVnfZGjB.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
import{$ as e,S as t,St as n,V as r,_ as i,b as a,g as o,m as s,ut as c,v as l,vt as u,w as d,x as f,y as p,yt as m,z as h}from"./modules/shiki-CkJq9tSf.js";import{t as g}from"./_plugin-vue_export-helper-BDNMzG2s.js";import{n as _}from"./slidev/context-DnYiQGy6.js";import{n as v}from"./useConvolution-mOidZmS_.js";import{n as y}from"./interactive-pqWNz3EB.js";import{t as b}from"./Plot2D-C9URVmMB.js";import{t as x}from"./PlotLabel-BilrlAqg.js";import{t as S}from"./PlotPoints-CeOGnq0p.js";var C={key:0,class:`dl-emb`},w={class:`dl-emb__grid`},T={class:`dl-emb__head dl-emb__head--wide`},E=[`onClick`],D={class:`dl-emb__result`},O={class:`dl-emb__out`},k={class:`dl-emb__outcap`},A={key:0,class:`dl-emb__tabs`},j=[`onClick`],M={class:`dl-emb__scale`},N={class:`dl-emb__scale`},P=g(d({__name:`EmbeddingLab`,props:{mode:{default:`lookup`},vocabulary:{default:2e4},dim:{default:64},hidden:{default:128}},setup(d){let{$slidev:g,$nav:P,$clicksContext:F,$clicks:I,$page:L,$renderContext:R,$frontmatter:z}=_(),B=[{word:`the`,vec:[0,0,0,.9],group:`function`},{word:`a`,vec:[0,.1,0,.8],group:`function`},{word:`movie`,vec:[.1,.9,.1,.1],group:`thing`},{word:`plot`,vec:[0,.8,0,.1],group:`thing`},{word:`ending`,vec:[0,.7,.1,.1],group:`thing`},{word:`great`,vec:[.8,.1,.6,0],group:`positive`},{word:`brilliant`,vec:[.9,0,.8,0],group:`positive`},{word:`awful`,vec:[-.8,.1,.6,0],group:`negative`},{word:`terrible`,vec:[-.9,0,.8,0],group:`negative`}],V={plot:{dx:-10,dy:-9,anchor:`end`},brilliant:{dx:-10,dy:16,anchor:`end`},terrible:{dx:10,dy:16,anchor:`start`}};function H(e){return V[e.word]??(e.vec[0]>.3?{dx:-10,dy:-9,anchor:`end`}:{dx:10,dy:-9,anchor:`start`})}let U=d,W=c(5),G=o(()=>B[W.value]),K=e=>e.toLocaleString(`en-US`),q=o(()=>U.vocabulary*U.hidden),J=o(()=>U.vocabulary*U.dim+U.dim*U.hidden),Y={positive:`var(--dl-accent)`,negative:`var(--dl-danger)`,thing:`var(--dl-heading)`,function:`var(--dl-muted)`},X=o(()=>B.map((e,t)=>({x:e.vec[0],y:e.vec[1],cls:e.group,highlight:t===W.value})));return(o,c)=>{let d=S,g=x,_=b,P=y;return h(),l(P,{"max-width":U.mode===`space`?`34rem`:`40rem`},{controls:e(()=>[U.mode===`space`?(h(),a(`div`,A,[(h(),a(s,null,r(B,(e,t)=>i(`button`,{key:e.word,type:`button`,class:m({"is-selected":t===W.value}),onClick:e=>W.value=t},n(e.word),11,j)),64))])):p(`v-if`,!0)]),readout:e(()=>[U.mode===`lookup`?(h(),a(s,{key:0},[f(` The one-hot column has a single 1, in row `+n(W.value)+` — so the product picks `,1),i(`strong`,null,`row `+n(W.value),1),c[6]||=f(` of E and nothing else. `,-1),c[7]||=i(`code`,null,`nn.Embedding`,-1),c[8]||=f(` skips the multiply and indexes the row directly. `,-1),i(`div`,M,[f(` At real scale, `+n(K(U.vocabulary))+` words into a `+n(U.hidden)+`-unit layer: one-hot needs `+n(K(U.vocabulary))+` × `+n(U.hidden)+` = `,1),i(`strong`,null,n(K(q.value)),1),f(` weights; a `+n(U.dim)+`-wide embedding needs `+n(K(U.vocabulary))+` × `+n(U.dim)+` + `+n(U.dim)+` × `+n(U.hidden)+` = `,1),i(`strong`,null,n(K(J.value)),1),c[5]||=f(`. `,-1)])],64)):(h(),a(s,{key:1},[c[9]||=f(` Nobody wrote these coordinates — they are weights, trained by the same gradient descent as every other layer. `,-1),c[10]||=i(`strong`,null,`great`,-1),c[11]||=f(` and `,-1),c[12]||=i(`strong`,null,`brilliant`,-1),c[13]||=f(` end up beside each other because they did the same job in the training reviews; one-hot puts every pair of words exactly the same distance apart. `,-1),i(`div`,N,` The axes are named here so the picture is readable. In a real `+n(U.dim)+`-dimensional table no single axis means anything you could name. `,1)],64))]),default:e(()=>[U.mode===`lookup`?(h(),a(`div`,C,[i(`div`,w,[c[0]||=i(`div`,{class:`dl-emb__head`},`word`,-1),c[1]||=i(`div`,{class:`dl-emb__head`},`one-hot`,-1),i(`div`,T,`E — the embedding matrix, `+n(B.length)+` × 4`,1),(h(),a(s,null,r(B,(e,t)=>(h(),a(s,{key:e.word},[i(`button`,{type:`button`,class:m([`dl-emb__word`,{"is-selected":t===W.value}]),onClick:e=>W.value=t},n(e.word),11,E),i(`div`,{class:m([`dl-emb__onehot`,{"is-hot":t===W.value}])},n(+(t===W.value)),3),i(`div`,{class:m([`dl-emb__row`,{"is-selected":t===W.value}])},[(h(!0),a(s,null,r(e.vec,(e,t)=>(h(),a(`div`,{key:t,class:`dl-emb__cell`},n(u(v)(e)),1))),128))],2)],64))),64))]),i(`div`,D,[c[4]||=i(`div`,{class:`dl-emb__arrow`,"aria-hidden":`true`},`→`,-1),i(`div`,O,[(h(!0),a(s,null,r(G.value.vec,(e,t)=>(h(),a(`div`,{key:t,class:`dl-emb__cell is-out`},n(u(v)(e)),1))),128))]),i(`div`,k,[c[2]||=f(`the vector for`,-1),c[3]||=i(`br`,null,null,-1),i(`strong`,null,n(G.value.word),1)])])])):(h(),a(s,{key:1},[p(` The same table, read as a map. `),t(_,{"x-domain":[-1.15,1.15],"y-domain":[-.25,1.15],"x-ticks":[-1,-.5,0,.5,1],"y-ticks":[0,.5,1],"x-label":`learned dimension 1`,"y-label":`learned dimension 2`,width:520,height:300},{default:e(()=>[t(d,{points:X.value,radius:6,colors:Y},null,8,[`points`]),(h(),a(s,null,r(B,(e,n)=>t(g,{key:e.word,at:[e.vec[0],e.vec[1]],dx:H(e).dx,dy:H(e).dy,anchor:H(e).anchor,color:Y[e.group],bold:n===W.value,size:12,text:e.word},null,8,[`at`,`dx`,`dy`,`anchor`,`color`,`bold`,`text`])),64))]),_:1})],2112))]),_:1},8,[`max-width`])}}}),[[`__scopeId`,`data-v-83e76071`]]);export{P as t};
|
lecture-05/assets/GatedCell-BmFrMgAI.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
import{$ as e,S as t,St as n,V as r,X as ee,_ as i,b as a,g as o,m as s,ut as c,v as te,vt as l,w as u,x as d,y as f,yt as p,z as m}from"./modules/shiki-CkJq9tSf.js";import{t as h}from"./_plugin-vue_export-helper-BDNMzG2s.js";import{n as g}from"./slidev/context-DnYiQGy6.js";import{n as _}from"./useConvolution-mOidZmS_.js";import{d as ne,o as re,s as ie}from"./useRecurrence-PhWWMav6.js";import{n as ae}from"./interactive-pqWNz3EB.js";import{t as oe}from"./Katex-TqgxGJEq.js";import{t as se}from"./Slider-Bf0ITYx4.js";import{t as ce}from"./StepButton-BvnaUJaa.js";var le=[`viewBox`],ue=[`x2`],de=[`y`],fe=[`x1`,`x2`],pe=[`x1`,`x2`],me=[`x`,`y`],he=[`y`],ge=[`y2`],_e=[`x`],ve=[`y`],ye=[`x`,`y`],be=[`y`],xe=[`y1`,`y2`],Se=[`x2`,`y2`],Ce=[`x2`,`y2`],we=[`x`],Te=[`y`],Ee=[`x`,`y`],De=[`x`],Oe=[`y`],ke=[`x`,`y`],Ae=[`y`],je=[`y2`],Me=[`x`,`y`],Ne=[`y`],Pe=[`x1`,`x2`],Fe=[`y`],Ie=[`y2`],Le=[`x`],Re=[`y`],ze=[`x`,`y`],Be=[`x1`,`x2`],Ve=[`x`,`y`],He=[`y`],Ue=[`y`],We=[`x1`,`x2`,`y2`],Ge=[`y`],Ke=[`viewBox`],qe=[`y2`],Je=[`x`],Ye=[`x`,`y`],Xe=[`y`],Ze=[`x`,`y`,`width`],Qe=[`x`,`y`],$e=[`y1`,`x2`,`y2`],et=[`y`],tt={class:`dl-gcell__eq dl-math-sm`},v=580,y=272,b=46,x=162,S=56,C=30,w=236,T=180,E=300,D=300,nt=108,O=398,rt=398,k=120,it=470,A=262,j=338,M=470,N=13,P=196,F=300,at=h(u({__name:`GatedCell`,props:{variant:{default:`lstm`}},setup(u){let{$slidev:h,$nav:at,$clicksContext:ot,$clicks:st,$page:ct,$renderContext:lt,$frontmatter:ut}=g(),I=u,L=c(.6),R=c(.9),z=c(.4),B=c(.8),V=c(.7),H=c(.6),U=c(.5),W=c(1),G=c(.4),K=o(()=>ie(L.value,R.value,z.value,B.value,V.value)),q=o(()=>ne(U.value+.9*W.value*H.value)),J=o(()=>re(H.value,G.value,W.value,q.value)),dt=[{key:`forget`,name:`forget gate`,lit:[`cin`,`fgate`,`fmul`,`bus`],latex:`f_t = \\sigma\\!\\left(W_{xf}x_t + W_{hf}h_{t-1} + b_f\\right)`,numeric:()=>`f_t \\cdot c_{t-1} = ${_(R.value)} \\times ${_(L.value)} = ${_(K.value.kept)}`,note:`How much of the old cell state survives. 1 keeps all of it, 0 wipes it. Added to the LSTM in 2000 — the original 1997 cell could not forget.`},{key:`input`,name:`input gate`,lit:[`igate`,`bus`],latex:`i_t = \\sigma\\!\\left(W_{xi}x_t + W_{hi}h_{t-1} + b_i\\right)`,numeric:()=>`i_t = ${_(z.value)}`,note:`How much of the new candidate is allowed in. Note that it decides the amount, not the content.`},{key:`candidate`,name:`candidate`,lit:[`ggate`,`igmul`,`bus`],latex:`\\tilde{c}_t = \\tanh\\!\\left(W_{xc}x_t + W_{hc}h_{t-1} + b_c\\right)`,numeric:()=>`i_t \\cdot \\tilde{c}_t = ${_(z.value)} \\times ${_(B.value)} = ${_(K.value.written)}`,note:`The content: what this step would like to write. tanh, so it is signed — the cell state can be pushed down as well as up.`},{key:`cell`,name:`cell state`,lit:[`cin`,`fmul`,`igmul`,`plus`,`cout`],latex:`c_t = f_t \\odot c_{t-1} + i_t \\odot \\tilde{c}_t`,numeric:()=>`c_t = ${_(K.value.kept)} + ${_(K.value.written)} = ${_(K.value.c)}`,note:`The whole point of the architecture: an addition, not a matrix multiply. Nothing on this path can shrink the gradient by a factor per step.`},{key:`output`,name:`output gate`,lit:[`ogate`,`bus`],latex:`o_t = \\sigma\\!\\left(W_{xo}x_t + W_{ho}h_{t-1} + b_o\\right)`,numeric:()=>`o_t = ${_(V.value)}`,note:`How much of the cell state to expose. The cell can hold something for fifty steps and show it on exactly one of them.`},{key:`hidden`,name:`hidden state`,lit:[`cout`,`ctanh`,`hmul`,`hout`],latex:`h_t = o_t \\odot \\tanh(c_t)`,numeric:()=>`h_t = ${_(V.value)} \\times \\tanh(${_(K.value.c)}) = ${_(K.value.h)}`,note:`What leaves the cell, and the only thing the next layer sees. c_t stays inside.`}],ft=[{key:`update`,name:`update gate`,lit:[`z`],latex:`z_t = \\sigma\\!\\left(W_{xz}x_t + W_{hz}h_{t-1} + b_z\\right)`,numeric:()=>`z_t = ${_(G.value)}`,note:`One gate doing the LSTM’s forget and input jobs at once: whatever is not written is kept, by construction.`},{key:`reset`,name:`reset gate`,lit:[`r`,`cand`],latex:`r_t = \\sigma\\!\\left(W_{xr}x_t + W_{hr}h_{t-1} + b_r\\right)`,numeric:()=>`r_t \\cdot h_{t-1} = ${_(W.value)} \\times ${_(H.value)} = ${_(W.value*H.value)}`,note:`How much of the past the candidate is allowed to read. Drag it to 0: the candidate forgets the sentence so far and answers from this word alone.`},{key:`candidate`,name:`candidate`,lit:[`cand`],latex:`\\tilde{h}_t = \\tanh\\!\\left(W_{xh}x_t + W_{hh}(r_t \\odot h_{t-1}) + b_h\\right)`,numeric:()=>`\\tilde{h}_t = ${_(q.value)}`,note:`The proposed new state. Same shape as h — there is no second state vector in a GRU.`},{key:`blend`,name:`new state`,lit:[`kept`,`written`,`hnew`],latex:`h_t = (1 - z_t) \\odot h_{t-1} + z_t \\odot \\tilde{h}_t`,numeric:()=>`h_t = ${_(1-G.value)} \\times ${_(H.value)} + ${_(G.value)} \\times ${_(q.value)} = ${_(J.value.h)}`,note:`A weighted blend of old and new, and the two weights always sum to 1. Set z to 0 and the state is frozen; set it to 1 and the past is gone.`}],Y=o(()=>I.variant===`lstm`?dt:ft),X=c(-1);ee(()=>I.variant,()=>{X.value=-1});let Z=o(()=>X.value<0?null:Y.value[X.value]),pt=o(()=>X.value>=Y.value.length-1);function mt(){X.value=pt.value?-1:X.value+1}let ht=e=>!Z.value||Z.value.lit.includes(e),gt=e=>Z.value?!Z.value.lit.includes(e):!1;function Q(e){return{"is-dim":gt(e),"is-lit":!!Z.value&&ht(e)}}let _t=e=>e>=0?346:346+e*F/2,vt=e=>Math.abs(e)*F/2,yt=o(()=>[{key:`hprev`,label:`h(t−1)`,value:H.value,tone:`old`},{key:`cand`,label:`candidate`,value:q.value,tone:`new`},{key:`kept`,label:`kept: (1−z)·h(t−1)`,value:J.value.kept,tone:`old`},{key:`written`,label:`written: z·candidate`,value:J.value.written,tone:`new`},{key:`hnew`,label:`h(t)`,value:J.value.h,tone:`result`}]),$=e=>40+e*44+(e>=2?16:0);return(ee,o)=>{let c=se,u=ce,h=oe,g=ae;return m(),te(g,{"max-width":`40rem`},{controls:e(()=>[I.variant===`lstm`?(m(),a(s,{key:0},[t(c,{modelValue:L.value,"onUpdate:modelValue":o[0]||=e=>L.value=e,label:`c(t−1)`,min:-1,max:1,step:.05},null,8,[`modelValue`]),t(c,{modelValue:R.value,"onUpdate:modelValue":o[1]||=e=>R.value=e,label:`forget f`,min:0,max:1,step:.05},null,8,[`modelValue`]),t(c,{modelValue:z.value,"onUpdate:modelValue":o[2]||=e=>z.value=e,label:`input i`,min:0,max:1,step:.05},null,8,[`modelValue`]),t(c,{modelValue:B.value,"onUpdate:modelValue":o[3]||=e=>B.value=e,label:`candidate c̃`,min:-1,max:1,step:.05},null,8,[`modelValue`]),t(c,{modelValue:V.value,"onUpdate:modelValue":o[4]||=e=>V.value=e,label:`output o`,min:0,max:1,step:.05},null,8,[`modelValue`])],64)):(m(),a(s,{key:1},[t(c,{modelValue:H.value,"onUpdate:modelValue":o[5]||=e=>H.value=e,label:`h(t−1)`,min:-1,max:1,step:.05},null,8,[`modelValue`]),t(c,{modelValue:U.value,"onUpdate:modelValue":o[6]||=e=>U.value=e,label:`input drive`,min:-2,max:2,step:.1,precision:1},null,8,[`modelValue`]),t(c,{modelValue:W.value,"onUpdate:modelValue":o[7]||=e=>W.value=e,label:`reset r`,min:0,max:1,step:.05},null,8,[`modelValue`]),t(c,{modelValue:G.value,"onUpdate:modelValue":o[8]||=e=>G.value=e,label:`update z`,min:0,max:1,step:.05},null,8,[`modelValue`])],64)),t(u,{label:pt.value?`Start over`:X.value<0?`Walk the cell`:`Next part`,glyph:`▸`,onClick:mt},null,8,[`label`])]),readout:e(()=>[Z.value?(m(),a(s,{key:0},[i(`div`,tt,[t(h,{expr:Z.value.latex},null,8,[`expr`]),o[18]||=i(`span`,{class:`dl-gcell__arrow`},`→`,-1),t(h,{expr:Z.value.numeric()},null,8,[`expr`])]),i(`div`,null,[i(`strong`,null,n(Z.value.name)+`.`,1),d(` `+n(Z.value.note),1)])],64)):I.variant===`lstm`?(m(),a(s,{key:1},[o[19]||=d(` c`,-1),o[20]||=i(`sub`,null,`t`,-1),d(` = `+n(l(_)(R.value))+`×`+n(l(_)(L.value))+` + `+n(l(_)(z.value))+`×`+n(l(_)(B.value))+` = `,1),i(`strong`,null,n(l(_)(K.value.c)),1),o[21]||=d(`, and h`,-1),o[22]||=i(`sub`,null,`t`,-1),o[23]||=d(` = `,-1),i(`strong`,null,n(l(_)(K.value.h)),1),o[24]||=d(`. Set `,-1),o[25]||=i(`em`,null,`f`,-1),o[26]||=d(` = 1 and `,-1),o[27]||=i(`em`,null,`i`,-1),o[28]||=d(` = 0: the cell state passes through untouched, for as many steps as you like. The gates here are set directly — in a real cell each is its own σ(Wx + Wh + b). `,-1)],64)):(m(),a(s,{key:2},[o[29]||=d(` h`,-1),o[30]||=i(`sub`,null,`t`,-1),d(` = `+n(l(_)(1-G.value))+`×`+n(l(_)(H.value))+` + `+n(l(_)(G.value))+`×`+n(l(_)(q.value))+` = `,1),i(`strong`,null,n(l(_)(J.value.h)),1),o[31]||=d(`. Two gates instead of three, one state instead of two, and the kept and written shares always sum to 1 — so a GRU cannot forget without writing. `,-1)],64))]),default:e(()=>[I.variant===`lstm`?(m(),a(`svg`,{key:0,class:`dl-gcell`,viewBox:`0 0 ${v} ${y}`,preserveAspectRatio:`xMidYMid meet`,role:`img`,"aria-label":`An LSTM memory block: the cell state runs across the top through a multiply by the forget gate and an add of the input gate times the candidate; the hidden state leaves through the output gate`},[o[17]||=i(`defs`,null,[i(`marker`,{id:`dl-gcell-arrow`,viewBox:`0 0 8 8`,refX:`7`,refY:`4`,markerWidth:`5`,markerHeight:`5`,orient:`auto-start-reverse`},[i(`path`,{d:`M0,0 L8,4 L0,8 z`,fill:`currentColor`})])],-1),f(` The cell state: one straight line from edge to edge. `),i(`g`,{class:p([`dl-gcell__highway`,Q(`cin`)])},[i(`line`,{x1:26,y1:b,x2:167,y2:b,"marker-end":`url(#dl-gcell-arrow)`},null,8,ue),i(`text`,{class:`dl-gcell__port`,x:22,y:50,"text-anchor":`end`},[...o[9]||=[d(`c`,-1),i(`tspan`,{class:`dl-gcell__sub`,dy:`3`},`t−1`,-1)]],8,de)],2),i(`line`,{class:p([`dl-gcell__highway-seg`,Q(`fmul`)]),x1:193,y1:b,x2:287,y2:b,"marker-end":`url(#dl-gcell-arrow)`},null,10,fe),i(`g`,{class:p([`dl-gcell__highway`,Q(`cout`)])},[i(`line`,{x1:313,y1:b,x2:520,y2:b,"marker-end":`url(#dl-gcell-arrow)`},null,8,pe),i(`text`,{class:`dl-gcell__port`,x:526,y:50},[...o[10]||=[d(`c`,-1),i(`tspan`,{class:`dl-gcell__sub`,dy:`3`},`t`,-1)]],8,me)],2),f(` forget: × on the highway, fed by a sigmoid `),i(`g`,{class:p(Q(`fmul`))},[i(`circle`,{class:`dl-gcell__node`,cx:T,cy:b,r:N}),i(`text`,{class:`dl-gcell__op`,x:T,y:51,"text-anchor":`middle`},`×`,8,he)],2),i(`line`,{class:p([`dl-gcell__wire`,Q(`fgate`)]),x1:T,y1:x,x2:T,y2:63,"marker-end":`url(#dl-gcell-arrow)`},null,10,ge),i(`g`,{class:p(Q(`fgate`))},[i(`rect`,{class:`dl-gcell__gate`,x:T-S/2,y:x,width:S,height:C,rx:`5`},null,8,_e),i(`text`,{class:`dl-gcell__gatelabel`,x:T,y:181,"text-anchor":`middle`},`σ = `+n(l(_)(R.value)),9,ve),i(`text`,{class:`dl-gcell__gatename`,x:164,y:157,"text-anchor":`end`},[...o[11]||=[d(`f`,-1),i(`tspan`,{class:`dl-gcell__sub`,dy:`3`},`t`,-1)]],8,ye)],2),f(` input × candidate, then + on to the highway `),i(`g`,{class:p(Q(`igmul`))},[i(`circle`,{class:`dl-gcell__node`,cx:D,cy:nt,r:N}),i(`text`,{class:`dl-gcell__op`,x:D,y:113,"text-anchor":`middle`},`×`,8,be),i(`line`,{class:`dl-gcell__wire`,x1:D,y1:95,x2:E,y2:63,"marker-end":`url(#dl-gcell-arrow)`},null,8,xe)],2),i(`line`,{class:p([`dl-gcell__wire`,Q(`igate`)]),x1:A,y1:x,x2:291,y2:117,"marker-end":`url(#dl-gcell-arrow)`},null,10,Se),i(`line`,{class:p([`dl-gcell__wire`,Q(`ggate`)]),x1:j,y1:x,x2:309,y2:117,"marker-end":`url(#dl-gcell-arrow)`},null,10,Ce),i(`g`,{class:p(Q(`igate`))},[i(`rect`,{class:`dl-gcell__gate`,x:A-S/2,y:x,width:S,height:C,rx:`5`},null,8,we),i(`text`,{class:`dl-gcell__gatelabel`,x:A,y:181,"text-anchor":`middle`},`σ = `+n(l(_)(z.value)),9,Te),i(`text`,{class:`dl-gcell__gatename`,x:246,y:157,"text-anchor":`end`},[...o[12]||=[d(`i`,-1),i(`tspan`,{class:`dl-gcell__sub`,dy:`3`},`t`,-1)]],8,Ee)],2),i(`g`,{class:p(Q(`ggate`))},[i(`rect`,{class:`dl-gcell__gate is-tanh`,x:j-S/2,y:x,width:S,height:C,rx:`5`},null,8,De),i(`text`,{class:`dl-gcell__gatelabel`,x:j,y:181,"text-anchor":`middle`},`tanh = `+n(l(_)(B.value)),9,Oe),i(`text`,{class:`dl-gcell__gatename`,x:354,y:157,"text-anchor":`start`},[...o[13]||=[d(`c̃`,-1),i(`tspan`,{class:`dl-gcell__sub`,dy:`3`},`t`,-1)]],8,ke)],2),i(`g`,{class:p(Q(`plus`))},[i(`circle`,{class:`dl-gcell__node is-plus`,cx:E,cy:b,r:N}),i(`text`,{class:`dl-gcell__op`,x:E,y:51,"text-anchor":`middle`},`+`,8,Ae)],2),f(` the branch that becomes h_t `),i(`g`,{class:p(Q(`ctanh`))},[i(`line`,{class:`dl-gcell__wire`,x1:O,y1:b,x2:O,y2:101,"marker-end":`url(#dl-gcell-arrow)`},null,8,je),i(`rect`,{class:`dl-gcell__gate is-tanh`,x:rt-S/2,y:105,width:S,height:C,rx:`5`},null,8,Me),i(`text`,{class:`dl-gcell__gatelabel`,x:rt,y:125,"text-anchor":`middle`},`tanh`,8,Ne)],2),i(`g`,{class:p(Q(`hmul`))},[i(`line`,{class:`dl-gcell__wire`,x1:426,y1:k,x2:453,y2:k,"marker-end":`url(#dl-gcell-arrow)`},null,8,Pe),i(`circle`,{class:`dl-gcell__node`,cx:it,cy:k,r:N}),i(`text`,{class:`dl-gcell__op`,x:it,y:125,"text-anchor":`middle`},`×`,8,Fe)],2),i(`line`,{class:p([`dl-gcell__wire`,Q(`ogate`)]),x1:M,y1:x,x2:M,y2:137,"marker-end":`url(#dl-gcell-arrow)`},null,10,Ie),i(`g`,{class:p(Q(`ogate`))},[i(`rect`,{class:`dl-gcell__gate`,x:M-S/2,y:x,width:S,height:C,rx:`5`},null,8,Le),i(`text`,{class:`dl-gcell__gatelabel`,x:M,y:181,"text-anchor":`middle`},`σ = `+n(l(_)(V.value)),9,Re),i(`text`,{class:`dl-gcell__gatename`,x:454,y:157,"text-anchor":`end`},[...o[14]||=[d(`o`,-1),i(`tspan`,{class:`dl-gcell__sub`,dy:`3`},`t`,-1)]],8,ze)],2),i(`g`,{class:p(Q(`hout`))},[i(`line`,{class:`dl-gcell__wire`,x1:483,y1:k,x2:520,y2:k,"marker-end":`url(#dl-gcell-arrow)`},null,8,Be),i(`text`,{class:`dl-gcell__port`,x:526,y:124},[...o[15]||=[d(`h`,-1),i(`tspan`,{class:`dl-gcell__sub`,dy:`3`},`t`,-1)]],8,Ve)],2),f(` what every gate reads: this step's input and the last hidden state `),i(`g`,{class:p(Q(`bus`))},[i(`rect`,{class:`dl-gcell__inbox`,x:20,y:221,width:112,height:30,rx:`5`},null,8,He),i(`text`,{class:`dl-gcell__inlabel`,x:76,y:240,"text-anchor":`middle`},[...o[16]||=[d(`x`,-1),i(`tspan`,{class:`dl-gcell__sub`,dy:`3`},`t`,-1),i(`tspan`,{dy:`-3`},`, h`,-1),i(`tspan`,{class:`dl-gcell__sub`,dy:`3`},`t−1`,-1)]],8,Ue),i(`line`,{class:`dl-gcell__bus`,x1:132,y1:w,x2:M,y2:w}),(m(!0),a(s,null,r([T,A,j,M],e=>(m(),a(`line`,{key:`stub${e}`,class:`dl-gcell__wire`,x1:e,y1:w,x2:e,y2:196,"marker-end":`url(#dl-gcell-arrow)`},null,8,We))),128))],2),i(`text`,{class:`dl-gcell__caption`,x:26,y:28},`the cell state — a multiply and an add, nothing else`,8,Ge)],8,le)):(m(),a(s,{key:1},[f(` The GRU, as the interpolation it is. `),(m(),a(`svg`,{class:`dl-gcell`,viewBox:`0 0 ${v} ${y}`,preserveAspectRatio:`xMidYMid meet`,role:`img`,"aria-label":`A GRU step shown as bars: the old state and the candidate, each scaled by the update gate, adding up to the new state`},[i(`line`,{class:`dl-gcell__zero`,x1:346,y1:26,x2:346,y2:246},null,8,qe),i(`text`,{class:`dl-gcell__tick`,x:P,y:20,"text-anchor":`middle`},`−1`),i(`text`,{class:`dl-gcell__tick`,x:346,y:20,"text-anchor":`middle`},`0`),i(`text`,{class:`dl-gcell__tick`,x:496,y:20,"text-anchor":`middle`},`+1`,8,Je),(m(!0),a(s,null,r(yt.value,(e,t)=>(m(),a(`g`,{key:e.key,class:p(Q(e.key))},[i(`text`,{class:`dl-gcell__rowlabel`,x:182,y:$(t)+14,"text-anchor":`end`},n(e.label),9,Ye),i(`rect`,{class:`dl-gcell__track`,x:P,y:$(t),width:F,height:20,rx:`3`},null,8,Xe),i(`rect`,{class:p([`dl-gcell__bar`,`is-${e.tone}`]),x:_t(e.value),y:$(t),width:vt(e.value),height:20,rx:`2`},null,10,Ze),i(`text`,{class:`dl-gcell__rowval`,x:508,y:$(t)+14},n(l(_)(e.value)),9,Qe)],2))),128)),i(`line`,{class:`dl-gcell__sep`,x1:40,y1:$(2)-14,x2:536,y2:$(2)-14},null,8,$e),i(`text`,{class:`dl-gcell__caption`,x:40,y:$(2)-20},`the blend`,8,et)],8,Ke))],2112))]),_:1})}}}),[[`__scopeId`,`data-v-bf0d1e22`]]);export{at as t};
|
lecture-05/assets/GatedCell-CMocJDE5.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
.dl-gcell[data-v-bf0d1e22]{width:100%;height:100%}.is-dim[data-v-bf0d1e22]{opacity:.2;transition:opacity .25s}.is-lit[data-v-bf0d1e22]{transition:opacity .25s}.dl-gcell__highway line[data-v-bf0d1e22],.dl-gcell__highway-seg[data-v-bf0d1e22]{stroke:var(--dl-accent);stroke-width:3px;color:var(--dl-accent)}.dl-gcell__wire[data-v-bf0d1e22]{stroke:var(--dl-muted);stroke-width:1.5px;color:var(--dl-muted)}.dl-gcell__bus[data-v-bf0d1e22]{stroke:var(--dl-border);stroke-width:2px}.dl-gcell__node[data-v-bf0d1e22]{fill:var(--dl-bg);stroke:var(--dl-heading);stroke-width:1.5px}.dl-gcell__node.is-plus[data-v-bf0d1e22]{stroke:var(--dl-accent)}.dl-gcell__op[data-v-bf0d1e22]{fill:var(--dl-heading);font-size:14px;font-weight:700}.dl-gcell__gate[data-v-bf0d1e22]{fill:var(--dl-accent-soft);stroke:var(--dl-accent);stroke-width:1.2px}.dl-gcell__gate.is-tanh[data-v-bf0d1e22]{fill:var(--dl-surface);stroke:var(--dl-body)}.dl-gcell__gatelabel[data-v-bf0d1e22]{fill:var(--dl-heading);font-variant-numeric:tabular-nums;font-size:11px;font-weight:600}.dl-gcell__gatename[data-v-bf0d1e22]{fill:var(--dl-heading);font-size:12px;font-style:italic;font-weight:600}.dl-gcell__gateval[data-v-bf0d1e22]{fill:var(--dl-accent-strong);font-variant-numeric:tabular-nums;font-size:10.5px;font-weight:600}.dl-gcell__port[data-v-bf0d1e22]{fill:var(--dl-heading);font-size:13px;font-style:italic;font-weight:600}.dl-gcell__sub[data-v-bf0d1e22]{font-size:8.5px;font-style:normal;font-weight:400}.dl-gcell__inbox[data-v-bf0d1e22]{fill:var(--dl-surface);stroke:var(--dl-border);stroke-width:1px}.dl-gcell__inlabel[data-v-bf0d1e22]{fill:var(--dl-heading);font-size:12px;font-style:italic;font-weight:600}.dl-gcell__caption[data-v-bf0d1e22]{fill:var(--dl-muted);font-size:10.5px}.dl-gcell__zero[data-v-bf0d1e22]{stroke:var(--dl-muted);stroke-width:1px;stroke-dasharray:3 4}.dl-gcell__sep[data-v-bf0d1e22]{stroke:var(--dl-border);stroke-width:1px}.dl-gcell__tick[data-v-bf0d1e22]{fill:var(--dl-muted);font-size:10px}.dl-gcell__track[data-v-bf0d1e22]{fill:var(--dl-surface);stroke:var(--dl-border);stroke-width:1px}.dl-gcell__bar[data-v-bf0d1e22]{transition:x .15s,width .15s}.dl-gcell__bar.is-old[data-v-bf0d1e22]{fill:var(--dl-muted)}.dl-gcell__bar.is-new[data-v-bf0d1e22]{fill:var(--dl-accent)}.dl-gcell__bar.is-result[data-v-bf0d1e22]{fill:var(--dl-accent-strong)}.dl-gcell__rowlabel[data-v-bf0d1e22]{fill:var(--dl-heading);font-size:11.5px;font-weight:600}.dl-gcell__rowval[data-v-bf0d1e22]{fill:var(--dl-body);font-variant-numeric:tabular-nums;font-size:11px}.dl-gcell__eq[data-v-bf0d1e22]{flex-wrap:wrap;align-items:center;gap:.5rem;margin-bottom:.15rem;display:flex}.dl-gcell__arrow[data-v-bf0d1e22]{color:var(--dl-muted)}
|
lecture-05/assets/GradientFlow-B-uOpJPB.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
import{$ as e,S as t,St as n,_ as r,b as i,c as a,et as o,g as s,m as c,ut as l,v as u,vt as d,w as f,x as p,y as m,z as h}from"./modules/shiki-CkJq9tSf.js";import{t as g}from"./_plugin-vue_export-helper-BDNMzG2s.js";import{n as _}from"./slidev/context-DnYiQGy6.js";import{a as v,f as y}from"./useRecurrence-PhWWMav6.js";import{n as b}from"./interactive-pqWNz3EB.js";import{t as x}from"./Slider-Bf0ITYx4.js";import{t as S}from"./Plot2D-C9URVmMB.js";import{t as C}from"./PlotLabel-BilrlAqg.js";import{n as w,t as T}from"./PlotLine-yjOYb3U7.js";var E={key:1,class:`dl-gflow__toggle`},D=5,O=-12,k=4,A=g(f({__name:`GradientFlow`,props:{mode:{default:`decay`},steps:{default:25},w:{default:.6},forget:{default:.99},clip:{type:Boolean,default:!0}},setup(f){let{$slidev:g,$nav:A,$clicksContext:j,$clicks:M,$page:N,$renderContext:P,$frontmatter:F}=_(),I=f,L=l(I.w),R=l(I.forget),z=l(!1),B=Math.log10(D);function V(e,t){return v(e,I.steps).map((e,n)=>{let r=e===0?-13:Math.log10(e);return{x:n,y:t&&r>B?B:r}})}let H=s(()=>V(L.value,z.value&&I.clip)),U=s(()=>V(R.value,!1)),W=s(()=>Math.abs(L.value-1)<1e-9?`hold`:L.value<1?`vanish`:`explode`),G=s(()=>Math.abs(L.value)**Math.min(20,I.steps)),K=s(()=>Math.abs(R.value)**Math.min(20,I.steps)),q=s(()=>y(L.value,.01)),J={0:`⁰`,1:`¹`,2:`²`,3:`³`,4:`⁴`,5:`⁵`,6:`⁶`,7:`⁷`,8:`⁸`,9:`⁹`,"-":`⁻`,"+":``};function Y(e){if(e===0)return`0`;let t=Math.abs(e);if(t>=.001&&t<1)return String(Number(e.toPrecision(2)));if(t>=1&&t<1e4)return String(Number(e.toPrecision(3)));let[n,r]=e.toExponential(1).split(`e`);return`${n} \u00d7 10${[...r].map(e=>J[e]??e).join(``)}`}return(s,l)=>{let f=T,g=w,_=C,v=S,y=x,A=b;return h(),u(A,{"max-width":`34rem`},{controls:e(()=>[t(y,{modelValue:L.value,"onUpdate:modelValue":l[0]||=e=>L.value=e,label:`recurrent weight W`,min:.2,max:1.6,step:.05,precision:2},null,8,[`modelValue`]),I.mode===`gated`?(h(),u(y,{key:0,modelValue:R.value,"onUpdate:modelValue":l[1]||=e=>R.value=e,label:`forget gate f`,min:.8,max:1,step:.005,precision:3},null,8,[`modelValue`])):m(`v-if`,!0),I.clip&&I.mode===`decay`?(h(),i(`label`,E,[o(r(`input`,{"onUpdate:modelValue":l[2]||=e=>z.value=e,type:`checkbox`},null,512),[[a,z.value]]),l[3]||=p(` gradient clipping `,-1)])):m(`v-if`,!0)]),readout:e(()=>[I.mode===`gated`?(h(),i(c,{key:0},[l[4]||=p(` Twenty steps back, the plain recurrence has multiplied by `,-1),r(`strong`,null,n(Y(G.value)),1),l[5]||=p(`; the cell state, by `,-1),r(`strong`,null,n(Y(K.value)),1),l[6]||=p(`. Push `,-1),l[7]||=r(`em`,null,`f`,-1),l[8]||=p(` to 1.000 and the factor is exactly `,-1),l[9]||=r(`strong`,null,`1`,-1),l[10]||=p(` — the gradient reaches the start of the sequence undamaged. `,-1)],64)):W.value===`vanish`?(h(),i(c,{key:1},[l[11]||=r(`strong`,null,`Vanishing.`,-1),p(` Twenty steps back the gradient carries a factor of `+n(L.value.toFixed(2)),1),l[12]||=r(`sup`,null,`20`,-1),l[13]||=p(` = `,-1),r(`strong`,null,n(Y(G.value)),1),l[14]||=p(`. It is still worth 1% of its original size about `,-1),r(`strong`,null,n(q.value),1),l[15]||=p(` steps back — past that, the end of the sentence cannot teach the weights that read its beginning. `,-1)],64)):W.value===`hold`?(h(),i(c,{key:2},[l[16]||=r(`strong`,null,`The knife edge.`,-1),l[17]||=p(` At exactly 1 the gradient neither shrinks nor grows. Nothing keeps a trained weight there, and this is one number out of a whole matrix. `,-1)],64)):(h(),i(c,{key:3},[l[21]||=r(`strong`,null,`Exploding.`,-1),p(` `+n(L.value.toFixed(2)),1),l[22]||=r(`sup`,null,`20`,-1),l[23]||=p(` = `,-1),r(`strong`,null,n(Y(G.value)),1),p(`, and by step `+n(I.steps)+` it is `+n(Y(Math.abs(L.value)**I.steps))+`. One long sequence and the update overshoots — the loss goes to NaN in a single batch. `,1),I.clip?(h(),i(c,{key:0},[l[18]||=p(` Tick `,-1),l[19]||=r(`strong`,null,`gradient clipping`,-1),l[20]||=p(`: the ceiling caps it. Notice it does nothing at all to the vanishing end. `,-1)],64)):m(`v-if`,!0)],64))]),default:e(()=>[t(v,{"x-domain":[0,I.steps],"y-domain":[O,k],"x-ticks":[0,5,10,15,20,25].filter(e=>e<=I.steps),"y-ticks":[-12,-9,-6,-3,0,3],"x-label":`time steps back through the sequence`,"y-label":`log₁₀ of the gradient's size`,width:520,height:290},{default:e(()=>[m(` Unity: the gradient neither grows nor shrinks. `),t(f,{from:[0,0],to:[I.steps,0],color:`var(--dl-muted)`,width:1.2,dashed:``},null,8,[`to`]),z.value&&I.clip&&I.mode===`decay`?(h(),u(f,{key:0,from:[0,d(B)],to:[I.steps,d(B)],color:`var(--dl-danger)`,width:1.2,dashed:``},null,8,[`from`,`to`])):m(`v-if`,!0),t(g,{points:H.value,color:I.mode===`gated`?`var(--dl-danger)`:`var(--dl-accent)`,width:2.6},null,8,[`points`,`color`]),I.mode===`gated`?(h(),u(g,{key:1,points:U.value,color:`var(--dl-accent)`,width:2.6},null,8,[`points`])):m(`v-if`,!0),I.mode===`gated`?(h(),u(_,{key:2,at:[I.steps,U.value[I.steps].y],dx:-6,dy:-10,anchor:`end`,color:`var(--dl-accent)`,text:`LSTM cell state — multiplied by the forget gate`,size:11,bold:``},null,8,[`at`])):m(`v-if`,!0),I.mode===`gated`?(h(),u(_,{key:3,at:[I.steps,Math.min(Math.max(H.value[I.steps].y,-11),3)],dx:-6,dy:22,anchor:`end`,color:`var(--dl-danger)`,text:`plain RNN — multiplied by W`,size:11,bold:``},null,8,[`at`])):m(`v-if`,!0),z.value&&I.clip&&I.mode===`decay`?(h(),u(_,{key:4,at:[1,d(B)],dx:4,dy:-6,color:`var(--dl-danger)`,text:`clipped at ${D}×`,size:11},null,8,[`at`,`text`])):m(`v-if`,!0)]),_:1},8,[`x-domain`,`y-domain`,`x-ticks`])]),_:1})}}}),[[`__scopeId`,`data-v-d7ea900e`]]);export{A as t};
|
lecture-05/assets/GradientFlow-BJ1pHoOj.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
.dl-gflow__toggle[data-v-d7ea900e]{color:var(--dl-body);cursor:pointer;align-items:center;gap:.35rem;font-size:.82rem;display:inline-flex}.dl-gflow__toggle input[data-v-d7ea900e]{accent-color:var(--dl-accent);cursor:pointer}
|
lecture-05/assets/KaTeX_AMS-Regular-BQhdFMY1.woff2
ADDED
|
Binary file (28.1 kB). View file
|
|
|
lecture-05/assets/KaTeX_AMS-Regular-DMm9YOAa.woff
ADDED
|
Binary file (33.5 kB). View file
|
|
|
lecture-05/assets/KaTeX_AMS-Regular-DRggAlZN.ttf
ADDED
|
Binary file (63.6 kB). View file
|
|
|
lecture-05/assets/KaTeX_Caligraphic-Bold-ATXxdsX0.ttf
ADDED
|
Binary file (12.4 kB). View file
|
|
|
lecture-05/assets/KaTeX_Caligraphic-Bold-BEiXGLvX.woff
ADDED
|
Binary file (7.72 kB). View file
|
|
|
lecture-05/assets/KaTeX_Caligraphic-Bold-Dq_IR9rO.woff2
ADDED
|
Binary file (6.91 kB). View file
|
|
|
lecture-05/assets/KaTeX_Caligraphic-Regular-CTRA-rTL.woff
ADDED
|
Binary file (7.66 kB). View file
|
|
|
lecture-05/assets/KaTeX_Caligraphic-Regular-Di6jR-x-.woff2
ADDED
|
Binary file (6.91 kB). View file
|
|
|
lecture-05/assets/KaTeX_Caligraphic-Regular-wX97UBjC.ttf
ADDED
|
Binary file (12.3 kB). View file
|
|
|
lecture-05/assets/KaTeX_Fraktur-Bold-BdnERNNW.ttf
ADDED
|
Binary file (19.6 kB). View file
|
|
|
lecture-05/assets/KaTeX_Fraktur-Bold-BsDP51OF.woff
ADDED
|
Binary file (13.3 kB). View file
|
|
|
lecture-05/assets/KaTeX_Fraktur-Bold-CL6g_b3V.woff2
ADDED
|
Binary file (11.3 kB). View file
|
|
|
lecture-05/assets/KaTeX_Fraktur-Regular-CB_wures.ttf
ADDED
|
Binary file (19.6 kB). View file
|
|
|
lecture-05/assets/KaTeX_Fraktur-Regular-CTYiF6lA.woff2
ADDED
|
Binary file (11.3 kB). View file
|
|
|
lecture-05/assets/KaTeX_Fraktur-Regular-Dxdc4cR9.woff
ADDED
|
Binary file (13.2 kB). View file
|
|
|
lecture-05/assets/KaTeX_Main-Bold-Cx986IdX.woff2
ADDED
|
Binary file (25.3 kB). View file
|
|
|
lecture-05/assets/KaTeX_Main-Bold-Jm3AIy58.woff
ADDED
|
Binary file (29.9 kB). View file
|
|
|
lecture-05/assets/KaTeX_Main-Bold-waoOVXN0.ttf
ADDED
|
Binary file (51.3 kB). View file
|
|
|
lecture-05/assets/KaTeX_Main-BoldItalic-DxDJ3AOS.woff2
ADDED
|
Binary file (16.8 kB). View file
|
|
|
lecture-05/assets/KaTeX_Main-BoldItalic-DzxPMmG6.ttf
ADDED
|
Binary file (33 kB). View file
|
|
|
lecture-05/assets/KaTeX_Main-BoldItalic-SpSLRI95.woff
ADDED
|
Binary file (19.4 kB). View file
|
|
|
lecture-05/assets/KaTeX_Main-Italic-3WenGoN9.ttf
ADDED
|
Binary file (33.6 kB). View file
|
|
|
lecture-05/assets/KaTeX_Main-Italic-BMLOBm91.woff
ADDED
|
Binary file (19.7 kB). View file
|
|
|
lecture-05/assets/KaTeX_Main-Italic-NWA7e6Wa.woff2
ADDED
|
Binary file (17 kB). View file
|
|
|
lecture-05/assets/KaTeX_Main-Regular-B22Nviop.woff2
ADDED
|
Binary file (26.3 kB). View file
|
|
|
lecture-05/assets/KaTeX_Main-Regular-Dr94JaBh.woff
ADDED
|
Binary file (30.8 kB). View file
|
|
|
lecture-05/assets/KaTeX_Main-Regular-ypZvNtVU.ttf
ADDED
|
Binary file (53.6 kB). View file
|
|
|
lecture-05/assets/KaTeX_Math-BoldItalic-B3XSjfu4.ttf
ADDED
|
Binary file (31.2 kB). View file
|
|
|
lecture-05/assets/KaTeX_Math-BoldItalic-CZnvNsCZ.woff2
ADDED
|
Binary file (16.4 kB). View file
|
|
|
lecture-05/assets/KaTeX_Math-BoldItalic-iY-2wyZ7.woff
ADDED
|
Binary file (18.7 kB). View file
|
|
|
lecture-05/assets/KaTeX_Math-Italic-DA0__PXp.woff
ADDED
|
Binary file (18.7 kB). View file
|
|
|
lecture-05/assets/KaTeX_Math-Italic-flOr_0UB.ttf
ADDED
|
Binary file (31.3 kB). View file
|
|
|
lecture-05/assets/KaTeX_Math-Italic-t53AETM-.woff2
ADDED
|
Binary file (16.4 kB). View file
|
|
|
lecture-05/assets/KaTeX_SansSerif-Bold-CFMepnvq.ttf
ADDED
|
Binary file (24.5 kB). View file
|
|
|
lecture-05/assets/KaTeX_SansSerif-Bold-D1sUS0GD.woff2
ADDED
|
Binary file (12.2 kB). View file
|
|
|