11 Neural Networks
🆕 Գլխի բոլոր դասախոսություններն անցկացված են ([40], [41_1], [41_2], [42], [43], [44], [45])։ Սլայդերը և նշումներով PDF-երը ներքևում են, տեսանյութերը՝ շուտով։
🎲 Random
TBD
📚 Նյութը
Սլայդերը հիմնված են LMU-ի Introduction to Deep Learning դասընթացի սլայդերի վրա՝ մեր լրացումներով։ Սլայդերը ml/11_neural_networks/ պանակում։
[40] Խորը ուսուցում. ներածություն և պատմություն — ինչ է deep learning-ը, համառոտ պատմություն, և ինչ է այն անում այսօր․ ոլորտի և ինդուստրիայի վիճակը, Bun-ի Rust-ով վերագրումը AI գործակալներով, generative մեդիա, ռոբոտներ, AI-ը գիտության մեջ (AlphaFold, Էրդյոշի խնդիրներ, Նավիե-Սթոքսի case study, AlphaEvolve), մարդիկ, և ինչպես շարունակել սովորել։ 🎞️ Սլայդեր · 📝 PDF (նշումներով) · 📺 տեսանյութը՝ շուտով
[41_1] Նեյրոնից՝ ցանց — մեկ նեյրոնը (լոգիստիկ ռեգրեսիան՝ որպես նեյրոն), XOR-ը և ինչու մեկ նեյրոնը բավական չէ, մեկ թաքնված շերտ, ակտիվացիոն ֆունկցիաներ, ինչպես է ReLU-ն «ծալում» տարածությունը։ 🎞️ Սլայդեր · 📝 PDF (նշումներով) · 📺 տեսանյութը՝ շուտով
[41_2] Բազմաշերտ ցանցեր — մատրիցային նշանակումներ և չափերի հետևում, բազմաշերտ ցանցեր, ինչու է խորությունը ավելի արդյունավետ, քան լայնությունը (2081 vs 72,807,417 տիրույթ), բազմադասային դասակարգում և softmax, ունիվերսալ մոտարկման թեորեմը և նրա «մանր տառերը»։ 🎞️ Սլայդեր · 📝 PDF (նշումներով) · 📺 տեսանյութը՝ շուտով
[42] Ցանցի ուսուցում. գրադիենտային իջեցում և backpropagation — էմպիրիկ ռիսկի մինիմիզացիա, gradient descent և SGD, հաշվարկային գրաֆներ, backpropagation-ը քայլ առ քայլ (XOR-ի ձեռքով օրինակը՝ LMU-ի թվաբանական վրիպակի ուղղումով), δ-երի ռեկուրսիան և քեշավորումը, vanishing gradients, softmax-ի գրադիենտը՝ որպես «քաշել-հրել»,
loss.backward()-ը մեկ տողում, ինչու է backprop-ը «leaky abstraction», ինչ է փոխվել սարքավորումներում մինչև 2026, GPU-ի վարձակալություն և փորձերի հետագծում (Weights & Biases)։ 🎞️ Սլայդեր · 📝 PDF (նշումներով) · 📺 տեսանյութը՝ շուտով[43] Ռեգուլյարացիա — weight decay-ը՝ որպես Ridge, early stopping, ուսուցման կորերը կարդալը, ցանցն անգիր է անում պատահական պիտակները (Zhang et al.), double descent և scaling laws, dropout (այդ թվում՝ inverted dropout-ի մասշտաբավորումը PyTorch-ում և ինչու է այն այսօր անջատվում LLM-երի նախապատրաստման ժամանակ), տվյալների ավգմենտացիա և «որ կոճակը երբ» աղյուսակը։ 🎞️ Սլայդեր · 📝 PDF (նշումներով) · 📺 տեսանյութը՝ շուտով
[44] Օպտիմիզացիա (1/2). ինչն է դժվարացնում ուսուցումը և ինչպես ենք արագացնում այն — վատ պայմանավորված Հեսսյան, լոկալ մինիմումներ, թամբակետեր և ժայռեր (gradient clipping), ինչու է SGD-ն այնուամենայնիվ աշխատում, momentum և Nesterov, ուսուցման քայլի ժամանակացույցեր (այդ թվում՝ warmup + cosine), AdaGrad/RMSProp/Adam, Adam-ից AdamW երեք սլայդով (չափված համեմատությամբ), BatchNorm և LayerNorm։ 🎞️ Սլայդեր · 📝 PDF (նշումներով) · 📺 տեսանյութը՝ շուտով
[45] Օպտիմիզացիա (2/2). սկզբնարժեքավորում և ակտիվացիաներ — ինչու է կարևոր սկզբնարժեքավորումը, Glorot-ը և He-ի \(2/m\)-ի արտածումը (և չափումը), ինչ կորուստ պետք է սպասել ուսուցումից առաջ (\(\ln C\)), ակտիվացիոն ֆունկցիաները՝ որպես բանաձևեր (սիգմոիդ, tanh, ReLU-ների ընտանիք, GELU), որ ակտիվացիան երբ, ժամանակակից ցանցերի գերվստահությունը (կալիբրացիա), երկու լուռ սխալ տնայինում և չորս էժան ստուգում՝ երկար ուսուցումից առաջ, գլխի ամփոփում։ 🎞️ Սլայդեր · 📝 PDF (նշումներով) · 📺 տեսանյութը՝ շուտով
Օպտիմիզատորների (SGD, momentum, Adam) մանրամասների համար՝ Optim մոդուլը (09 Optim: Prerequisites and Gradient Descent, 10 Optim: Momentum + First Order Methods)։
Օգտակար նյութեր (դասին ցույց տրվածները):
- TensorFlow Playground — ցանցը սովորում է հենց բրաուզերում. վերցրեք XOR կամ spiral տվյալները, սկսեք 0 թաքնված շերտից, հետո ավելացրեք շերտեր ու նեյրոններ։
- 📺 Neural networks — 3Blue1Brown-ի playlist-ը, կշիռների ամենապարզ վիզուալ ինտուիցիան։
- MLU-Explain: Neural Networks — կարճ, ինտերակտիվ բացատրություն։
- 📺 The spelled-out intro to neural networks and backpropagation: building micrograd — Andrej Karpathy, նեյրոնն ու backpropagation-ը զրոյից Python-ով (📺 Neural Networks: Zero to Hero playlist-ի առաջին տեսանյութը)։
- 📺 Why Deep Learning Works Unreasonably Well [How Models Learn Part 3] — Welch Labs, «ծալելու» և խորության երկրաչափությունը. սլայդերի Welch Labs նկարներն այս տեսանյութից են։
📝 Թեմայի վերաբերյալ հարցաշար (Google Form): TBD
🧪 Գործնական — The Armenian Name Inventor
Instructor-led practical (դասի ընթացքում միասին ենք անցնում). We build a character-level language model — an embedding layer plus the MLP from [41]-[43], nothing else — train it on 689 հայկական ազգանուն scraped from Armenian Wikipedia, and have it invent surnames that do not exist: Ավանիբեկյան, Ղամիրյան, Զոդոյան, Քոլաջյան… This is literally the architecture of the first neural language model (Bengio et al., 2003) — the direct ancestor of every modern LLM, at ~8.5k parameters.
Two tools make their course debut here, both explained from zero inside the notebook:
- PyTorch — tensors,
nn.Module, autograd, and the training loop, introduced at the exact moment each is needed; - Weights & Biases — experiment tracking: named runs, loss curves against a clueless-guessing baseline, tables of generated names per epoch (watch «-յան» get learned in the first epochs), and a one-run hyperparameter comparison with multi-line charts.
Along the way: early stopping (the val minimum arrives fast), overfitting as memorization (the net starts reciting real surnames — the same failure that makes LLMs leak training data), the temperature knob, PCA on the learned character embeddings, and steering generation with a prefix (everyone makes surnames from their own initials).
Notebook: xx_name_inventor_solution.ipynb (download) · view on GitHub
Data prep (already pinned, no internet needed): py_src/fetch_surnames.py → data/surnames_hy.txt
🏡 Տնային
Practical — Train your first neural network (Fashion-MNIST) 🧀🧀
Train a multilayer perceptron on Fashion-MNIST (28×28 grayscale clothing images, 10 classes) and run the experiments from L15. Framework: PyTorch; everything runs on a laptop CPU in a couple of minutes (subsample the data - the starter notes how).
The arc mirrors the lectures: build the net (L14) → train it and fight overfitting (L15). At every step, plot and read the training curves - that habit is the real lesson.
Tasks (1-5 graded; bonuses optional):
- Data + a linear baseline 🧀 — load Fashion-MNIST, flatten to 784-vectors, scale to [0, 1], split off a validation set. Fit logistic regression (a single softmax “neuron”, L14) and report its test accuracy - the floor your network must beat.
- Build + train an MLP 🧀🧀 — define an
nn.ModuleMLP and write the training loop (forward → loss →zero_grad→backward→step). Train with Adam and beat the baseline. - Learning-rate sweep 🧀🧀 — train the same architecture at three learning rates, plot the training loss, and say which is too high, too low, and just right.
- Dropout + weight decay 🧀🧀 — add dropout and L2 weight decay (= Ridge, L01b). Compare the train/val gap with and without. Does regularization improve validation accuracy?
- BatchNorm + early stopping 🧀🧀🧀 — on a deeper net, compare training with vs without BatchNorm; then add early stopping on validation loss and report the epoch it picks.
- Bonus 🎁 — backprop from scratch: reimplement the L15 worked example (the 2-2-1 sigmoid net) in numpy - forward, backward, and a gradient check against finite differences. You should recover
f - y = -0.31and a falling loss. - Bonus 🎁 — tuning push: get test accuracy as high as you can (wider net, dropout, weight decay, early stopping; for a real search reuse grid / random / Optuna from lecture [08]). On the 10k subsample an MLP tops out around 85%; the biggest lever is more data - the full 60k training set gets an MLP to roughly 88%.
Solution: nn_practical_solution.ipynb (download) · view on GitHub