What is perceptron?
- User
What is perceptron?
- Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
What is perceptron?
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
| Aspect | TL;DR |
|---|---|
| What? | The simplest neural “neuron.” It takes several inputs, weighs them, adds a bias, applies a step function, and spits out a binary decision (0 / 1 or –1 / +1). |
| Who? | Introduced by Frank Rosenblatt in 1957. |
| Why? | Foundational building block for modern neural networks and a classic linear classifier in machine learning. |
“Is the weighted sum of the inputs high enough?
Yes ➜ fire (class = 1)
No ➜ stay quiet (class = 0)”
Think of it as the simplest vote-taking committee:
y = {
1, if w·x + b ≥ 0
0, otherwise
}
x : input feature vector (x₁, x₂, …, xₙ)w : weight vector (w₁, w₂, …, wₙ)b : bias (threshold)· : dot productThe perceptron draws a straight decision boundary (a hyperplane) in feature space.
For each training example (x, y):
e = y – ŷw ← w + η * e * x
b ← b + η * e
Repeat until all points are classified correctly or a max # of epochs is reached.
✔ Pros
• Simple, fast, online-friendly
• Guarantees convergence if data are linearly separable
✘ Cons
• Fails on non-linearly separable problems (famous XOR example)
• Outputs only hard binary decisions (no probabilities)
• Sensitive to feature scaling and learning-rate choices
import numpy as np
def perceptron_train(X, y, lr=0.1, epochs=50):
w = np.zeros(X.shape[1])
b = 0
for _ in range(epochs):
for xi, yi in zip(X, y):
y_hat = 1 if (np.dot(w, xi) + b) >= 0 else 0
error = yi - y_hat
w += lr * error * xi
b += lr * error
return w, b
def perceptron_predict(X, w, b):
return (np.dot(X, w) + b >= 0).astype(int)
Feel free to ask if you'd like deeper math, visualization, or real-world examples! 😃