Convolution & CNNsKonvolusi & CNN

Seeing with filtersMelihat dengan filter

A convolutional network sees an image by sliding tiny filters across it, each one lighting up where it finds the pattern it likes — an edge, a corner, a blob. Here you build filters by hand, watch convolution turn into simple multiplication in frequency space, and then let a network discover its own filters from scratch. You only need the idea of a weighted sum.

Jaringan konvolusi melihat sebuah citra dengan menggeser filter kecil ke seluruh permukaannya, masing-masing menyala di tempat ia menemukan pola yang disukainya — tepi, sudut, gumpalan. Di sini kamu membangun filter dengan tangan, menyaksikan konvolusi berubah jadi perkalian sederhana di ruang frekuensi, lalu membiarkan jaringan menemukan filternya sendiri dari nol. Kamu hanya butuh ide penjumlahan berbobot.

Deep learning · pairs withDeep learning · cocok dengan Fourier (a filter is a frequency selector) and the(filter adalah pemilih frekuensi) dan playground neural-net-from-scratchneural-net-dari-nol playground.itu.

A filter is a small weighted stampFilter adalah stempel kecil berbobot

Take a 3×3 grid of weights. Slide it over the image; at every position, multiply the nine weights by the nine pixels underneath and add them up. That single number is the feature map value there. Different weights detect different things — a blur, an edge, a corner — all from the same slide-multiply-add.

Ambil grid bobot 3×3. Geser ke seluruh citra; di tiap posisi, kalikan sembilan bobot dengan sembilan piksel di bawahnya lalu jumlahkan. Angka tunggal itulah nilai feature map di sana. Bobot berbeda mendeteksi hal berbeda — blur, tepi, sudut — semua dari geser-kali-jumlah yang sama.

ImageCitra

Or draw on the left image with your mouse.

Atau gambar pada citra kiri dengan mouse-mu.

Filter (3×3 weights)Filter (bobot 3×3)

Edit any weight — the feature map updates live. Presets just fill these nine numbers.

Sunting bobot mana pun — feature map diperbarui langsung. Praatur hanya mengisi sembilan angka ini.

weight sumjumlah bobot
1.00
hovered outputkeluaran tersorot

Input image — draw hereCitra masukan — gambar di sini

Feature map — hover to inspectFeature map — arahkan mouse untuk memeriksa

What one output pixel isApa itu satu piksel keluaran

Hover a cell in the feature map: the matching 3×3 patch lights up on the input, and the box above shows the exact nine-term weighted sum that produced it. That is all a convolution layer does — this, millions of times.

Arahkan mouse ke sebuah sel di feature map: patch 3×3 yang cocok menyala di masukan, dan kotak di atas menampilkan penjumlahan berbobot sembilan-suku yang menghasilkannya. Itulah seluruh yang dilakukan lapisan konvolusi — ini, jutaan kali.

Try this
  1. Pick edges and the Sobel ↔ filter: only the vertical strokes light up. Switch to Sobel ↕: now the horizontal ones. Each filter is tuned to one orientation.
  2. Pick box blur: the sharp digit turns soft — the filter replaces each pixel with the average of its neighbours. Compare with sharpen, which does the opposite.
  3. Hand-edit the weights to all-zero except the centre = 1: that's identity, the image passes through untouched. Nudge one neighbour and watch a ghost appear.
Coba ini
  1. Pilih tepi dan filter Sobel ↔: hanya goresan vertikal yang menyala. Ganti ke Sobel ↕: kini yang horizontal. Tiap filter disetel untuk satu orientasi.
  2. Pilih box blur: angka yang tajam jadi lembut — filter mengganti tiap piksel dengan rata-rata tetangganya. Bandingkan dengan pertajam, yang melakukan kebalikannya.
  3. Sunting bobot jadi semua-nol kecuali pusat = 1: itu identitas, citra lewat tanpa berubah. Senggol satu tetangga dan lihat bayangan muncul.
× = in frequency space, blur is just a mask

Every filter is a frequency selectorTiap filter adalah pemilih frekuensi

Convolution feels like a lot of sliding and adding. But move to frequency space (a 2D Fourier transform) and it collapses to a single rule: multiply the image's spectrum by the filter's spectrum. A blur is a filter that keeps only low frequencies; an edge filter keeps only high ones. Same lesson as the Fourier page, now in 2D.

Konvolusi terasa seperti banyak geser dan tambah. Tapi pindah ke ruang frekuensi (transformasi Fourier 2D) dan ia mengerut jadi satu aturan: kalikan spektrum citra dengan spektrum filter. Blur adalah filter yang hanya menyimpan frekuensi rendah; filter tepi hanya menyimpan yang tinggi. Pelajaran yang sama seperti halaman Fourier, kini dalam 2D.

ImageCitra

Or draw on the input image.

Atau gambar pada citra masukan.

Filter

The spectra below are the 2D Fourier transforms: centre = low frequency, edges = high frequency, brighter = more energy.

Spektrum di bawah adalah transformasi Fourier 2D: pusat = frekuensi rendah, tepi = frekuensi tinggi, makin terang = makin banyak energi.

Input imageCitra masukan

Filtered outputKeluaran tersaring

The same thing in frequency space — output spectrum = input × filterHal yang sama di ruang frekuensi — spektrum keluaran = masukan × filter

input spectrumspektrum masukan
filter responserespons filter
output spectrumspektrum keluaran

The ruleAturannya

A blur's response is bright in the middle (keeps low frequencies, kills the fine detail); an edge filter's is bright at the rim (keeps the fast changes, drops the flat regions). This is exactly the Fourier page in two dimensions — see the Fourier bridge → for the 1D story.

Respons blur terang di tengah (menyimpan frekuensi rendah, membunuh detail halus); respons filter tepi terang di pinggir (menyimpan perubahan cepat, membuang wilayah rata). Ini persis halaman Fourier dalam dua dimensi — lihat jembatan Fourier → untuk kisah 1D-nya.

Try this
  1. Blur: watch the outer ring of the output spectrum go dark — high frequencies removed — and the image goes soft.
  2. Edge: the opposite — the centre goes dark, only the rim survives, and the output is all outlines. Flat regions (low frequency) vanish.
  3. Draw something jagged, then blur it: the jaggedness (high frequency) is exactly what disappears first.
Coba ini
  1. Blur: lihat cincin luar spektrum keluaran menggelap — frekuensi tinggi dibuang — dan citra jadi lembut.
  2. Tepi: kebalikannya — pusat menggelap, hanya pinggir yang bertahan, dan keluarannya serba garis tepi. Wilayah rata (frekuensi rendah) lenyap.
  3. Gambar sesuatu yang bergerigi, lalu blur: kegerigian (frekuensi tinggi) itulah yang hilang lebih dulu.
learned filters

Nobody tells it what an edge isTak ada yang memberitahunya apa itu tepi

So far you chose the filters. A convolutional network learns them. Here a tiny CNN is shown random images of a single stroke — sometimes vertical, sometimes horizontal — and must say which. It starts with random filters and, purely from being right or wrong, sculpts them into edge detectors. Watch the filters below turn from noise into structure.

Sejauh ini kamu yang memilih filter. Jaringan konvolusi mempelajarinya. Di sini sebuah CNN kecil diperlihatkan citra acak berisi satu goresan — kadang vertikal, kadang horizontal — dan harus menebak yang mana. Ia mulai dengan filter acak dan, murni dari benar-atau-salah, memahatnya jadi detektor tepi. Lihat filter di bawah berubah dari derau jadi struktur.

The taskTugasnya

Each image has one bright stroke plus noise. Class: is it vertical or horizontal? The net: 4 learnable 3×3 filters → ReLU → average-pool → a 2-way decision.

Tiap citra punya satu goresan terang plus derau. Kelas: vertikal atau horizontal? Jaringannya: 4 filter 3×3 yang dapat dilatih → ReLU → average-pool → keputusan 2-arah.

TrainingPelatihan

Every step draws a fresh batch of random strokes, predicts, and nudges the filters by gradient descent — exactly the loop from the neural-net playground, now over images.

Tiap langkah menggambar satu batch goresan acak baru, memprediksi, dan menyenggol filter dengan gradient descent — persis loop dari playground neural-net, kini atas citra.

training stepslangkah pelatihan
0
accuracyakurasi
loss

A sample & the network's guessSatu contoh & tebakan jaringan

Accuracy while trainingAkurasi selama pelatihan

The four filters it is learning — watch them become edge detectorsEmpat filter yang dipelajarinya — lihat mereka jadi detektor tepi

Warm = positive weight, cool = negative. A good vertical-edge filter ends up with one bright column beside one dark column — the same Sobel shape you built by hand in tab 1, but discovered, not designed.

Hangat = bobot positif, sejuk = negatif. Filter tepi-vertikal yang baik berakhir dengan satu kolom terang di samping satu kolom gelap — bentuk Sobel yang sama yang kamu bangun sendiri di tab 1, tapi ditemukan, bukan dirancang.

Try this
  1. Press Train and watch the accuracy shoot up while the four noisy filters organise into clean light/dark stripes within a few seconds.
  2. Reset a few times: the filters land in different arrangements each run — there is no single "correct" filter, only ones that work. Some runs even leave a filter unused.
  3. Compare a learned filter to the hand-built Sobel in tab 1. The network reinvented the edge detector on its own, guided only by right-vs-wrong.
Coba ini
  1. Tekan Train dan lihat akurasi melesat sementara empat filter berderau menata diri jadi garis terang/gelap yang rapi dalam beberapa detik.
  2. Reset beberapa kali: filternya mendarat dalam susunan berbeda tiap kali — tak ada satu filter "benar", hanya yang bekerja. Beberapa kali bahkan menyisakan satu filter tak terpakai.
  3. Bandingkan filter terpelajar dengan Sobel buatan-tangan di tab 1. Jaringan menemukan kembali detektor tepi sendiri, dipandu hanya oleh benar-vs-salah.

What just happened

This is the whole idea of deep learning for vision: don't hand-engineer features, learn them. Stack more of these layers and the filters in later layers combine edges into corners, corners into textures, textures into object parts — a hierarchy nobody wrote down. Real CNNs (for photos, medical scans, self-driving) are this exact mechanism, just wider, deeper, and trained on millions of images.

Inilah keseluruhan ide deep learning untuk penglihatan: jangan rekayasa fitur dengan tangan, pelajari. Tumpuk lebih banyak lapisan ini dan filter di lapisan berikutnya menggabungkan tepi jadi sudut, sudut jadi tekstur, tekstur jadi bagian objek — hierarki yang tak ditulis siapa pun. CNN sungguhan (untuk foto, pindai medis, mobil swakemudi) adalah mekanisme persis ini, hanya lebih lebar, lebih dalam, dan dilatih pada jutaan citra.

The catch: that power needs data and compute, and the learned filters are only as unbiased as the training set. This toy learns two clean classes in seconds; ImageNet-scale vision took years of GPUs.

Tangkapannya: kekuatan itu butuh data dan komputasi, dan filter terpelajar hanya senetral set pelatihannya. Mainan ini mempelajari dua kelas bersih dalam hitungan detik; penglihatan skala-ImageNet butuh bertahun-tahun GPU.

Three views of one operationTiga sudut pandang satu operasi

In spaceDi ruangIn frequencyDi frekuensiIn a CNNDi CNN
What a filter isApa itu filterA 3×3 grid of weights you slide and dot-productGrid bobot 3×3 yang digeser dan di-dot-productA mask that scales each frequencyTopeng yang menskala tiap frekuensiNine numbers the network learns by gradient descentSembilan angka yang dipelajari jaringan lewat gradient descent
BlurAverage of neighboursRata-rata tetanggaKeep low frequencies (low-pass)Simpan frekuensi rendah (low-pass)Rarely learned — it throws away detailJarang dipelajari — ia membuang detail
EdgeTepiNeighbour minus neighbourTetangga dikurangi tetanggaKeep high frequencies (high-pass)Simpan frekuensi tinggi (high-pass)The first thing early layers learnHal pertama yang dipelajari lapisan awal
CostOngkosOne dot product per output pixelSatu dot product per piksel keluaranOne multiply per frequency (via FFT)Satu perkalian per frekuensi (lewat FFT)Filters shared across the whole image — few weights, huge reachFilter dibagi ke seluruh citra — sedikit bobot, jangkauan besar

The same operation, seen three ways. The Fourier view explains why filters do what they do; the CNN view explains where the filters come from.

Operasi yang sama, dilihat dari tiga sisi. Sudut Fourier menjelaskan kenapa filter melakukan yang dilakukannya; sudut CNN menjelaskan dari mana filter itu berasal.

Where this connectsKe mana ini terhubung

← Fourier. A filter is a frequency selector; convolution in space is multiplication in frequency. The Fourier bridge is the 1D version of tab 2.

← Fourier. Filter adalah pemilih frekuensi; konvolusi di ruang adalah perkalian di frekuensi. Jembatan Fourier adalah versi 1D dari tab 2.

← Neural net from scratch. Tab 3 is the same gradient-descent training loop as the MLP playground, but the weights are shared filters slid over an image instead of a dense layer.

← Neural net dari nol. Tab 3 adalah loop pelatihan gradient-descent yang sama seperti playground MLP, tapi bobotnya adalah filter bersama yang digeser di atas citra alih-alih lapisan dense.

→ What comes next. Pooling, stacking layers into a deep hierarchy, and — the modern successor for many tasks — attention, where a token learns which other tokens to look at instead of using a fixed local window.

→ Apa selanjutnya. Pooling, menumpuk lapisan jadi hierarki dalam, dan — penerus modern untuk banyak tugas — attention, di mana sebuah token mempelajari token lain mana yang harus dilihat alih-alih memakai jendela lokal tetap.

Check yourselfUji dirimu