ZPĚTBACK

05Učení z příkladů — perceptronLearning from examples — perceptron

Místo abychom pravidlo naprogramovali, necháme ho stroj najít z dat. Naklikej do plochy modré a červené body a stiskni „Trénuj" — perceptron sám hledá přímku, která obě barvy oddělí. To je nejjednodušší model, který se „učí". Instead of programming the rule, we let the machine find it from data. Click blue and red points into the canvas and press "Train" — the perceptron itself looks for the line that separates the two colors. It's the simplest model that "learns".

Co a jak?What & how?

Co to jeWhat it is Perceptron — nejjednodušší model, který se „učí". Dostane obarvené body (dvě skupiny) a sám hledá přímku, která je od sebe oddělí.A perceptron — the simplest model that “learns”. It gets colored points (two groups) and finds, on its own, a line that separates them.

Co zkusitWhat to try Naklikej do plochy modré a červené body a stiskni „Trénuj". Sleduj schéma nad plátnem — váhy (čísla uvnitř) se mění a přímka se postupně natáčí, dokud body neoddělí.Click blue and red points into the canvas and press “Train”. Watch the diagram above the canvas — the weights (the numbers inside) change and the line gradually rotates until it separates the points.

Proč je to důležitéWhy it matters Je to rozdíl mezi „naprogramovat pravidlo" a „nechat ho stroj najít z příkladů" — základ strojového učení. Zkus body do kříže: narazíš na hranici perceptronu (přímka nestačí), kterou překoná příklad 6.It is the difference between “programming a rule” and “letting the machine find it from examples” — the basis of machine learning. Try points in a cross shape: you hit the perceptron’s limit (a line is not enough), which example 6 overcomes.

jak perceptron vypadá uvnitř (váhy se mění během učení)how a perceptron looks inside (weights change as it learns)
w₁ w₂ w₀ x y 1 bias Σ vážený součet weighted sum aktivace activation ≥ 0 ? třída class ±1
výstup = znaménko( output = sign( w₀ + w₁·x + w₂·y )
epocha:epoch: 0 chybně:misclassified: přesnost:accuracy:
Tip: když body nejdou oddělit přímkou (např. do kříže), perceptron nikdy nedojde k nule chyb — to je jeho hranice. Vyřeší to až příklad 6. Tip: when the points can't be separated by a line (e.g. arranged in a cross), the perceptron never reaches zero errors — that's its limit. Example 6 solves it.
Jak se to učí a kde je hraniceHow it learns and where its limit is

Perceptron má tři čísla (váhy) popisující jednu přímku: w₀ + w₁·x + w₂·y = 0. Na začátku jsou náhodná, čára je „někde". Pak prochází body a u každého špatně zařazeného maličko posune váhy tím správným směrem. Po mnoha opakováních se čára usadí tam, kde barvy odděluje. A perceptron has three numbers (weights) describing one line: w₀ + w₁·x + w₂·y = 0. At first they're random, so the line sits "somewhere". Then it goes through the points and, for each misclassified one, nudges the weights a little in the right direction. After many passes the line settles where it separates the colors.

Naprogramovat × naučitProgram vs. learn

Nikde nepíšeme „když x > 5, je to modré". Dáme jen příklady (body s barvou) a model si pravidlo (čáru) najde sám. Nowhere do we write "if x > 5, it's blue". We give only examples (colored points) and the model finds the rule (the line) on its own.

To je celý princip strojového učení — místo pravidel dodáme data. That's the whole principle of machine learning — instead of rules we supply data.

Učení = posouvání vahLearning = nudging weights

Pro každý špatně zařazený bod se váhy posunou o malý krok (učící rychlost) tak, aby ho příště zařadily lépe. For each misclassified point the weights shift by a small step (the learning rate) so they classify it better next time.

+ jednoduché, rychlé, vždy konverguje…simple, fast, always converges…
…ale jen když data jdou oddělit přímkou…but only when the data can be separated by a line

Lineární hraniceA linear boundary

Perceptron umí nakreslit jen rovnou čáru (rovinu). Na data uspořádaná do kruhu nebo kříže (XOR) prostě nestačí. A perceptron can only draw a straight line (a plane). For data arranged in a circle or a cross (XOR) it simply isn't enough.

Tahle slabina historicky málem AI pohřbila — vyřešily ji až vícevrstvé sítě. This weakness nearly buried AI historically — it took multilayer networks to solve it.

Stavební kámen neuronekThe building block of neural nets

Jeden perceptron = jeden „neuron". Když jich spojíš mnoho do vrstev, vznikne neuronová síť, která zvládne i složité, zakřivené hranice. One perceptron = one "neuron". Connect many of them into layers and you get a neural network that can handle complex, curved boundaries too.

Přesně to ukazuje další příklad. That's exactly what the next example shows.