Chapterبەش 8 · Lectureوانە 8.2
Neural Networks and Deep Learningتۆڕە دەمارییەکان و فێربوونی قووڵ
How an artificial neuron computes (weights, bias, ReLU and sigmoid), layers and why "deep", the forward pass, the loss, gradient descent with a learning rate, backpropagation, epochs and early stopping, why XOR needs a hidden layer (a 2-2-1 network trained in plain Python), convolutional networks for pictures, a network that found planets, RNNs and transformers, the bridge to generative AI, and why deep learning took off in 2012 (ImageNet, AlexNet, GPUs) up to the 2024 Nobel Prize.
چۆن حیساب دەکات (، ، و )، و بۆچی «قووڵ»، ، زیان، بە ، ، و ڕاگرتنی زوو، بۆچی XOR پێویستی بە هەیە (تۆڕێکی 2-2-1 کە بە Pythonـی سادە ڕاهێنراوە)، بۆ وێنە، تۆڕێک کە هەسارەی دۆزییەوە، و ، پردی و بۆچی لە 2012دا هەستایەوە (ImageNet، AlexNet، ) تا خەڵاتی نۆبڵی 2024.
What you will learnچی فێر دەبیت
- Compute the output of an artificial neuron from its inputs, weights, bias and activation function (ReLU, sigmoid).
- Describe the input, hidden and output layers, count a network's weights and biases, and explain what "deep" means.
- Explain the training loop: forward pass, loss, backpropagation and gradient descent with a learning rate, epochs and early stopping.
- Run and read a small neural network in plain Python that learns XOR, and explain why XOR needs a hidden layer.
- Explain how a CNN uses filters and pooling on pictures, and what RNNs and transformers do with sequences.
- Explain why deep learning took off after 2010 (big data, GPUs, better methods) and name its milestones up to the 2024 Nobel Prize.
- لە ، ، و (، ) حیساب بکەیت.
- ، و باس بکەیت، و تۆڕێک بژمێریت و ڕوونی بکەیتەوە «قووڵ» واتای چییە.
- ڕاهێنان ڕوون بکەیتەوە: ، زیان، و بە ، و ڕاگرتنی زوو.
- تۆڕێکی دەماریی بچووک بە Pythonـی سادە کە XOR فێر دەبێت کار پێ بکەیت و بیخوێنیتەوە و ڕوونی بکەیتەوە بۆچی XOR پێویستی بە هەیە.
- ڕوونی بکەیتەوە چۆن و لەسەر وێنە بەکار دەهێنێت و و چی لە زنجیرەدا دەکەن.
- ڕوونی بکەیتەوە بۆچی دوای 2010 هەستایەوە (، ، ڕێگای باشتر) و قۆناغە گرنگەکانی تا خەڵاتی نۆبڵی 2024 ناو ببەیت.
From one neuron to deep learningلە یەک دەمارەخانەی دەستکردەوە تا فێربوونی قووڵ
In Machine Learning Basics a model learned a rule from examples. Most of today's AI, from voice typing and photo search to chatbots, is built from one kind of model: the neural network. When a network has many layers, learning with it is called deep learning.
لە بنەماکانی فێربوونی ئامێردا یاسایەکی لە نموونەکانەوە فێر بوو. زۆربەی ئەمڕۆ، لە نووسین بە دەنگ و گەڕان لە وێنەکانەوە تا ، لە یەک جۆر دروست کراوە: . کاتێک تۆڕێک چەندین هەبێت، فێربوون پێی پێی دەگوترێت .
This lesson builds the idea from the bottom up: one artificial neuron, then layers, then how a network learns from its own mistakes. You will train a small network in Python, see how networks read pictures, and learn why deep learning suddenly worked after 2012.
ئەم وانەیە بیرۆکەکە لە خوارەوە بۆ سەرەوە بنیات دەنێت: یەک ، پاشان ، پاشان تۆڕێک چۆن لە هەڵەکانی خۆیەوە فێر دەبێت. تۆڕێکی بچووک بە Python ڕادەهێنیت، دەبینیت تۆڕەکان چۆن وێنە دەخوێننەوە و تێدەگەیت بۆچی لە دوای 2012 لەناکاو سەرکەوت.
How AI, machine learning, deep learning and generative AI fit inside each other, and how each one grew in time.
چۆن ، ، و یەک لەناو یەکدان و هەر یەکەیان بە درێژایی کات چۆن گەشەی کردووە.
Plays 4:48–9:08: deep learning (neural networks), foundation models, large language models as a kind of autocomplete, generative AI for text, audio and video, and deepfakes.
لە 4:48 تا 9:08 لێدەدرێت: ()، ، وەک جۆرێک لە تەواوکەری خۆکار، بۆ دەق و دەنگ و ڤیدیۆ، هەروەها ڤیدیۆ و دەنگی ساختە (deepfakes).
The artificial neuronدەمارەخانەی دەستکرد
An artificial neuron is a tiny calculator. It takes a few numbers (its inputs), multiplies each one by a weight that says how important it is, adds them up, and adds one more number, the bias. Then an activation function turns the sum into the neuron's output. The idea is loosely inspired by brain cells, but it is simple arithmetic.
بچووکە. چەند ژمارەیەک وەردەگرێت ()، هەریەکەیان لە دەدات کە دەڵێت چەند گرنگە، هەموویان کۆ دەکاتەوە و ژمارەیەکی تریش زیاد دەکات: . پاشان کۆکە دەکاتە . بیرۆکەکە کەمێک لە خانەکانی مێشکەوە وەرگیراوە، بەڵام تەنیا حیسابێکی سادەیە.
Kak Rebin sells pomegranates. He judges a fruit by its redness and its weight in his hand. Redness counts more for him (a bigger weight), and he only calls a fruit ripe when the evidence is strong (a negative bias, like a high bar to jump). That is one neuron.
کاک ڕێبین هەنار دەفرۆشێت. هەنارێک بە سووری و قورسییەکەی لە دەستیدا هەڵدەسەنگێنێت. سووری لای ئەو گرنگترە ( گەورەتر) و تەنیا کاتێک دەڵێت هەنارەکە پێگەیشتووە کە بەڵگەکان بەهێز بن ( نەرێنی، وەک بەربەستێکی بەرز). ئەمە یەک .
Where the analogy stops workingسنووری ئەم نموونەیە
A real neuron learns its weights from thousands of examples; Kak Rebin learned his from years at the bazaar.
لە تۆڕێکی ڕاستەقینەدا لە هەزاران نموونەوە فێر دەبن؛ کاک ڕێبین هی خۆی لە ساڵانی کارکردن لە بازاڕەوە فێر بوو.
The weighted sum z, then the activation function f.
کۆی قورسکراو z، پاشان f.
The artificial neuronدەمارەخانەی دەستکرد
Activation functions: ReLU and sigmoidکردارەکانی چالاککردن: ReLU و کرداری سیگمۆید
Why not pass the sum on as it is? Because sums of sums are still one straight line: a hundred layers without activation functions can do no more than one linear classifier. The activation function bends the line, and that lets layers build curved, complex shapes. Three are worth knowing:
بۆچی کۆکە وەک خۆی نانێرین؟ چونکە کۆی کۆکان هێشتا یەک هێڵی ڕاستە: سەد بەبێ لە یەک پۆلێنکەری هێڵی زیاتر ناکەن. هێڵەکە دەچەمێنێتەوە و ئەمە ڕێگە بە دەدات شێوەی چەماوە و ئاڵۆز دروست بکەن. سێیان شایەنی ناسینن:
- Step function: 0 or 1, yes or no. Rosenblatt's perceptron (1958) used it. It cannot be trained with gradient descent, because its slope is 0 almost everywhere.
- Sigmoid: squeezes any number between 0 and 1, so it suits a yes/no probability in the output layer.
- ReLU: keeps positive numbers and turns negative ones into 0. It is cheap to compute and trains well, so it is the usual choice in hidden layers today.
- : 0 یان 1، بەڵێ یان نەخێر. ـی Rosenblatt (1958) بەکاری دەهێنا. ناتوانرێت بە ڕابهێنرێت، چونکە لە زۆربەی شوێنەکاندا 0ـە.
- : هەر ژمارەیەک دەگوشێتە نێوان 0 و 1، بۆیە بۆ بەڵێ/نەخێر لە دەگونجێت.
- : ژمارەی ئەرێنی دەهێڵێتەوە و ژمارەی نەرێنی دەکاتە 0. حیسابکردنی هەرزانە و باش ڕادەهێنرێت، بۆیە ئەمڕۆ هەڵبژاردەی ئاسایییە لە .
The artificial neuronدەمارەخانەی دەستکرد
One neuron in Pythonیەک دەمارەخانەی دەستکرد بە Python
Here is Kak Rebin's neuron as a small Python program. It needs nothing but the math module (functions and zip are all you need). It checks two pomegranates, one red and heavy, one pale and light:
ئەمە کاک ڕێبینە وەک بچووکی Python. جگە لە math هیچی تری ناوێت (کردارەکان و zip بەسن). دوو هەنار دەپشکنێت، یەکێکیان سوور و قورس، ئەوی تر کاڵ و سووک:
import math
def sigmoid(z):
return 1 / (1 + math.exp(-z))
def relu(z):
return max(0.0, z)
def neuron(inputs, weights, bias):
z = sum(x * w for x, w in zip(inputs, weights)) + bias
return z
# A pomegranate: [redness, heaviness], each from 0 to 1
weights = [3.0, 2.0]
bias = -3.5
for fruit in ([0.9, 0.8], [0.3, 0.4]):
z = neuron(fruit, weights, bias)
print(f"{fruit}: z = {z:.2f}, sigmoid = {sigmoid(z):.3f}, ReLU = {relu(z):.2f}")[0.9, 0.8]: z = 0.80, sigmoid = 0.690, ReLU = 0.80 [0.3, 0.4]: z = -1.80, sigmoid = 0.142, ReLU = 0.00
Explain the codeڕوونکردنەوەی کۆدەکە
- Lineدێڕی 10
zippairs each input with its weight;sumadds the products; then the bias is added.zipهەر لەگەڵ جووت دەکات؛sumلێکدانەکان کۆ دەکاتەوە؛ پاشان زیاد دەکرێت.- Lineدێڕی 14-15
These numbers are chosen by hand here. In a real network, training finds them.
ئەم ژمارانە لێرەدا بە دەست هەڵبژێردراون. لە تۆڕێکی ڕاستەقینەدا ڕاهێنان دەیاندۆزێتەوە.
The red, heavy fruit gets 0.69 ("probably ripe"); the pale one gets 0.142. Notice what the bias does: with −3.5, the inputs must be strong before z becomes positive. In 1958 a neuron like this was a whole machine, Rosenblatt's Mark I Perceptron; today it is a few lines of code.
میوە سوور و قورسەکە 0.69 وەردەگرێت («ئەگەری زۆرە پێگەیشتبێت»)؛ کاڵەکە 0.142. سەرنج بدە چی دەکات: بە −3.5، دەبێت بەهێز بن پێش ئەوەی z ئەرێنی ببێت. لە 1958دا وەک ئەمە ئامێرێکی تەواو بوو، Mark I Perceptronـی Rosenblatt؛ ئەمڕۆ چەند دێڕێکی کۆدە.
Layers: input, hidden and outputچینەکان: نێوخستە، شاراوە و دەرخستە
One neuron can only draw one straight line. Put many neurons side by side and you get a layer; put layers one after another and you get a network. Every network has three kinds of layer:
یەک تەنیا دەتوانێت یەک هێڵی ڕاست بکێشێت. چەندین لە تەنیشت یەکتر دابنێ و دروست دەبێت؛ لە دوای یەکتر دابنێ و تۆڕێک دروست دەبێت. هەموو تۆڕێک سێ جۆر هەیە:
- The input layer only holds the numbers that go in (here: hours of study, hours of sleep, classes attended). It calculates nothing.
- Hidden layers sit in the middle. Each neuron gets every output of the layer before ("fully connected") and finds a pattern in them. Nobody tells them which pattern: training decides.
- The output layer gives the answer: one neuron for a yes/no question, or one neuron per class.
- تەنیا ئەو ژمارانە هەڵدەگرێت کە دەچنە ژوورەوە (لێرەدا: کاتژمێری خوێندن، کاتژمێری خەو، ئامادەبوون لە وانەکان). هیچ حیسابێک ناکات.
- لە ناوەڕاستدان. هەر هەموو پێشوو وەردەگرێت («تەواو بەستراو») و شێوازێک تێیاندا دەدۆزێتەوە. کەس پێیان ناڵێت کام شێواز: ڕاهێنان بڕیار دەدات.
- وەڵامەکە دەدات: یەک بۆ پرسیارێکی بەڵێ/نەخێر، یان یەک بۆ هەر پۆلێک.
Layers: input, hidden and outputچینەکان: نێوخستە، شاراوە و دەرخستە
Why deep? From pixels to "cat"بۆچی قووڵ؟ لە پیکسڵەکانەوە تا «پشیلە»
Deep simply means many layers. Google's glossary calls a network with more than one hidden layer a deep neural network; large modern models have dozens or even hundreds. Depth helps because each layer can build on the patterns found by the layer before. Take a network that decides whether a photo shows a cat:
قووڵ تەنیا واتە چەندین . فەرهەنگۆکی Google تۆڕێک کە زیاتر لە یەک هەبێت ناو دەنێت قووڵ؛ گەورەترین ئەمڕۆ دەیان یان تەنانەت سەدان هەیە. قووڵی یارمەتی دەدات، چونکە هەر دەتوانێت لەسەر ئەو شێوازانە بنیات بنێت کە پێشوو دۆزیونیەوە. تۆڕێک وەربگرە کە بڕیار دەدات ئایا وێنەیەک پشیلەی تێدایە:
- Input layer: the photo is cut into pixels; each pixel is a number for its colour or brightness (a picture is a grid of numbers).
- Hidden layers: the first one reacts to simple features such as edges and corners; the next ones combine them into shapes and textures (ears, eyes, fur), and later ones into a whole cat face.
- Output layer: here two neurons, cat and not cat. The bigger score wins: 0.9 for cat means "very likely a cat".
- : وێنەکە دەکرێت بە ؛ هەر ژمارەیەکە بۆ ڕەنگ یان ڕووناکییەکەی (وێنە تۆڕێکی ژمارەیە).
- : یەکەمیان بە تایبەتمەندیی سادە وەک لێوار و گۆشە دەجووڵێت؛ ئەوانەی دواتر ئەمانە دەکەن بە شێوە و ڕووکار (گوێ، چاو، موو) و ئەوانەی دواتریش بە ڕووخسارێکی تەواوی پشیلە.
- : لێرەدا دوو ، پشیلە و پشیلە نییە. نمرەی گەورەتر دەباتەوە: 0.9 بۆ پشیلە واتە «زۆر ئەگەری هەیە پشیلە بێت».
Layers: input, hidden and outputچینەکان: نێوخستە، شاراوە و دەرخستە
The forward pass: from input to answerتێپەڕینی بەرەوپێش: لە نێوخستەوە تا وەڵام
To get an answer, the network runs a forward pass: the input layer hands its numbers to the first hidden layer, every neuron there computes its output, those outputs go to the next layer, and so on until the output layer. The picture shows the small network you will train later in this lesson, after training, with the input (1, 0):
بۆ وەرگرتنی وەڵام، تۆڕەکە ئەنجام دەدات: ژمارەکانی دەداتە یەکەم ، هەر لەوێ خۆی حیساب دەکات، ئەو دەچنە دواتر و بەم شێوەیە تا . وێنەکە ئەو تۆڕە بچووکە پیشان دەدات کە دواتر لەم وانەیەدا ڕای دەهێنیت، دوای ڕاهێنان، بە (1, 0):
The second hidden neuron, for example, computes . Each layer is really one big table of multiplications and additions (a matrix product), which is exactly the work a graphics processor (GPU) does fast.
بۆ نموونە، دووەم شاراوە ئەمە حیساب دەکات: . هەر لە ڕاستیدا یەک خشتەی گەورەی لێکدان و کۆکردنەوەیە (لێکدانی ماتریکس)، کە ڕێک ئەو کارەیە کە بە خێرایی دەیکات.
How wrong is it? The loss functionچەند هەڵەیە؟ کرداری زیان
A new network starts with random weights, so its answers are guesses. To improve, it first needs a number that says how wrong it is. That number comes from a loss function. A common one is the mean squared error: for each example take the difference between the right answer y and the network's answer , square it, and average over all examples.
تۆڕێکی نوێ بە هەڕەمەکی دەست پێ دەکات، بۆیە وەڵامەکانی مەزەندەن. بۆ باشتربوون، سەرەتا پێویستی بە ژمارەیەکە کە بڵێت چەند هەڵەیە. ئەو ژمارەیە لە دێت. یەکێکی باو ناوەندی دووجای هەڵەیە: بۆ هەر نموونەیەک جیاوازیی نێوان وەڵامی ڕاست y و وەڵامی تۆڕەکە وەربگرە، دووجای بکە و ناوەندی هەموو نموونەکان بدۆزەوە.
Example: the right answer is 1 and the network says 0.7, so this example adds (1 − 0.7)² = 0.09.
نموونە: وەڵامی ڕاست 1ـە و تۆڕەکە دەڵێت 0.7، بۆیە ئەم نموونەیە (1 − 0.7)² = 0.09 زیاد دەکات.
Training means one thing: change the weights and biases so that the loss gets smaller. The curve shows this happening in the Python program of this lesson.
ڕاهێنان یەک واتای هەیە: و بگۆڕە بۆ ئەوەی زیانەکە بچووکتر ببێتەوە. چەماوەکە پیشان دەدات ئەمە چۆن لە Pythonـی ئەم وانەیەدا ڕوو دەدات.
How wrong is it? The loss functionچەند هەڵەیە؟ کرداری زیان
Gradient descent: walking downhillدابەزینی گرادیەنت: ڕۆیشتن بەرەو خوارەوەی لێژی
Dilan is on Korek mountain in thick fog and wants to reach the valley. She cannot see far, but she can feel which way the ground slopes under her feet. So she takes a small step downhill, feels again, and steps again. That is gradient descent: the height is the loss, and her position is the weights.
دیلان لە چیای کۆڕەکە لە ناو تەمێکی چڕدا و دەیەوێت بگاتە دۆڵەکە. ناتوانێت دوور ببینێت، بەڵام هەست دەکات زەوی لە ژێر پێیدا بەرەو کوێ لێژە. بۆیە هەنگاوێکی بچووک بەرەو خوار دەنێت، دیسان هەست دەکات و دیسان هەنگاو دەنێت. ئەمە : بەرزی زیانەکەیە و شوێنەکەی ئەویش .
Where the analogy stops workingسنووری ئەم نموونەیە
A real network has millions of weights, so it walks in a landscape with millions of directions, not two.
تۆڕێکی ڕاستەقینە ملیۆنان هەیە، بۆیە لە دیمەنێکدا دەڕوات کە ملیۆنان ئاڕاستەی هەیە، نەک دوو.
The slope of the loss for one weight (its derivative) says which way is uphill. Gradient descent moves the weight a small step the other way. The size of the step is set by the learning rate η. This is hill climbing turned upside down: we want the lowest point.
زیان بۆ یەک (مشتەقەکەی) دەڵێت کام لا بەرەو سەرەوەیە. هەنگاوێکی بچووک بەرەو لای پێچەوانە دەجووڵێنێت. قەبارەی هەنگاوەکە بە η دیاری دەکرێت. ئەمە چیاهەڵەگڕیـە بە پێچەوانەوە: نزمترین خاڵمان دەوێت.
Worked example: one weight, loss (2w − 6)², start w = 1, η = 0.1. The slope is 8w − 24 = −16, so w = 1 − 0.1 × (−16) = 2.6.
نموونەی چارەسەرکراو: یەک ، زیانی (2w − 6)²، دەستپێک w = 1، η = 0.1. 8w − 24 = −16ـە، بۆیە w = 1 − 0.1 × (−16) = 2.6.


How wrong is it? The loss functionچەند هەڵەیە؟ کرداری زیان
The learning rate: how big is each step?ڕێژەی فێربوون: هەر هەنگاوێک چەند گەورەیە؟
The learning rate is chosen by people before training (a hyperparameter, like the number of layers or epochs). The same example, run with three learning rates, shows why the choice matters:
پێش ڕاهێنان لەلایەن مرۆڤەوە هەڵدەبژێردرێت (وەک ژمارەی یان ، ڕێکخستنێکە کە تۆڕەکە خۆی فێری نابێت). هەمان نموونە، بە سێ ، پیشان دەدات بۆچی ئەم هەڵبژاردنە گرنگە:
With 0.3 the loss goes 16, 31.4, 61.5, 120.5: training diverges. In real projects people try a few values (0.1, 0.01, 0.001…) and watch the loss curve.
بە 0.3 زیانەکە دەبێتە 16، 31.4، 61.5، 120.5: ڕاهێنان لێک دەترازێت. لە پڕۆژەی ڕاستەقینەدا خەڵک چەند بەهایەک تاقی دەکەنەوە (0.1، 0.01، 0.001…) و سەیری چەماوەی زیان دەکەن.
How wrong is it? The loss functionچەند هەڵەیە؟ کرداری زیان
Backpropagation: sharing out the blameگەڕاندنەوەی هەڵە بۆ دواوە: دابەشکردنی تاوان
A network has thousands or millions of weights. Which ones caused the error, and by how much? Backpropagation answers this. After the forward pass and the loss, it goes backwards from the output layer to the first hidden layer and, with the chain rule of calculus, works out the slope of the loss for every weight. Then gradient descent changes every weight a little. The method was made popular by Rumelhart, Hinton and Williams in 1986.
تۆڕێک هەزاران یان ملیۆنان هەیە. کامیان بوونە هۆی هەڵەکە و چەند؟ وەڵامی ئەمە دەداتەوە. دوای و زیان، لە بۆ دواوە دەگەڕێتەوە تا یەکەم و بە یاسای زنجیرەی ژمێرکاری زیان بۆ هەموو حیساب دەکات. پاشان هەموو کەمێک دەگۆڕێت. ئەم ڕێگایە لە 1986دا لەلایەن Rumelhart، Hinton و Williamsـەوە بڵاو بووەوە.
When Soran's football team concedes a goal, the coach replays it backwards: the goalkeeper was a little late, but the defender before him was out of place, and the midfielder before that lost the ball. Each player gets his share of the blame and trains on it. Backpropagation shares out the error the same way, layer by layer, from the end back to the start.
کاتێک تیمی تۆپی پێی سۆران گۆڵێکی لێ دەکرێت، ڕاهێنەرەکە بە پێچەوانەوە سەیری دەکاتەوە: گۆڵپارێزەکە کەمێک دواکەوت، بەڵام بەرگریکارەکەی پێش ئەو لە شوێنی خۆیدا نەبوو و یاریزانی ناوەڕاستی پێش ئەویش تۆپەکەی لەدەست دا. هەر یاریزانێک بەشی خۆی لە تاوانەکە وەردەگرێت و لەسەری ڕاهێنان دەکات. بە هەمان شێوە هەڵەکە دابەش دەکات، بە ، لە کۆتاییەوە بۆ سەرەتا.
Where the analogy stops workingسنووری ئەم نموونەیە
The network does not judge; it computes exactly how much each weight changed the loss.
تۆڕەکە دادوەری ناکات؛ ڕێک حیساب دەکات هەر چەندی زیانەکەی گۆڕیوە.
At first the weights are random and the answers are poor. After many thousands of labelled photos, a network trained this way recognises cats it has never seen, much as a child learns pointed ears and whiskers from many examples.
لە سەرەتادا هەڕەمەکین و وەڵامەکان لاوازن. دوای هەزاران وێنەی نیشانەکراو، تۆڕێک کە بەم شێوەیە ڕاهێنرابێت ئەو پشیلانەش دەناسێتەوە کە هەرگیز نەیبینیون، وەک چۆن منداڵێک لە نموونەی زۆرەوە گوێی تیژ و سمێڵ فێر دەبێت.
How wrong is it? The loss functionچەند هەڵەیە؟ کرداری زیان
Epochs, batches and when to stopگەڕی ڕاهێنان، کۆمەڵەکان و کەی ڕابگرین
Training repeats one loop: take a batch of examples, run the forward pass, measure the loss, backpropagate, update the weights. When every training example has been used once, that is one epoch. Big networks train for many epochs on millions of examples.
ڕاهێنان یەک دووپاتە دەکاتەوە: کۆمەڵێک نموونە وەربگرە، ئەنجام بدە، زیانەکە بپێوە، بکە، بگۆڕە. کاتێک هەموو نموونەیەکی ڕاهێنان یەک جار بەکار هات، ئەوە یەک . تۆڕە گەورەکان لەسەر ملیۆنان نموونە بۆ چەندین ڕادەهێنرێن.
How do we know when to stop? Exactly as in Training data and test data: keep some validation data apart. If the training loss still falls but the validation loss starts to rise, the network is memorising: overfitting. Stop there ("early stopping") and measure once on the test data.
چۆن بزانین کەی ڕابگرین؟ ڕێک وەک لە دراوەی ڕاهێنان و دراوەی تاقیکردنەوە: هەندێک جیا ڕابگرە. ئەگەر زیانی ڕاهێنان هێشتا کەم ببێتەوە بەڵام زیانی دەست بکات بە زیادبوون، تۆڕەکە لەبەری دەکات: زیادەگونجاندن. لەوێ ڕایبگرە («ڕاگرتنی زوو») و یەک جار لەسەر بیپێوە.
Why one neuron is not enough: XORبۆچی یەک دەمارەخانەی دەستکرد بەس نییە: XOR
XOR ("exclusive or") answers 1 when exactly one of two inputs is 1, as in the XOR gate of logic design. Draw the four cases on a grid: the two 1s sit on one diagonal and the two 0s on the other. A single neuron can only cut the grid with one straight line, and no straight line puts both 1s on one side and both 0s on the other.
XOR («یان»ی تایبەت) کاتێک 1 دەداتەوە کە ڕێک یەکێک لە دوو 1 بێت، وەک گەیتی XOR لە دیزاینی . چوار حاڵەتەکە لەسەر تۆڕێک بکێشە: دوو 1ـەکە لەسەر یەک تیرەن و دوو 0ـەکە لەسەر تیرەکەی تر. یەک تەنیا دەتوانێت تۆڕەکە بە یەک هێڵی ڕاست ببڕێت و هیچ هێڵێکی ڕاست هەردوو 1ـەکە لە لایەک و هەردوو 0ـەکە لە لایەکی تر دانانێت.
In 1969 Minsky and Papert's book Perceptrons proved this limit, and interest in neural networks fell for years. The way out is a hidden layer: two hidden neurons draw two lines, and the output neuron combines them.
لە 1969دا کتێبی Perceptronsـی Minsky و Papert ئەم سنوورەی سەلماند و بۆ چەند ساڵێک بایەخدان بە کەم بووەوە. ڕێگای دەربازبوون : دوو شاراوە دوو هێڵ دەکێشن و پێکیانەوە دەبەستێت.
Why one neuron is not enough: XORبۆچی یەک دەمارەخانەی دەستکرد بەس نییە: XOR
A tiny network learns XOR in Pythonتۆڕێکی بچووک بە Python XOR فێر دەبێت
This program trains a 2-2-1 network (2 inputs, 2 hidden neurons, 1 output) with everything from this lesson: sigmoid neurons, the squared-error loss, backpropagation and gradient descent. It uses plain Python only, and random.seed(1) makes the "random" start the same at every run.
ئەم تۆڕێکی 2-2-1 ڕادەهێنێت (2 ، 2 شاراوە، 1 ) بە هەموو ئەوەی لەم وانەیەدا هات: بە ، زیانی دووجای هەڵە، و . تەنیا Pythonـی سادە بەکار دەهێنێت و random.seed(1) وا دەکات دەستپێکی «هەڕەمەکی» لە هەموو جارێکدا وەک یەک بێت.
import math, random
random.seed(1) # the same "random" start every run
def sigmoid(z):
return 1 / (1 + math.exp(-z))
# XOR: the answer is 1 when exactly one input is 1
data = [([0, 0], 0), ([0, 1], 1), ([1, 0], 1), ([1, 1], 0)]
H = 2 # neurons in the hidden layer
w_h = [[random.uniform(-1, 1), random.uniform(-1, 1)] for _ in range(H)]
b_h = [0.0] * H
w_o = [random.uniform(-1, 1) for _ in range(H)]
b_o = 0.0
rate = 0.5 # learning rate
def forward(x):
h = [sigmoid(w_h[j][0] * x[0] + w_h[j][1] * x[1] + b_h[j]) for j in range(H)]
y = sigmoid(sum(w_o[j] * h[j] for j in range(H)) + b_o)
return h, y
for epoch in range(10001):
loss = 0
for x, target in data:
h, y = forward(x) # 1. forward pass
loss += (y - target) ** 2 # 2. loss
d_o = 2 * (y - target) * y * (1 - y) # 3. backpropagation
for j in range(H):
d_h = d_o * w_o[j] * h[j] * (1 - h[j])
w_o[j] -= rate * d_o * h[j] # 4. gradient descent
w_h[j][0] -= rate * d_h * x[0]
w_h[j][1] -= rate * d_h * x[1]
b_h[j] -= rate * d_h
b_o -= rate * d_o
if epoch % 2000 == 0:
print(f"epoch {epoch:5}: loss {loss / 4:.4f}")
for x, target in data:
print(x, "->", round(forward(x)[1], 3), " target", target)epoch 0: loss 0.2750 epoch 2000: loss 0.0009 epoch 4000: loss 0.0004 epoch 6000: loss 0.0002 epoch 8000: loss 0.0002 epoch 10000: loss 0.0001 [0, 0] -> 0.013 target 0 [0, 1] -> 0.989 target 1 [1, 0] -> 0.989 target 1 [1, 1] -> 0.011 target 0
Explain the codeڕوونکردنەوەی کۆدەکە
- Lineدێڕی 12-15
Random starting weights between −1 and 1; biases start at 0.
دەستپێک بە هەڕەمەکی لە نێوان −1 و 1دان؛ لە 0ـەوە دەست پێ دەکەن.
- Lineدێڕی 18-21
The forward pass: hidden layer first, then the output neuron.
: سەرەتا ، پاشان .
- Lineدێڕی 27
The squared error of this example is added to the loss.
دووجای هەڵەی ئەم نموونەیە دەخرێتە سەر زیانەکە.
- Lineدێڕی 28-30
Backpropagation:
d_ois the slope for the output neuron;d_hpasses its share back to each hidden neuron (y·(1 − y) is the slope of the sigmoid).:
d_o؛d_hبەشی خۆی دەگەڕێنێتەوە بۆ هەر لە (y·(1 − y) ).- Lineدێڕی 31-35
Gradient descent: every weight and bias takes a small step against its slope.
: هەموو و هەنگاوێکی بچووک بە پێچەوانەی دەنێت.
After training, the hidden neurons have found two ideas: one fires for "only the second input", the other for "only the first", and the output neuron fires for either one. That is XOR built from AND, OR and NOT, as in XOR from basic gates, but nobody programmed it: the network found it.
دوای ڕاهێنان، دوو بیرۆکەیان دۆزیوەتەوە: یەکێکیان بۆ «تەنیا دووەم» چالاک دەبێت، ئەوی تر بۆ «تەنیا یەکەم» و بۆ هەر یەکێکیان چالاک دەبێت. ئەمە XORـە کە لە AND، OR و NOT دروست کراوە، وەک لە XOR لە AND، OR و NOTـەوە، بەڵام کەس بەرنامەی بۆ دانەنا: تۆڕەکە خۆی دۆزییەوە.
Seeing pictures: convolutional neural networksبینینی وێنە: تۆڕە دەمارییە کانڤۆلووشنییەکان
A phone photo has about 36 million numbers (a picture is a grid of numbers). A fully connected neuron would need a weight for each of them, and a cat in the corner would look completely different from a cat in the middle. A convolutional neural network (CNN) solves both problems with small filters: a 3 × 3 grid of weights slides over the picture, and at each place it multiplies the pixels under it by its weights and adds them up.
وێنەیەکی مۆبایل نزیکەی 36 ملیۆن ژمارەی تێدایە (وێنە تۆڕێکی ژمارەیە). کە تەواو بەستراو بێت پێویستی بە دەبێت بۆ هەر یەکێکیان و پشیلەیەک لە گۆشەی وێنەکەدا بە تەواوی جیاواز دەردەکەوێت لە پشیلەیەک لە ناوەڕاستدا. هەردوو کێشەکە بە بچووک چارەسەر دەکات: تۆڕێکی 3 × 3 لە بەسەر وێنەکەدا دەخشێت و لە هەر شوێنێک ئەو لە ژێریدان لە خۆی دەدات و کۆیان دەکاتەوە.
The same few weights are used everywhere in the picture, so a filter that finds an edge finds it in any corner. The numbers it produces form a feature map: big where its pattern is.
هەمان چەند لە هەموو شوێنێکی وێنەکەدا بەکار دێن، بۆیە کە لێوارێک دەدۆزێتەوە لە هەر گۆشەیەکدا دەیدۆزێتەوە. ئەو ژمارانەی دروستی دەکات نەخشەیەکی تایبەتمەندی پێک دێنن: لەو شوێنەی شێوازەکەی لێیە گەورەن.


Seeing pictures: convolutional neural networksبینینی وێنە: تۆڕە دەمارییە کانڤۆلووشنییەکان
Inside a CNN: filters, pooling and the answerناو تۆڕێکی دەماریی کانڤۆلووشنی: فلتەرەکان، پوختەکردن و وەڵام
A real CNN stacks several steps. A convolution layer has many filters (edges in every direction, colours) and passes each feature map through ReLU. A pooling step then makes the maps smaller: max pooling keeps the largest number of each 2 × 2 square, so the square 1, 3, 4, 6 becomes 6. Deeper convolution layers combine edges into shapes such as ears and eyes. At the end a fully connected layer turns everything into one score per class, and softmax turns the scores into probabilities that add up to 1.
ڕاستەقینە چەند هەنگاوێک لەسەر یەک دادەنێت. کانڤۆلووشن چەندین هەیە (لێوار بە هەموو ئاڕاستەیەک، ڕەنگ) و هەر نەخشەیەکی تایبەتمەندی بە تێدەپەڕێنێت. پاشان هەنگاوی نەخشەکان بچووکتر دەکات: بە گەورەترین ژمارە، گەورەترین ژمارەی هەر چوارگۆشەیەکی 2 × 2 دەهێڵێتەوە، بۆیە چوارگۆشەی 1، 3، 4، 6 دەبێتە 6. قووڵتری کانڤۆلووشن لێوارەکان دەکەنە شێوە وەک گوێ و چاو. لە کۆتاییدا تەواو بەستراو هەموو شتێک دەکاتە یەک نمرە بۆ هەر پۆلێک و نمرەکان دەکاتە کە کۆیان 1ـە.
CNNs are older than they look: Yann LeCun's network read handwritten postcodes in 1989. Today they help phones find faces in photos and doctors read X-rays; how such vision systems fail is taught in When AI gets it wrong.
لەوە کۆنترن کە دەردەکەون: تۆڕەکەی Yann LeCun لە 1989دا پۆستکۆدی دەستنووسی دەخوێندەوە. ئەمڕۆ یارمەتی مۆبایل دەدەن ڕووخسار لە وێنەکاندا بدۆزێتەوە و یارمەتی پزیشکان دەدەن وێنەی تیشکی X بخوێننەوە؛ ئەم جۆرە سیستەمانەی بینین چۆن هەڵە دەکەن لە کاتێک ژیریی دەستکرد هەڵە دەکات فێر دەکرێت.
Seeing pictures: convolutional neural networksبینینی وێنە: تۆڕە دەمارییە کانڤۆلووشنییەکان
Deep learning at work: a network that found planetsفێربوونی قووڵ لە کاردا: تۆڕێک کە هەسارەی دۆزییەوە
NASA's Kepler space telescope (2009–2018) measured the brightness of about 150,000 stars again and again. When a planet passes in front of its star, the star looks a tiny bit darker for a few hours: a small dip in its light curve. Real dips are faint and easy to confuse with noise, so people had checked mostly the clearest ones.
تەلەسکۆپی ئاسمانیی Keplerـی NASA (2009–2018) ڕووناکیی نزیکەی 150,000 ئەستێرەی دووپاتە و دووپاتە پێوا. کاتێک هەسارەیەک بە بەردەم ئەستێرەکەیدا تێدەپەڕێت، ئەستێرەکە بۆ چەند کاتژمێرێک کەمێک تاریکتر دیار دەبێت: دابەزینێکی بچووک لە هێڵی ڕووناکییەکەیدا. دابەزینە ڕاستەقینەکان لاوازن و ئاسان لەگەڵ ژاوەژاو تێکەڵ دەبن، بۆیە خەڵک زیاتر ڕوونترینەکانیان پشکنیبوو.
In 2017 Christopher Shallue (Google) and Andrew Vanderburg (University of Texas at Austin) trained a deep convolutional neural network on 15,000 signals that people had already labelled planet or not a planet; it read each light curve like a one-row picture. On test signals it was right 96% of the time. They let it search 670 stars with known planets, and it found two that had been missed: Kepler-90i, which gives the star Kepler-90 eight known planets, as many as our Sun, and Kepler-80g. NASA announced them on 14 December 2017. In 2019 a version for Kepler's second mission, AstroNet-K2, found two more: K2-293b and K2-294b.
لە 2017دا Christopher Shallue (Google) و Andrew Vanderburg (زانکۆی تەکساس لە ئۆستن) قووڵیان لەسەر 15,000 ئاماژە ڕاهێنا کە خەڵک پێشتر بە هەسارە یان هەسارە نییە نیشانەیان کردبوون؛ هەر هێڵێکی ڕووناکی وەک وێنەیەکی یەک ڕیز دەخوێندەوە. لەسەر ئاماژەکانی تاقیکردنەوە لە 96٪ی جارەکاندا ڕاست بوو. پاشان هێشتیان لە 670 ئەستێرەدا بگەڕێت کە هەسارەی زانراویان هەبوو و دوو هەسارەی دۆزییەوە کە لە چاو ون ببوون: Kepler-90i، کە ئەستێرەی Kepler-90 دەکاتە خاوەنی هەشت هەسارەی زانراو، هێندەی خۆری ئێمە، هەروەها Kepler-80g. NASA لە 14ی کانوونی یەکەمی 2017دا ڕایگەیاندن. لە 2019دا وەشانێک بۆ ئەرکی دووەمی Kepler، بە ناوی AstroNet-K2، دوانی دیکەی دۆزییەوە: K2-293b و K2-294b.
This is supervised deep learning at work: labelled examples in, a classifier out, and a real discovery at the end.
ئەمە چاودێریکراوە لە کاردا: نموونەی نیشانەکراو دەچێتە ژوورەوە، پۆلێنکەرێک دێتە دەرەوە و لە کۆتاییدا دۆزینەوەیەکی ڕاستەقینە.
Words and sequences: RNNs and transformersوشە و زنجیرە: تۆڕە دەمارییە گەڕاوەکان و ترانسفۆرمەرەکان
Text, speech and sensor readings come as sequences, where order matters. A recurrent neural network (RNN) reads one item at a time and carries a memory (a hidden state) from each word to the next. It works, but it is slow, because word 10 must wait for word 9, and the memory of early words fades in long texts.
دەق، قسە و خوێندنەوەی وەک زنجیرە دێن، کە ڕیزبەندییان گرنگە. هەر جارە یەک بڕگە دەخوێنێتەوە و بیرەوەرییەک لە هەر وشەیەکەوە بۆ وشەی دواتر دەبات. کار دەکات، بەڵام خاوە، چونکە وشەی 10 دەبێت چاوەڕێی وشەی 9 بکات و لە دەقی درێژدا بیرەوەریی وشە سەرەتاییەکان کاڵ دەبێتەوە.
In 2017 the paper Attention Is All You Need introduced the transformer. It drops the step-by-step memory: with attention, every word looks at every other word at the same time and decides which ones matter for it. Because all words are processed together, GPUs can work on them in parallel. Transformers are the base of today's large language models.
لە 2017دا توێژینەوەی Attention Is All You Need ـی ناساند. ئەو بیرەوەرییە هەنگاو بە هەنگاوە لادەبات: بە ، هەموو وشەیەک لە یەک کاتدا سەیری هەموو وشەکانی تر دەکات و بڕیار دەدات کامیان بۆ ئەو گرنگن. چونکە هەموو وشەکان پێکەوە کاریان لەسەر دەکرێت، دەتوانێت هاوکات کاریان لەسەر بکات. بنەمای ئەمڕۆن.
Words and sequences: RNNs and transformersوشە و زنجیرە: تۆڕە دەمارییە گەڕاوەکان و ترانسفۆرمەرەکان
From deep learning to generative AIلە فێربوونی قووڵەوە بۆ ژیریی دەستکردی بەرهەمهێنەر
The model behind a chatbot, a large language model, is a very deep transformer with billions of weights, trained with the same loss, gradient descent and backpropagation you met in this lesson. Three ideas lead from here to chatbots; the Generative AI course teaches each one:
پشت ، واتە ، زۆر قووڵە بە ملیاران ، کە بە هەمان زیان، و ڕاهێنراوە کە لەم وانەیەدا بینیت. سێ بیرۆکە لێرەوە دەتبەن بۆ ؛ کۆرسی هەریەکەیان فێر دەکات:
- Tokens: text is cut into small pieces, and the model predicts the next piece again and again; a Kurdish sentence usually needs more tokens than the same sentence in English. How a language model writes
- Embeddings: each token becomes a long list of learned numbers, so words used in similar ways, such as Kurdistan and Erbil, get similar vectors. Vectors and embeddings
- Prompts: a model knows the world only from what it was trained on, so a clear, detailed prompt gets a better answer. Prompt engineering
- : دەق دەکرێت بە پارچەی بچووک و دووپاتە و دووپاتە پێشبینیی پارچەی دواتر دەکات؛ ڕستەیەکی کوردی زۆرجار زیاتری پێویستە لە هەمان ڕستە بە ئینگلیزی. مۆدێلی زمان چۆن دەنووسێت
- : هەر دەبێتە لیستێکی درێژی ژمارەی فێربوو، بۆیە ئەو وشانەی بە شێوەی لێکچوو بەکار دێن، وەک کوردستان و هەولێر، لێکچوو وەردەگرن. ئاڕاستەبڕەکان و ئیمبەدینگەکان
- : جیهان تەنیا لەو دەناسێت کە لەسەری ڕاهێنراوە، بۆیە ڕوون و ورد وەڵامێکی باشتر وەردەگرێت. ئەندازیاریی هەوێن
Why deep learning took off in 2012بۆچی فێربوونی قووڵ لە 2012دا هەستایەوە
Most ideas in this lesson are old: the artificial neuron (1943), the perceptron (1958), backpropagation (1986), CNNs (1989). Deep networks still worked badly for decades. Three things changed around 2010:
زۆربەی بیرۆکەکانی ئەم وانەیە کۆنن: (1943)، (1958)، (1986)، (1989). هێشتا بۆ چەندین دەیە تۆڕە قووڵەکان باش کاریان نەدەکرد. نزیکەی 2010 سێ شت گۆڕا:
- Big data: the web gave millions of labelled examples. ImageNet, started by Fei-Fei Li's team, collected over 14 million labelled photos; its yearly contest used 1.2 million training photos in 1,000 classes.
- GPUs: a graphics processor has thousands of small cores that do the same multiply-and-add on many numbers at once, exactly what a layer needs (Graphics processors).
- Better methods: ReLU instead of the sigmoid in hidden layers, and dropout (switching off random neurons during training) against overfitting.
- : وێب ملیۆنان نموونەی نیشانەکراوی دابین کرد. ImageNet، کە تیمەکەی Fei-Fei Li دەستیان پێ کرد، زیاتر لە 14 ملیۆن وێنەی نیشانەکراوی کۆکردەوە؛ پێشبڕکێ ساڵانەکەی 1.2 ملیۆن وێنەی ڕاهێنانی لە 1,000 پۆلدا بەکار دەهێنا.
- : هەزاران ناوکی بچووکی هەیە کە هەمان لێکدان و کۆکردنەوە لەسەر ژمارەیەکی زۆر لە یەک کاتدا دەکەن، ڕێک ئەوەی پێویستیەتی (یەکەی چارەسەرکردنی وێنەیی).
- ڕێگای باشتر: لە جیاتی لە و dropout (کوژاندنەوەی هەڕەمەکیی هەندێک لە کاتی ڕاهێناندا) دژی .
In 2012 AlexNet, a deep CNN by Alex Krizhevsky, Ilya Sutskever and Geoffrey Hinton, trained on two gaming GPUs, won the ImageNet contest by a wide margin. After that, almost every vision system switched to deep learning.
لە 2012دا AlexNet، قووڵی Alex Krizhevsky، Ilya Sutskever و Geoffrey Hinton کە لەسەر دوو ڕاهێنرا کە بۆ یاری دروست کرابوون، بە جیاوازییەکی زۆر پێشبڕکێی ImageNetـی بردەوە. لەوە بەدواوە نزیکەی هەموو سیستەمێکی بینین ڕووی کردە .
Why deep learning took off in 2012بۆچی فێربوونی قووڵ لە 2012دا هەستایەوە
From 1943 to the 2024 Nobel Prizeلە 1943ـەوە تا خەڵاتی نۆبڵی 2024
The timeline shows the main steps. Two of them were honoured with the highest prizes: in 2019 Yoshua Bengio, Geoffrey Hinton and Yann LeCun received the 2018 ACM Turing Award, named after Alan Turing, for making deep neural networks "a critical component of computing". On 8 October 2024 the Nobel Prize in Physics went to John Hopfield (Princeton) and Geoffrey Hinton (Toronto) "for foundational discoveries and inventions that enable machine learning with artificial neural networks": Hopfield's network of 1982 stores and recalls patterns, and Hinton's Boltzmann machine learns the typical features of data.
هێڵی کاتەکە هەنگاوە سەرەکییەکان پیشان دەدات. دووانیان بەرزترین خەڵاتیان وەرگرت: لە 2019دا Yoshua Bengio، Geoffrey Hinton و Yann LeCun خەڵاتی ACM Turingـی 2018یان وەرگرت، کە ناوی ئالان تیورینگـی لەسەرە، چونکە قووڵیان کردە «بەشێکی گرنگی ». لە 8ی تشرینی یەکەمی 2024دا خەڵاتی نۆبڵی فیزیا درا بە John Hopfield (Princeton) و Geoffrey Hinton (Toronto) بۆ «دۆزینەوە و داهێنانە بنەڕەتییەکان کە بە دەستکرد دەگونجێنن»: تۆڕەکەی Hopfield لە 1982 شێواز هەڵدەگرێت و دەیانگەڕێنێتەوە و ئامێری Boltzmannـی Hinton تایبەتمەندییە باوەکانی فێر دەبێت.
Common mistakesهەڵە باوەکان
A mistake in code: in Python, * between two lists does not multiply number by number.
هەڵەیەک لە کۆددا: لە Pythonـدا، * لە نێوان دوو لیستدا ژمارە بە ژمارە لێکیان نادات.
inputs = [0.9, 0.8]
weights = [3.0, 2.0]
bias = -3.5
z = inputs * weights + bias
print(z)Traceback (most recent call last): File "<stdin>", line 5, in <module> TypeError: can't multiply sequence by non-int of type 'list'
inputs = [0.9, 0.8]
weights = [3.0, 2.0]
bias = -3.5
z = sum(x * w for x, w in zip(inputs, weights)) + bias
print(round(z, 2))0.8
Exercisesڕاهێنانەکان
A neuron has inputs 2 and 1, weights 0.5 and −1, and bias 0.5. Find z, then the output with ReLU and with the sigmoid.
2 و 1، 0.5 و −1 و 0.5ـی هەیە. z بدۆزەوە، پاشان بە و بە .
Show answerوەڵامەکە پیشان بدە
z = 0.5 × 2 + (−1) × 1 + 0.5 = 1 − 1 + 0.5 = 0.5. ReLU(0.5) = 0.5. Sigmoid: 1 / (1 + e^(−0.5)) ≈ 0.622 (checked with Python).
z = 0.5 × 2 + (−1) × 1 + 0.5 = 1 − 1 + 0.5 = 0.5. ReLU(0.5) = 0.5. : 1 / (1 + e^(−0.5)) ≈ 0.622 (بە Python پشکنرا).
A fully connected network has 4 inputs, a hidden layer of 3 neurons and an output layer of 2 neurons. How many weights and biases does training have to learn?
تۆڕێکی تەواو بەستراو 4 ، بە 3 و بە 2 هەیە. ڕاهێنان دەبێت فێری چەند و ببێت؟
Hintئاماژە
Each neuron has one weight per input coming in, plus one bias.
هەر بۆ هەر کە دێتە ژوورەوە یەک هەیە، لەگەڵ یەک .
Show answerوەڵامەکە پیشان بدە
Hidden layer: 4 × 3 = 12 weights + 3 biases = 15. Output layer: 3 × 2 = 6 weights + 2 biases = 8. Total: 23.
: 4 × 3 = 12 + 3 = 15. : 3 × 2 = 6 + 2 = 8. کۆی گشتی: 23.
The loss of one weight is , so its slope is . Start at w = 1 with learning rate 0.25 and do two steps. What happens to the loss?
زیانی یەک ـە، بۆیە ـە. لە w = 1ـەوە بە 0.25 دەست پێ بکە و دوو هەنگاو بنێ. زیانەکە چی لێ دێت؟
Show answerوەڵامەکە پیشان بدە
The loss falls 16 → 4 → 1 and w moves towards the best value 5.
زیانەکە 16، 4، 1 دەبێت و w بەرەو باشترین بەها کە 5ـە دەڕوات.
Use the 5 × 5 picture and the edge filter of the convolution animation. Compute the top-left number of the feature map by hand, then check all nine with Python.
وێنە 5 × 5ـەکە و لێواردۆزی ئەنیمەیشنەکەی کانڤۆلووشن بەکار بهێنە. ژمارەی سەرەوەی لای چەپی نەخشەی تایبەتمەندی بە دەست حیساب بکە، پاشان هەر نۆیان بە Python بپشکنە.
Show answerوەڵامەکە پیشان بدە
The top-left window covers rows 1–3 and columns 1–3. Right column 9 + 9 + 0 = 18, left column 0 + 0 + 0 = 0, so 18 − 0 = 18.
پەنجەرەی سەرەوەی لای چەپ ڕیزەکانی 1 تا 3 و ستوونەکانی 1 تا 3 دەگرێتەوە. ستوونی ڕاست 9 + 9 + 0 = 18، ستوونی چەپ 0 + 0 + 0 = 0، بۆیە 18 − 0 = 18.
# A 5x5 grey picture: 0 = dark, 9 = bright
image = [
[0, 0, 9, 9, 9],
[0, 0, 9, 9, 9],
[0, 0, 0, 9, 9],
[0, 0, 0, 9, 9],
[0, 0, 0, 0, 9],
]
# A 3x3 filter that reacts to "dark on the left, bright on the right"
edge = [
[-1, 0, 1],
[-1, 0, 1],
[-1, 0, 1],
]
def convolve(img, f):
size = len(img) - len(f) + 1 # 5 - 3 + 1 = 3
out = []
for r in range(size):
row = []
for c in range(size):
total = 0
for i in range(3):
for j in range(3):
total += img[r + i][c + j] * f[i][j]
row.append(total)
out.append(row)
return out
feature_map = convolve(image, edge)
for row in feature_map:
print(row)[18, 27, 9] [9, 27, 18] [0, 18, 27]
Apply 2 × 2 max pooling to this grid: rows 1 3 0 2 / 4 6 1 0 / 0 2 9 5 / 1 0 3 7.
بە گەورەترین بە چوارگۆشەی 2 × 2 لەسەر ئەم تۆڕە جێبەجێ بکە: ڕیزەکان 1 3 0 2 / 4 6 1 0 / 0 2 9 5 / 1 0 3 7.
Show answerوەڵامەکە پیشان بدە
Top-left square 1, 3, 4, 6 → 6; top-right 0, 2, 1, 0 → 2; bottom-left 0, 2, 1, 0 → 2; bottom-right 9, 5, 3, 7 → 9. Result: 6 2 / 2 9.
چوارگۆشەی سەرەوەی چەپ 1، 3، 4، 6 ← 6؛ سەرەوەی ڕاست 0، 2، 1، 0 ← 2؛ خوارەوەی چەپ 0، 2، 1، 0 ← 2؛ خوارەوەی ڕاست 9، 5، 3، 7 ← 9. ئەنجام: 6 2 / 2 9.
grid = [
[1, 3, 0, 2],
[4, 6, 1, 0],
[0, 2, 9, 5],
[1, 0, 3, 7],
]
pooled = [[max(grid[r][c], grid[r][c + 1], grid[r + 1][c], grid[r + 1][c + 1])
for c in (0, 2)] for r in (0, 2)]
print(pooled)[[6, 2], [2, 9]]
In xor.py, change the last example to ([1, 1], 1) so the network learns OR. Run it. Does it learn? Would a single neuron be enough for OR?
لە xor.pyـدا دوایین نموونە بگۆڕە بۆ ([1, 1], 1) بۆ ئەوەی تۆڕەکە OR فێر ببێت. کاری پێ بکە. فێر دەبێت؟ ئایا یەک بۆ OR بەس دەبوو؟
Show answerوەڵامەکە پیشان بدە
epoch 0: loss 0.2550 epoch 2000: loss 0.0003 epoch 4000: loss 0.0001 epoch 6000: loss 0.0001 epoch 8000: loss 0.0001 epoch 10000: loss 0.0000 [0, 0] -> 0.011 target 0 [0, 1] -> 0.994 target 1 [1, 0] -> 0.994 target 1 [1, 1] -> 0.999 target 1
Yes, it learns OR quickly. One neuron would be enough, because one straight line separates (0, 0) from the other three points; the hidden layer is only needed when one line is not enough, as in XOR.
بەڵێ، بە خێرایی OR فێر دەبێت. یەک بەس دەبوو، چونکە یەک هێڵی ڕاست (0, 0) لە سێ خاڵەکەی تر جیا دەکاتەوە؛ تەنیا کاتێک پێویستە کە یەک هێڵ بەس نەبێت، وەک لە XORـدا.
Lana trains a CNN on 2,000 photos of Kurdish dishes. After epoch 30 the training loss keeps falling to 0.01, but the validation loss rises from 0.40 to 0.75. What is happening, and what should she do?
لانا لەسەر 2,000 وێنەی خواردنی کوردی ڕادەهێنێت. دوای 30، زیانی ڕاهێنان هەر کەم دەبێتەوە تا 0.01، بەڵام زیانی لە 0.40ـەوە بەرز دەبێتەوە بۆ 0.75. چی ڕوو دەدات و دەبێت چی بکات؟
Show answerوەڵامەکە پیشان بدە
Overfitting: the network is memorising the 2,000 photos. She should keep the weights from about epoch 30 (early stopping), and can add more photos, use dropout or a smaller network. Then she tests once on the test data.
: تۆڕەکە 2,000 وێنەکە لەبەر دەکات. دەبێت لە نزیکەی 30 هەڵبگرێت (ڕاگرتنی زوو) و دەتوانێت وێنەی زیاتر زیاد بکات، dropout یان تۆڕێکی بچووکتر بەکار بهێنێت. پاشان یەک جار لەسەر تاقی دەکاتەوە.
Summaryپوختە
- An artificial neuron computes : inputs times weights, plus a bias, through an activation function (ReLU, sigmoid).
- Networks have an input layer, hidden layers and an output layer; deep means many layers, each building on the patterns of the one before.
- Training: forward pass → loss → backpropagation → gradient descent with a learning rate, batch after batch, epoch after epoch; stop when the validation loss rises.
- One neuron draws one straight line, so XOR needs a hidden layer; our 2-2-1 network learned it in plain Python.
- CNNs slide small filters over pictures, then pool and classify; RNNs read sequences step by step; transformers use attention and power today's language models.
- Deep learning took off around 2012 thanks to big data (ImageNet), GPUs and better methods; Hopfield and Hinton received the 2024 Nobel Prize in Physics.
- ئەمە حیساب دەکات: : جاران ، لەگەڵ ، بە ناو (، ).
- تۆڕەکان ، و هەیە؛ قووڵ واتە چەندین ، کە هەریەکەیان لەسەر شێوازەکانی پێشوو بنیات دەنێت.
- ڕاهێنان: ← زیان ← ← بە ، کۆمەڵە لە دوای کۆمەڵە، لە دوای ؛ کاتێک زیانی بەرز دەبێتەوە ڕایبگرە.
- یەک یەک هێڵی ڕاست دەکێشێت، بۆیە XOR پێویستی بە هەیە؛ تۆڕە 2-2-1ـەکەمان بە Pythonـی سادە فێری بوو.
- بچووک بەسەر وێنەدا دەخشێنن، پاشان و پۆلێنکردن دەکەن؛ زنجیرە هەنگاو بە هەنگاو دەخوێننەوە؛ بەکار دەهێنن و ئەمڕۆ دەجووڵێنن.
- نزیکەی 2012 بە هۆی (ImageNet)، و ڕێگای باشترەوە هەستایەوە؛ Hopfield و Hinton خەڵاتی نۆبڵی فیزیای 2024یان وەرگرت.
Why does a neural network need activation functions?بۆچی تۆڕی دەماری پێویستی بە کردارەکانی چالاککردن هەیە؟
Without them, every layer is a straight-line step and the whole network is one straight line. The activation function bends it, so layers can learn curved patterns such as XOR.
بەبێ ئەوان هەر هەنگاوێکی هێڵییە و هەموو تۆڕەکە یەک هێڵی ڕاستە. دەیچەمێنێتەوە، بۆیە دەتوانن شێوازی چەماوە وەک XOR فێر ببن.
What do backpropagation and gradient descent each do?گەڕاندنەوەی هەڵە بۆ دواوە و دابەزینی گرادیەنت هەریەکەیان چی دەکەن؟
Backpropagation computes how much each weight changed the loss (its slope); gradient descent then moves every weight a small step against that slope.
حیساب دەکات هەر چەندی زیانەکەی گۆڕیوە ()؛ پاشان هەموو هەنگاوێکی بچووک بە پێچەوانەی ئەو دەجووڵێنێت.
What is an epoch?گەڕی ڕاهێنان چییە؟
One full pass over all the training data, so every example has been used once to update the weights.
یەک جار تێپەڕبوونی تەواو بەسەر هەموو ، بە شێوەیەک کە هەموو نموونەیەک یەک جار بۆ نوێکردنەوەی بەکار هاتبێت.
What is an embedding?ئیمبەدینگ چییە؟
A learned list of numbers (a vector) for a token or a word. Words used in similar ways get similar vectors; the Generative AI course explains them in depth.
لیستێکی فێربووی ژمارە () بۆ یان وشەیەک. ئەو وشانەی بە شێوەی لێکچوو بەکار دێن لێکچوو وەردەگرن؛ کۆرسی بە قووڵی ڕوونیان دەکاتەوە.
Lesson complete!وانەکە تەواو بوو!
Well done. Review the key terms, then go on to the next lesson.دەستخۆش. سەیرێکی زاراوە سەرەکییەکان بکەرەوە، پاشان بڕۆ بۆ وانەی داهاتوو.
Key termsزاراوە سەرەکییەکان
Related lecturesوانە پەیوەندیدارەکان
- Hill Climbing and Its Problemsچیاهەڵەگڕی و کێشەکانی
- How AI Sees: Sensors, Computer Vision and Detectionژیریی دەستکرد چۆن دەبینێت: هەستەوەرەکان، بینایی کۆمپیوتەر و دۆزینەوە
- When AI Gets It Wrong: Errors, Bias and Deceptionکاتێک ژیریی دەستکرد هەڵە دەکات: هەڵە، لاسەنگی و فریودان
- Processor Speed, Cache, GPUs and Coolingخێرایی پرۆسێسەر، کاش، GPU و ساردکردنەوە
- XOR, XNOR and All Gates at a Glanceگەیتی XOR، گەیتی XNOR و هەموو گەیتەکان بە یەک سەیرکردن
- Can Machines Think? The Turing Testئایا ئامێرەکان بیر دەکەنەوە؟ تاقیکاریی تیورینگ
- What Is Artificial Intelligence?ژیریی دەستکرد چییە؟
- Probability in Computing: Speech, Predictive Text and Riskبەکارهێنانی ئەگەر لە بواری کۆمپیوتەردا: ئاخاوتن، پێشبینیی دەق و مەترسی
- Limits, Derivatives and Integrals: lim, dy/dx, ∂ and ∫ئامانجەکان، مشتەقەکان و تەواوکارییەکان: lim، dy/dx، ∂ و ∫
References and further readingسەرچاوەکان و خوێندنەوەی زیاتر
- Goodfellow, Bengio and Courville (2016), Deep Learning, MIT Press — free online book (ch. 6 feedforward networks, ch. 8 optimisation, ch. 9 convolutional networks, ch. 10 recurrent nets)
- Google Machine Learning Crash Course — Neural networks: nodes and hidden layers
- Google Machine Learning Crash Course — Neural networks: activation functions (sigmoid, tanh, ReLU)
- Google Machine Learning Crash Course — Neural networks: training using backpropagation
- Google Machine Learning Crash Course — Linear regression: gradient descent
- Google Machine Learning Glossary (epoch, iteration, batch, hyperparameter, deep neural network)
- Stanford CS231n — Convolutional Neural Networks for Visual Recognition (filters, pooling, AlexNet)
- MIT 6.S191 — Introduction to Deep Learning (2026 edition)
- IBM Think — What is deep learning?
- IBM Think — What are convolutional neural networks?
- Royal Swedish Academy of Sciences (8 October 2024) — The Nobel Prize in Physics 2024: Hopfield and Hinton
- EurekAlert / ACM (27 March 2019) — Fathers of the Deep Learning Revolution Receive ACM A.M. Turing Award
- Wikipedia — AlexNet (ImageNet 2012, two GTX 580 GPUs, 60 million parameters)
- Wikipedia — Perceptron (McCulloch and Pitts 1943, Rosenblatt 1958, Minsky and Papert 1969)
- Wikipedia — Hopfield network (1982)
- Rumelhart, Hinton and Williams (1986), Learning representations by back-propagating errors, Nature 323
- Vaswani and others (2017), Attention Is All You Need
- Shallue and Vanderburg (2018), Identifying Exoplanets with Deep Learning (a deep convolutional neural network)
- NASA (14 December 2017) — Artificial Intelligence, NASA Data Used to Discover Eighth Planet Circling Distant Star
- NASA — Discovery Alert: Two New Planets Found by AI (AstroNet-K2, 2019)
- CS50's Introduction to AI with Python — Notes 5: Neural Networks
- Google Machine Learning Crash Course — LLMs: What's a large language model? (tokens, self-attention)
- Google Machine Learning Crash Course — Embeddings: embedding space and static embeddings
- Petrov, La Malfa, Torr and Bibi (NeurIPS 2023), Language Model Tokenizers Introduce Unfairness Between Languages
- Brendan Bycroft — LLM Visualization (a GPT model step by step in 3D)
- Python documentation — math.exp and random.seed
This lecture is a first edition. The Kurdish text and terminology are waiting for review by Kurdish IT teachers.ئەم وانەیە چاپی یەکەمە. دەقە کوردییەکە و زاراوەکانی چاوەڕێی پێداچوونەوەی مامۆستایانی کوردی بواری IT ن.