How AI learnsCara AI belajar

A real neural network, small enough to watch. It starts out knowing nothing, learns handwritten digits right here in your browser, and then you test it with your own handwriting. Jaringan saraf tiruan beneran, cukup kecil buat diamati. Awalnya nggak tahu apa-apa, belajar angka tulisan tangan langsung di browser kamu, lalu kamu uji pakai tulisan tanganmu sendiri.

1Meet the networkKenalan sama jaringannya

A digit comes in as 196 numbers (14 × 14 pixels, 0 = black, 1 = white). Each of the 32 neurons in the middle multiplies every pixel by its own weight and adds them up. The squares below are those weights drawn as pictures: blue = "I want ink here", red = "ink here counts against". Before training they're random speckle. The 10 outputs (one per digit) do the same with the 32 neurons, and the biggest one is the answer. Satu angka masuk sebagai 196 bilangan (14 × 14 piksel, 0 = hitam, 1 = putih). Tiap 32 neuron di tengah mengalikan setiap piksel dengan bobotnya sendiri lalu menjumlahkannya. Kotak-kotak di bawah adalah bobot itu digambar: biru = "aku mau ada tinta di sini", merah = "tinta di sini malah mengurangi". Sebelum dilatih isinya cuma bintik acak. 10 output (satu per angka) melakukan hal yang sama ke 32 neuron itu, dan yang paling besar jadi jawabannya.

INPUT 14×14INPUT 14×14
32 NEURONS · what each one looks for32 NEURON · yang dicari tiap neuron
10 OUTPUTS10 OUTPUT

2Train itLatih

Training = show it a digit, see how wrong its answer is, and nudge every weight a tiny bit in the direction that would have made it less wrong. Then the next digit. That's all "learning" is here. Watch the squares above grow from speckle into stroke detectors. Latihan = tunjukkan satu angka, lihat seberapa salah jawabannya, lalu geser setiap bobot sedikit ke arah yang bikin jawabannya kurang salah. Lalu angka berikutnya. Cuma itu yang disebut "belajar" di sini. Lihat kotak-kotak di atas tumbuh dari bintik acak jadi pendeteksi goresan.

Examples to learn fromContoh untuk belajar
Learning rateLaju belajar 0.10
test accuracy (digits it has never seen)akurasi tes (angka yang belum pernah dilihat) training accuracy (its homework)akurasi latihan (PR-nya)
–
test accuracyakurasi tes
0
digits seenangka dilihat
–
error (loss), lower = bettererror (loss), makin kecil makin bagus
–

loading 7,000 handwritten digits…memuat 7.000 angka tulisan tangan…

3Test it with your handwritingUji pakai tulisan tanganmu

Draw one digit, big, in the middle. Your drawing gets shrunk to 14 × 14 and centred the same way the training digits were, then goes through the network. The neurons that fire light up in step 1. Gambar satu angka, besar, di tengah. Gambarmu dikecilkan jadi 14 × 14 dan ditaruh di tengah dengan cara yang sama seperti angka latihan, lalu masuk ke jaringan. Neuron yang aktif menyala di langkah 1.

Draw something.Gambar sesuatu.

4What just happenedBarusan itu apa

A neuron is just: multiply each input by a weight, add them up, add a bias, and if the total is negative, output 0 (that last step is called ReLU). out = max(0, w₁x₁ + w₂x₂ + … + w₁₉₆x₁₉₆ + b). This network has 6,634 of these weights and biases. Nobody typed them in.

Learning is measuring how wrong the answer was (the loss) and working out, for every weight, whether raising it a little would make the loss go up or down. That's calculus: the gradient. Then every weight takes a small step downhill: w ← w − learning rate × gradient. Working out the gradients for all the layers at once, from the output back to the input, is called backpropagation. Repeat a few thousand times.

Why a separate test set? A network can memorise its homework. The blue line only counts digits it has never trained on, which is the honest score.

  1. Set Examples to 100 and train: the grey line (homework) hits 100%, the blue line (test) gets stuck far below. That gap is overfitting: it memorised 100 digits instead of learning what digits look like. More data fixes it.
  2. Push the learning rate all the way up: the steps are too big, it overshoots and the accuracy jumps around or collapses. Too low and it barely moves.
  3. Draw a 7 with a line through it, or a tiny 1 in a corner, or a letter. The training digits are mostly American-style handwriting, so it has never seen some of yours. It still answers, confidently. Networks don't know what they don't know.

And chatbots? Same idea, much bigger. A chatbot is also layers of neurons with weights found by gradient descent, but with billions of weights instead of 6,634, trained on huge amounts of text to predict the next word instead of which digit it's looking at. No rules typed in by hand there either.

Satu neuron itu cuma: kalikan tiap input dengan bobot, jumlahkan, tambah bias, dan kalau totalnya negatif, keluarkan 0 (langkah terakhir ini namanya ReLU). out = max(0, w₁x₁ + w₂x₂ + … + w₁₉₆x₁₉₆ + b). Jaringan ini punya 6.634 bobot dan bias seperti itu. Nggak ada yang mengetiknya satu-satu.

Belajar artinya mengukur seberapa salah jawabannya (loss) lalu menghitung, untuk setiap bobot, kalau bobotnya dinaikkan sedikit, loss-nya naik atau turun. Itu kalkulus: gradien. Lalu setiap bobot melangkah sedikit ke arah turun: w ← w − laju belajar × gradien. Menghitung gradien semua lapisan sekaligus, dari output mundur ke input, namanya backpropagation. Ulangi beberapa ribu kali.

Kenapa ada data tes terpisah? Jaringan bisa menghafal PR-nya. Garis biru cuma menghitung angka yang belum pernah dipakai latihan, jadi itu nilai yang jujur.

  1. Pasang Contoh ke 100 lalu latih: garis abu-abu (PR) tembus 100%, garis biru (tes) mentok jauh di bawah. Selisih itu namanya overfitting: dia menghafal 100 angka, bukan belajar bentuk angka. Data yang lebih banyak memperbaikinya.
  2. Geser laju belajar sampai mentok: langkahnya kegedean, kelewatan, dan akurasinya loncat-loncat atau ambruk. Terlalu kecil, hampir nggak bergerak.
  3. Gambar angka 7 pakai coretan di tengah, angka 1 kecil di pojok, atau huruf. Data latihannya kebanyakan tulisan tangan gaya Amerika, jadi ada gaya tulisanmu yang belum pernah dia lihat. Dia tetap menjawab, dengan yakin. Jaringan nggak tahu apa yang dia nggak tahu.

Terus chatbot? Idenya sama, cuma jauh lebih besar. Chatbot juga lapisan-lapisan neuron dengan bobot yang dicari lewat gradient descent, tapi bobotnya miliaran, bukan 6.634, dan dilatih dengan teks yang sangat banyak untuk menebak kata berikutnya, bukan menebak angka. Di sana juga nggak ada aturan yang diketik manual.

← hub