Perceptron Visualizer
A single-neuron model implementing linear classification boundaries.
What is Perceptron Visualizer?
The Perceptron is the fundamental building block of neural networks, modeling a single biological neuron. It is a linear binary classifier that takes a vector of inputs, calculates their weighted sum, adds a bias, and applies an activation function (like step function) to produce an output (Class A or Class B). It learns by iteratively updating its weights whenever it makes a classification error.
Key Characteristics:
- First artificial single-layer neural network model
- Calculates weighted sum: z = w1*x1 + w2*x2 + ... + bias
- Step Activation: Output 1 if z >= 0, else 0
- Learns only linearly separable datasets
Complexity Analysis
How it Works Step-by-Step
- Compute Input Sum: w1*x1 + w2*x2 + ... + bias.
- Activation: Pass sum through step function; output prediction.
- Calculate Error: error = target_label - predicted_label.
- Update Weights: If error exists, update: w_new = w + rate * error * x.
Code Implementation
Worked Trace Example
Training Perceptron on AND gate with inputs (1,1) [Target 1]:
1. Initial weights: w1=0.2, w2=0.2, bias=-0.5
2. Sum = 0.2(1) + 0.2(1) - 0.5 = -0.1 -> Prediction = 0
3. Error = 1 - 0 = 1 (Misclassified)
4. Update weights: w1 = w1 + 0.1(1)(1) = 0.3. New bias = -0.4.