Perceptron
Perceptron adalah model neural network paling sederhana, terinspirasi dari cara kerja sel saraf biologis (biological neuron).
#Link to this headingA Simplified Brain Cell

McCulloch dan Pitts mendeskripsikan sebuah simple logic gate dengan binary outputs:
- Banyak sinyal tiba di dendrites
- Diintegrasikan dalam cell body
- Jika sinyal akumulasi melebihi threshold tertentu, sinyal output dihasilkan melalui axon
#Link to this headingDefinisi Formal Neuron

Dalam konteks binary classification:
- Input: real-valued
- Weight vector: , di mana merepresentasikan kontribusi input
- Bias/threshold: (atau )
- Net input:
- Output: jika net input melebihi threshold tertentu
#Link to this headingPerceptron

Perceptron merepresentasikan hyperplane decision surface dalam ruang -dimensi dari instances.
- Linear model untuk linearly separable dataset
- Simple neural network berbasis satu unit
- Learning output:
- Hypothesis space:
#Link to this headingPerceptron untuk m-of-n Functions
m-of-n functions: setidaknya dari input harus bernilai true.
| Fungsi | Contoh | |
|---|---|---|
| AND | sign(x1 + x2 - 1) | |
| OR | sign(2x1 + 2x2 - 1) |
Cara merepresentasikan m-of-n function:
- Set semua input weights ke nilai yang sama (e.g., )
- Set threshold yang sesuai
#Link to this headingContoh: AND Perceptron

Dengan , → merepresentasikan fungsi AND:
#Link to this headingAlgoritma Pembelajaran Perceptron

Terdapat tiga algoritma pembelajaran utama:
| Algoritma | Fungsi Aktivasi | Update Bobot | Konvergensi |
|---|---|---|---|
| Perceptron Training Rule (PTR) | Sign | Saat misclassified | Hanya jika linearly separable |
| Batch Gradient Descent (BGD) | Linear | Setelah semua examples | Best-fit approximation |
| Stochastic Gradient Descent (SGD) | Linear | Setelah setiap example | Best-fit approximation |
#Link to this headingPerceptron Training Rule (PTR)

Menggunakan fungsi aktivasi sign. Update bobot hanya saat terjadi misclassification:
Initialize each w_k to 0 or small random value
Repeat:
E = 0
For each example <x_i, y_i>:
o_i = sign(w^T * x_i)
if o_i == y_i: do nothing
else:
w_j = w_j + η(y_i - o_i) * x_ij ← untuk setiap weight
E = E + (y_i - o_i)
Until all training examples correctly classified
Return w#Link to this headingContoh PTR

Dataset: , fungsi aktivasi SIGN
Inisialisasi:
Epoch 1:
| iter | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | 1 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | ||
| 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 2 | ||||
| 1 | 1 | 0.2 | 0 | −0.2 | −0.2 | 0.5 | 2 |
Setelah Epoch 1:
Epoch 2:
| iter | ||||||||
|---|---|---|---|---|---|---|---|---|
| 2 | 1 | 1 | 0 | 1 | 0 | 0 | ||
| 2 | 1 | 0 | 0.6 | 0 | ||||
| 2 | 1 | 0.5 | 0 |
Terminate - Semua prediksi benar.
#Link to this headingGradient Descent (Delta Rule)

Jika data tidak linearly separable, PTR gagal konvergen. Delta Rule (gradient descent) konvergen menuju best-fit approximation terlepas apakah data linearly separable atau tidak.
Searching strategy menggunakan gradient dari error landscape untuk menemukan minimum error:
#Link to this headingFungsi Aktivasi Linear
Pada delta rule, output menggunakan fungsi aktivasi linear (unthresholded):
Error menggunakan squared error:

#Link to this headingBatch Gradient Descent (BGD)
Menghitung akumulasi weight updates setelah memproses semua training examples, baru kemudian update bobot.
Initialize each w_k to 0 or small random value
Until termination condition is met:
Initialize Δw_k = 0 for all k; E = 0
For each example <x_i, y_i>:
o_i = w^T * x_i (linear activation)
For each weight w_k:
Δw_k = Δw_k + η(y_i - o_i) * x_ik
E = E + (y_i - o_i)² / 2
For each weight w_k:
w_k = w_k + Δw_k
Return w#Link to this headingContoh BGD

Dataset: , fungsi aktivasi LINEAR, error threshold
Inisialisasi:
Epoch 1 - Akumulasi :
| iter | |||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | 1 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0.500 | |||||
| 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 1.000 | |||||||
| 1 | 1 | 0 | 0 | 0 | 0 | 0 | 1.500 |
Update:
Epoch 2:
| iter | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| 2 | 1 | 1 | 0 | 1 | 0.020 | ||||||
| 2 | 1 | 0 | 0.231 | ||||||||
| 2 | 1 | 0.757 |
Update:
Proses berlanjut hingga .
#Link to this headingStochastic Gradient Descent (SGD)
Berbeda dengan BGD, SGD langsung update bobot setelah setiap training example, tidak menunggu semua data diproses.
Initialize each w_k to 0 or small random value
Until termination condition is met:
E = 0
For each example <x_i, y_i>:
o_i = w^T * x_i (linear activation)
For each weight w_k:
w_k = w_k + η(y_i - o_i) * x_ik ← langsung update
E = E + (y_i - o_i)² / 2
Return w#Link to this headingContoh SGD

Dataset sama: , fungsi aktivasi LINEAR, error threshold
Epoch 1:
| iter | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | 1 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0.500 | |
| 1 | 1 | 0 | 0 | 1.000 | |||||||
| 1 | 1 | 1.001 |
Setelah Epoch 1:
Epoch 2:
| iter | |||||||
|---|---|---|---|---|---|---|---|
| 2 | 1 | 1 | 0 | 1 | 0.007 | ||
| 2 | 1 | 0 | 0.016 | ||||
| 2 | 1 | 0.026 |
Setelah Epoch 2:
Proses berlanjut hingga epoch 4 di mana → terminate.
#Link to this headingBatch vs Stochastic Gradient Descent

Keduanya menggunakan fungsi aktivasi linear dan konvergen menuju best-fit approximation.
| Aspek | Batch GD | Stochastic GD |
|---|---|---|
| Update bobot | Setelah semua examples | Setelah setiap example |
| Konvergensi | Smooth, stabil | Lebih noisy, bisa keluar dari local minima |
| Kecepatan per epoch | Lebih lambat | Lebih cepat |
#Link to this headingMini-batch SGD
| Parameter | Penjelasan |
|---|---|
| Epoch | Iterasi untuk semua training data atau semua mini-batch |
| Batch size = 1 | True SGD (incremental) |
| Batch size = |data| | Batch GD |
| 1 < batch size < |data| | Mini-batch SGD |
| Step | Pemrosesan satu mini-batch diakhiri dengan update bobot |
#Link to this headingPerceptron: Kesimpulan
Perceptron Training Rule:
- Linear classifier, tidak dapat membuat non-linear boundaries
- Update bobot berdasarkan error pada thresholded perceptron output
- Tidak konvergen jika kelas tidak linearly separable
- Banyak solusi "optimal" dalam 0/1 loss, sebagian besar tidak optimal untuk generalisasi
Gradient Descent (Delta Rule):
- Update bobot berdasarkan error pada unthresholded linear combination of inputs
- Konvergen secara asimtotik menuju minimum hypothesis, terlepas dari linear separability
- Batch / Incremental weight update